tbx  0.7.6
resradiobutton.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_RESRADIOBUTTON_H
26 #define TBX_RES_RESRADIOBUTTON_H
27 
28 #include "resgadget.h"
29 
30 namespace tbx {
31 namespace res {
32 
36 class ResRadioButton : public ResGadget
37 {
38 
39 public:
40  enum {TYPE_ID = 384 };
41 
48  ResRadioButton(const ResGadget &other) : ResGadget(other)
49  {
50  check_type(TYPE_ID);
51  }
52 
58  ResRadioButton(const ResRadioButton &other) : ResGadget(other)
59  {
60  }
61 
62  virtual ~ResRadioButton() {}
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(384,52)
95  {
96  init_message(40,0); // label
97  }
98 
104  bool generate_state_changed() const {return flag(0, 1<<0);}
110  void generate_state_changed(bool value) {flag(0,1<<0,value);}
116  bool on() const {return flag(0, 1<<2);}
122  void on(bool value) {flag(0,1<<2,value);}
123 
132  int group_number() const {return int_value(36);}
141  void group_number(int value) {int_value(36,value);}
147  const char *label() const {return message(40);}
155  void label(const char *value, int max_length = -1) {message_with_length(40, value, max_length);}
163  void label(const std::string &value, int max_length = -1) {message_with_length(40, value, max_length);}
167  int max_label_len() const {return int_value(44);}
173  int event() const {return int_value(48);}
179  void event(int value) {int_value(48,value);}
180 
181 };
182 
183 }
184 }
185 
186 #endif // TBX_RES_RESRADIOBUTTON_H
187 
tbx::res::ResRadioButton::generate_state_changed
void generate_state_changed(bool value)
Set if state changed event will be generated.
Definition: resradiobutton.h:110
tbx::res::ResBase::message_with_length
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
tbx::res::ResBase::operator=
ResBase & operator=(const ResBase &other)
Assignment.
Definition: resbase.cc:1534
tbx::res::ResRadioButton::ResRadioButton
ResRadioButton(const ResGadget &other)
Construct an radio button gadget resource.
Definition: resradiobutton.h:48
tbx
A library for creating RISC OS toolbox applications.
Definition: abouttobeshownlistener.cc:35
tbx::res::ResRadioButton::operator=
ResRadioButton & operator=(const ResGadget &other)
Assign from a ResGadget.
Definition: resradiobutton.h:70
tbx::res::ResRadioButton::on
void on(bool value)
Set if the initial state of the radion button is on.
Definition: resradiobutton.h:122
tbx::res::ResGadget
Base class for gadget memory resources.
Definition: resgadget.h:43
tbx::res::ResBase::int_value
int int_value(int offset) const
Get an integer value.
Definition: resbase.h:316
tbx::res::ResRadioButton::ResRadioButton
ResRadioButton(const ResRadioButton &other)
Construct an radio button gadget resource.
Definition: resradiobutton.h:58
tbx::res::ResRadioButton::label
void label(const char *value, int max_length=-1)
Set the label for the radio button.
Definition: resradiobutton.h:155
tbx::res::ResRadioButton::operator=
ResRadioButton & operator=(const ResRadioButton &other)
Assign from another radio button gadget resource.
Definition: resradiobutton.h:82
tbx::res::ResRadioButton::label
void label(const std::string &value, int max_length=-1)
Set the label for the radio button.
Definition: resradiobutton.h:163
tbx::res::ResRadioButton::generate_state_changed
bool generate_state_changed() const
Check if state changed event will be generated.
Definition: resradiobutton.h:104
tbx::res::ResRadioButton::ResRadioButton
ResRadioButton()
Construct a radio button gadget resource.
Definition: resradiobutton.h:93
tbx::res::ResRadioButton::on
bool on() const
Check if the initial state of the radion button is on.
Definition: resradiobutton.h:116
tbx::res::ResRadioButton::group_number
int group_number() const
Get the group number for this radio buttons.
Definition: resradiobutton.h:132
tbx::res::ResBase::init_message
void init_message(int offset, const char *value)
Initialise a message in a constructor helper.
Definition: resbase.cc:1736
tbx::res::ResRadioButton::event
void event(int value)
Set the event ID raised when the radio button is selected.
Definition: resradiobutton.h:179
tbx::res::ResBase::flag
bool flag(int offset, int mask) const
Check if any of the bits in a mask are set.
Definition: resbase.h:352
tbx::res::ResRadioButton::group_number
void group_number(int value)
Set the group number for this radio buttons.
Definition: resradiobutton.h:141
tbx::res::ResRadioButton::max_label_len
int max_label_len() const
Get the maximum length allowed for the label.
Definition: resradiobutton.h:167
tbx::res::ResRadioButton::event
int event() const
Get the event ID raised when the radio button is selected.
Definition: resradiobutton.h:173
tbx::res::ResRadioButton::label
const char * label() const
Get the label for the radio button.
Definition: resradiobutton.h:147
tbx::res::ResGadget::check_type
void check_type(int type) const
Check if this gadgets type is as specified.
Definition: reswindow.cc:97
tbx::res::ResRadioButton
Class for RadioButton gadget template.
Definition: resradiobutton.h:37
tbx::res::ResBase::message
const char * message(int offset) const
Get the message string at the given offset.
Definition: resbase.cc:1602