tbx  0.7.6
resstringset.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_RESSTRINGSET_H
26 #define TBX_RES_RESSTRINGSET_H
27 
28 #include "resgadget.h"
29 #include "resjustification.h"
30 #include "../handles.h"
31 
32 namespace tbx {
33 namespace res {
34 
38 class ResStringSet : public ResGadget
39 {
40 
41 public:
42  enum {TYPE_ID = 896 };
43 
50  ResStringSet(const ResGadget &other) : ResGadget(other)
51  {
52  check_type(TYPE_ID);
53  }
54 
60  ResStringSet(const ResStringSet &other) : ResGadget(other)
61  {
62  }
63 
64  virtual ~ResStringSet() {}
65 
73  {
74  other.check_type(TYPE_ID);
75  ResBase::operator=(other);
76  return *this;
77  }
78 
85  {
86  ResBase::operator=(other);
87  return *this;
88  }
89 
96  : ResGadget(896,68)
97  {
98  init_message(36,0); // string_set
99  init_message(40,0); // Title
100  init_message(44,0); // initial_selected_string
101  init_message(52,0); // allowable
102  before(-1);
103  after(-1);
104  }
105 
111  bool generate_value_changed() const {return flag(0, 1<<0);}
117  void generate_value_changed(bool value) {flag(0,1<<0,value);}
123  bool writable() const {return flag(0, 1<<1);}
129  void writable(bool value) {flag(0,1<<1,value);}
135  bool generate_event_before_showing_menu() const {return flag(0, 1<<3);}
141  void generate_event_before_showing_menu(bool value) {flag(0,1<<3,value);}
147  bool no_value_field() const {return flag(0, 1<<4);}
153  void no_value_field(bool value) {flag(0,1<<4,value);}
165  void justification(ResJustification value) {flag_value(0,96,(int)value<<5);}
166 
175  const char *string_set() const {return message(36);}
184  void string_set(const char *value) {message(36, value);}
193  void string_set(const std::string &value) {message(36, value);}
194 
200  const char *title() const {return message(40);}
206  void title(const char *value) {message(40, value);}
212  void title(const std::string &value) {message(40, value);}
218  const char *selected_string() const {return message(44);}
226  void selected_string(const char *value, int max_length = -1) {message_with_length(44, value, max_length);}
234  void selected_string(const std::string &value, int max_length = -1) {message_with_length(44, value, max_length);}
239  int max_selected_string() const {return int_value(48);}
248  const char *allowable() const {return message(52);}
260  void allowable(const char *value, int max_length = -1) {message_with_length(52, value, max_length);}
271  void allowable(const std::string &value, int max_length = -1) {message_with_length(52, value, max_length);}
276  int max_allowable() const {return int_value(56);}
282  ComponentId before() const {return ComponentId(int_value(60));}
288  void before(ComponentId value) {int_value(60,(int)value);}
294  ComponentId after() const {return ComponentId(int_value(64));}
300  void after(ComponentId value) {int_value(64,(int)value);}
301 
302 };
303 
304 }
305 }
306 
307 #endif // TBX_RES_RESSTRINGSET_H
308 
tbx::res::ResStringSet::no_value_field
bool no_value_field() const
Check if string set has no display or writable field.
Definition: resstringset.h:147
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::ResStringSet
Class for StringSet gadget template.
Definition: resstringset.h:39
tbx
A library for creating RISC OS toolbox applications.
Definition: abouttobeshownlistener.cc:35
tbx::ComponentId
int ComponentId
Type for underlying toolbox component id.
Definition: handles.h:33
tbx::res::ResStringSet::max_selected_string
int max_selected_string() const
Get the maximum length the selected string can be increased to when using the string set.
Definition: resstringset.h:239
tbx::res::ResStringSet::before
void before(ComponentId value)
Set the component ID of the gadget before this one in the Tab order.
Definition: resstringset.h:288
tbx::res::ResStringSet::operator=
ResStringSet & operator=(const ResGadget &other)
Assign from a ResGadget.
Definition: resstringset.h:72
tbx::res::ResStringSet::ResStringSet
ResStringSet(const ResGadget &other)
Construct an string set gadget resource.
Definition: resstringset.h:50
tbx::res::ResStringSet::writable
void writable(bool value)
Set if user can enter values in the string set.
Definition: resstringset.h:129
tbx::res::ResStringSet::after
ComponentId after() const
Get the component ID of the gadget after this one in the Tab order.
Definition: resstringset.h:294
tbx::res::ResGadget
Base class for gadget memory resources.
Definition: resgadget.h:43
tbx::res::ResStringSet::title
const char * title() const
Get the title for the menu.
Definition: resstringset.h:200
tbx::res::ResBase::int_value
int int_value(int offset) const
Get an integer value.
Definition: resbase.h:316
tbx::res::ResStringSet::max_allowable
int max_allowable() const
Get the maximum length the allowable character can be changed to when the gadget is shown.
Definition: resstringset.h:276
tbx::res::ResStringSet::generate_event_before_showing_menu
bool generate_event_before_showing_menu() const
Check if an event will be generated before the menu is shown.
Definition: resstringset.h:135
tbx::res::ResStringSet::justification
void justification(ResJustification value)
Set justification of the value.
Definition: resstringset.h:165
tbx::res::ResStringSet::operator=
ResStringSet & operator=(const ResStringSet &other)
Assign from another string set gadget resource.
Definition: resstringset.h:84
tbx::res::ResStringSet::generate_value_changed
bool generate_value_changed() const
Check if the value changed event will be generated.
Definition: resstringset.h:111
tbx::res::ResStringSet::after
void after(ComponentId value)
Set the component ID of the gadget after this one in the Tab order.
Definition: resstringset.h:300
tbx::res::ResStringSet::before
ComponentId before() const
Get the component ID of the gadget before this one in the Tab order.
Definition: resstringset.h:282
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::ResBase::flag_value
int flag_value(int offset, int mask) const
Get the bits for the given mask.
Definition: resbase.h:362
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::ResStringSet::ResStringSet
ResStringSet(const ResStringSet &other)
Construct an string set gadget resource.
Definition: resstringset.h:60
tbx::res::ResStringSet::generate_value_changed
void generate_value_changed(bool value)
Set if the value changed event will be generated.
Definition: resstringset.h:117
tbx::res::ResStringSet::selected_string
void selected_string(const std::string &value, int max_length=-1)
Set the initially selected string.
Definition: resstringset.h:234
tbx::res::ResStringSet::title
void title(const char *value)
Set the title for the menu.
Definition: resstringset.h:206
tbx::res::ResStringSet::string_set
void string_set(const char *value)
Set the set of values shown in the string set menu.
Definition: resstringset.h:184
tbx::res::ResJustification
ResJustification
Standard justification of resource gadget flags.
Definition: resjustification.h:11
tbx::res::ResStringSet::allowable
const char * allowable() const
Get the allowable characters in a writable string set.
Definition: resstringset.h:248
tbx::res::ResStringSet::string_set
const char * string_set() const
Get the set of values shown in the string set menu.
Definition: resstringset.h:175
tbx::res::ResStringSet::writable
bool writable() const
Check if user can enter values in the string set.
Definition: resstringset.h:123
tbx::res::ResStringSet::selected_string
void selected_string(const char *value, int max_length=-1)
Set the initially selected string.
Definition: resstringset.h:226
tbx::res::ResStringSet::allowable
void allowable(const std::string &value, int max_length=-1)
Set the allowable characters in a writable string set.
Definition: resstringset.h:271
tbx::res::ResStringSet::allowable
void allowable(const char *value, int max_length=-1)
Set the allowable characters in a writable string set.
Definition: resstringset.h:260
tbx::res::ResStringSet::selected_string
const char * selected_string() const
Get the initially selected string.
Definition: resstringset.h:218
tbx::res::ResStringSet::ResStringSet
ResStringSet()
Construct a string set gadget resource.
Definition: resstringset.h:95
tbx::res::ResStringSet::string_set
void string_set(const std::string &value)
Set the set of values shown in the string set menu.
Definition: resstringset.h:193
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::ResStringSet::no_value_field
void no_value_field(bool value)
Set if string set has no display or writable field.
Definition: resstringset.h:153
tbx::res::ResStringSet::title
void title(const std::string &value)
Set the title for the menu.
Definition: resstringset.h:212
tbx::res::ResBase::message
const char * message(int offset) const
Get the message string at the given offset.
Definition: resbase.cc:1602
tbx::res::ResStringSet::generate_event_before_showing_menu
void generate_event_before_showing_menu(bool value)
Set if an event will be generated before the menu is shown.
Definition: resstringset.h:141
tbx::res::ResStringSet::justification
ResJustification justification() const
Get justification of the value.
Definition: resstringset.h:159