tbx  0.7.5
resnumberrange.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_RESNUMBERRANGE_H
26 #define TBX_RES_RESNUMBERRANGE_H
27 
28 #include "resgadget.h"
29 #include "resjustification.h"
30 #include "../colour.h"
31 #include "../handles.h"
32 
33 namespace tbx {
34 namespace res {
35 
39 class ResNumberRange : public ResGadget
40 {
41 
42 public:
43  enum {TYPE_ID = 832 };
44 
51  ResNumberRange(const ResGadget &other) : ResGadget(other)
52  {
53  check_type(TYPE_ID);
54  }
55 
61  ResNumberRange(const ResNumberRange &other) : ResGadget(other)
62  {
63  }
64 
65  virtual ~ResNumberRange() {}
66 
74  {
75  other.check_type(TYPE_ID);
76  ResBase::operator=(other);
77  return *this;
78  }
79 
86  {
87  ResBase::operator=(other);
88  return *this;
89  }
90 
97  : ResGadget(832,68)
98  {
99  slider_colour(4);
100  step_size(1);
101  before(-1);
102  after(-1);
103  }
104 
110  bool generate_value_changed() const {return flag(0, 1<<0);}
116  void generate_value_changed(bool value) {flag(0,1<<0,value);}
122  bool writable() const {return flag(0, 1<<2);}
128  void writable(bool value) {flag(0,1<<2,value);}
134  bool no_display_area() const {return flag(0, 1<<3);}
140  void no_display_area(bool value) {flag(0,1<<3,value);}
146  bool has_adjuster_arrows() const {return flag(0, 1<<4);}
152  void has_adjuster_arrows(bool value) {flag(0,1<<4,value);}
157  {
161  };
167  SliderType slider_type() const {return SliderType(flag_value(0, 224)>>5);}
173  void slider_type(SliderType value) {flag_value(0,224,((int)value)<<5);}
174 
180  ResJustification justification() const {return ResJustification(flag_value(0, 768)>>8);}
186  void justification(ResJustification value) {flag_value(0,768,(int)value<<8);}
192  WimpColour slider_colour() const {return WimpColour(flag_value(0, 61440)>>12);}
198  void slider_colour(WimpColour value) {flag_value(0,61440,((int)value)<<12);}
204  WimpColour slider_background_colour() const {return WimpColour(flag_value(0, 983040)>>16);}
210  void slider_background_colour(WimpColour value) {flag_value(0,983040,((int)value)<<16);}
211 
217  int lower_bound() const {return int_value(36);}
223  void lower_bound(int value) {int_value(36,value);}
229  int upper_bound() const {return int_value(40);}
235  void upper_bound(int value) {int_value(40,value);}
241  int step_size() const {return int_value(44);}
247  void step_size(int value) {int_value(44,value);}
253  int initial_value() const {return int_value(48);}
259  void initial_value(int value) {int_value(48,value);}
272  int precision() const {return int_value(52);}
285  void precision(int value) {int_value(52,value);}
291  ComponentId before() const {return ComponentId(int_value(56));}
297  void before(ComponentId value) {int_value(56,value);}
303  ComponentId after() const {return ComponentId(int_value(60));}
309  void after(ComponentId value) {int_value(60,value);}
315  int display_length() const {return int_value(64);}
321  void display_length(int value) {int_value(64,value);}
322 
323 };
324 
325 }
326 }
327 
328 #endif // TBX_RES_RESNUMBERRANGE_H
329 
void lower_bound(int value)
Set the minimum value for the number range.
Definition: resnumberrange.h:223
A library for creating RISC OS toolbox applications.
Definition: abouttobeshownlistener.cc:34
ComponentId before() const
Get the component ID of the gadget before this one in the Tab order.
Definition: resnumberrange.h:291
slider to the right of the display area
Definition: resnumberrange.h:159
int step_size() const
Get the step size value for the number range.
Definition: resnumberrange.h:241
Base class for gadget memory resources.
Definition: resgadget.h:42
void slider_colour(WimpColour value)
Set slider foreground colour.
Definition: resnumberrange.h:198
ComponentId after() const
Get the component ID of the gadget after this one in the Tab order.
Definition: resnumberrange.h:303
int precision() const
Get the precision of the number range.
Definition: resnumberrange.h:272
int upper_bound() const
Get the maximum value for the number range.
Definition: resnumberrange.h:229
bool flag(int offset, int mask) const
Check if any of the bits in a mask are set.
Definition: resbase.h:352
void precision(int value)
Set the precision of the number range.
Definition: resnumberrange.h:285
int flag_value(int offset, int mask) const
Get the bits for the given mask.
Definition: resbase.h:362
int ComponentId
Type for underlying toolbox component id.
Definition: handles.h:33
bool no_display_area() const
Check if display area is omitted from the number range.
Definition: resnumberrange.h:134
void has_adjuster_arrows(bool value)
Set if the number range shows adjuster arrows.
Definition: resnumberrange.h:152
int initial_value() const
Get the initial value for the number range.
Definition: resnumberrange.h:253
int lower_bound() const
Get the minimum value for the number range.
Definition: resnumberrange.h:217
Classes to use/edit toolbox resources in memory.
no slider
Definition: resnumberrange.h:158
SliderType
Enumaration for how slider is shown.
Definition: resnumberrange.h:156
ResJustification justification() const
Get the horizontal position of the number range in its bounding box.
Definition: resnumberrange.h:180
Class to represent a standard desktop WIMP colour.
Definition: colour.h:146
void writable(bool value)
Set if number range is writable.
Definition: resnumberrange.h:128
WimpColour slider_colour() const
Get slider foreground colour.
Definition: resnumberrange.h:192
int int_value(int offset) const
Get an integer value.
Definition: resbase.h:316
void generate_value_changed(bool value)
Set if the value changed event will be generated.
Definition: resnumberrange.h:116
void step_size(int value)
Set the step size value for the number range.
Definition: resnumberrange.h:247
bool generate_value_changed() const
Check if the value changed event will be generated.
Definition: resnumberrange.h:110
bool has_adjuster_arrows() const
Check if the number range shows adjuster arrows.
Definition: resnumberrange.h:146
ResNumberRange()
Construct a number range gadget resource.
Definition: resnumberrange.h:96
void slider_type(SliderType value)
Set how the slider is displayed.
Definition: resnumberrange.h:173
void slider_background_colour(WimpColour value)
Set slider background colour.
Definition: resnumberrange.h:210
void display_length(int value)
Set the length of the display field.
Definition: resnumberrange.h:321
ResNumberRange(const ResGadget &other)
Construct an number range gadget resource.
Definition: resnumberrange.h:51
void initial_value(int value)
Set the initial value for the number range.
Definition: resnumberrange.h:259
int display_length() const
Get the length of the display field.
Definition: resnumberrange.h:315
void before(ComponentId value)
Set the component ID of the gadget before this one in the Tab order.
Definition: resnumberrange.h:297
SliderType slider_type() const
Get how the slider is displayed.
Definition: resnumberrange.h:167
bool writable() const
Check if number range is writable.
Definition: resnumberrange.h:122
ResNumberRange(const ResNumberRange &other)
Construct an number range gadget resource.
Definition: resnumberrange.h:61
void no_display_area(bool value)
Set if display area is omitted from the number range.
Definition: resnumberrange.h:140
ResNumberRange & operator=(const ResNumberRange &other)
Assign from another number range gadget resource.
Definition: resnumberrange.h:85
WimpColour slider_background_colour() const
Get slider background colour.
Definition: resnumberrange.h:204
ResBase & operator=(const ResBase &other)
Assignment.
Definition: resbase.cc:1534
Class for NumberRange gadget template.
Definition: resnumberrange.h:39
void justification(ResJustification value)
Set the horizontal position of the number range in its bounding box.
Definition: resnumberrange.h:186
ResNumberRange & operator=(const ResGadget &other)
Assign from a ResGadget.
Definition: resnumberrange.h:73
void upper_bound(int value)
Set the maximum value for the number range.
Definition: resnumberrange.h:235
void check_type(int type) const
Check if this gadgets type is as specified.
Definition: reswindow.cc:97
void after(ComponentId value)
Set the component ID of the gadget after this one in the Tab order.
Definition: resnumberrange.h:309
slider to the left of the display area
Definition: resnumberrange.h:160