tbx  0.7.5
resactionbutton.h
1 /*
2  * tbx RISC OS toolbox library
3  *
4  * Copyright (C) 2010 Alan Buckley All Rights Reserved.
5  *
6  * Permission is hereby granted, free of charge, to any person obtaining a
7  * copy of this software and associated documentation files (the "Software"),
8  * to deal in the Software without restriction, including without limitation
9  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
10  * and/or sell copies of the Software, and to permit persons to whom the
11  * Software is furnished to do so, subject to the following conditions:
12  *
13  * The above copyright notice and this permission notice shall be included
14  * in all copies or substantial portions of the Software.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22  * THE SOFTWARE.
23  */
24 
25 #ifndef TBX_RES_RESACTIONBUTTON_H
26 #define TBX_RES_RESACTIONBUTTON_H
27 
28 #include "resgadget.h"
29 
30 namespace tbx {
31 namespace res {
32 
36 class ResActionButton : public ResGadget
37 {
38 
39 public:
40  enum {TYPE_ID = 128 };
41 
48  ResActionButton(const ResGadget &other) : ResGadget(other)
49  {
50  check_type(TYPE_ID);
51  }
52 
58  ResActionButton(const ResActionButton &other) : ResGadget(other)
59  {
60  }
61 
62  virtual ~ResActionButton() {}
63 
71  {
72  other.check_type(TYPE_ID);
73  ResBase::operator=(other);
74  return *this;
75  }
76 
83  {
84  ResBase::operator=(other);
85  return *this;
86  }
87 
94  : ResGadget(128,52)
95  {
96  init_message(36,0); // text
97  init_string(44,0); // click_show
98  }
99 
108  bool is_default() const {return flag(0, 1<<0);}
117  void is_default(bool value) {flag(0,1<<0,value);}
126  bool cancel() const {return flag(0, 1<<1);}
135  void cancel(bool value) {flag(0,1<<1,value);}
144  bool local() const {return flag(0, 1<<2);}
153  void local(bool value) {flag(0,1<<2,value);}
154 
160  bool click_show_transient() const {return flag(0, 1<<3);}
166  void click_show_transient(bool value) {flag(0,1<<3,value);}
167 
173  const char *text() const {return message(36);}
181  void text(const char *value, int max_length = -1) {message_with_length(36, value, max_length);}
189  void text(const std::string &value, int max_length = -1) {message_with_length(36, value, max_length);}
195  int max_text_len() const {return int_value(40);}
202  const char *click_show() const {return string(44);}
208  void click_show(const char *value) {string(44, value);}
214  void click_show(const std::string &value) {string(44, value);}
220  int event() const {return int_value(48);}
226  void event(int value) {int_value(48,value);}
227 };
228 
229 }
230 }
231 
232 #endif // TBX_RES_RESACTIONBUTTON_H
233 
void click_show(const char *value)
Set the name of the object to show on click.
Definition: resactionbutton.h:208
A library for creating RISC OS toolbox applications.
Definition: abouttobeshownlistener.cc:34
bool is_default() const
Check if this is the default button.
Definition: resactionbutton.h:108
Base class for gadget memory resources.
Definition: resgadget.h:42
ResActionButton(const ResActionButton &other)
Construct an action button gadget resource.
Definition: resactionbutton.h:58
void init_string(int offset, const char *value)
Initialise a string in a constructor helper.
Definition: resbase.cc:1725
void message_with_length(int offset, const char *value, int length=-1)
Assign a message where the length is at offset+4.
Definition: resbase.cc:1639
bool flag(int offset, int mask) const
Check if any of the bits in a mask are set.
Definition: resbase.h:352
ResActionButton & operator=(const ResActionButton &other)
Assign from another action button gadget resource.
Definition: resactionbutton.h:82
void text(const std::string &value, int max_length=-1)
Set the text for the button.
Definition: resactionbutton.h:189
bool cancel() const
Check if this is the cancel button.
Definition: resactionbutton.h:126
ResActionButton & operator=(const ResGadget &other)
Assign from a ResGadget.
Definition: resactionbutton.h:70
Classes to use/edit toolbox resources in memory.
void local(bool value)
Set if this is a local button.
Definition: resactionbutton.h:153
const char * click_show() const
Get the name of object to show on click.
Definition: resactionbutton.h:202
bool click_show_transient() const
Check if the object shown on a click is transient.
Definition: resactionbutton.h:160
void event(int value)
Set the event number to be generated by this button.
Definition: resactionbutton.h:226
Class for ActionButton gadget template.
Definition: resactionbutton.h:36
void text(const char *value, int max_length=-1)
Set the text for the button.
Definition: resactionbutton.h:181
int int_value(int offset) const
Get an integer value.
Definition: resbase.h:316
const char * text() const
Get the text for the button.
Definition: resactionbutton.h:173
void click_show_transient(bool value)
Set if the object shown on a click is transient.
Definition: resactionbutton.h:166
const char * string(int offset) const
Return a string at the given offset.
Definition: resbase.cc:1555
int max_text_len() const
Get the maximum length for the text.
Definition: resactionbutton.h:195
void click_show(const std::string &value)
Set the name of the object to show on click.
Definition: resactionbutton.h:214
bool local() const
Check if this is a local button.
Definition: resactionbutton.h:144
ResActionButton()
Construct a action button gadget resource.
Definition: resactionbutton.h:93
ResActionButton(const ResGadget &other)
Construct an action button gadget resource.
Definition: resactionbutton.h:48
const char * message(int offset) const
Get the message string at the given offset.
Definition: resbase.cc:1602
int event() const
Get the event number generated by this button.
Definition: resactionbutton.h:220
ResBase & operator=(const ResBase &other)
Assignment.
Definition: resbase.cc:1534
void cancel(bool value)
Set if this is the cancel button.
Definition: resactionbutton.h:135
void check_type(int type) const
Check if this gadgets type is as specified.
Definition: reswindow.cc:97
void is_default(bool value)
Set if this is a default button.
Definition: resactionbutton.h:117
void init_message(int offset, const char *value)
Initialise a message in a constructor helper.
Definition: resbase.cc:1736