tbx  0.7.5
resslider.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_RESSLIDER_H
26 #define TBX_RES_RESSLIDER_H
27 
28 #include "resgadget.h"
29 #include "../colour.h"
30 
31 namespace tbx {
32 namespace res {
33 
37 class ResSlider : public ResGadget
38 {
39 
40 public:
41  enum {TYPE_ID = 576 };
42 
49  ResSlider(const ResGadget &other) : ResGadget(other)
50  {
51  check_type(TYPE_ID);
52  }
53 
59  ResSlider(const ResSlider &other) : ResGadget(other)
60  {
61  }
62 
63  virtual ~ResSlider() {}
64 
71  ResSlider &operator=(const ResGadget &other)
72  {
73  other.check_type(TYPE_ID);
74  ResBase::operator=(other);
75  return *this;
76  }
77 
83  ResSlider &operator=(const ResSlider &other)
84  {
85  ResBase::operator=(other);
86  return *this;
87  }
88 
95  : ResGadget(576,52)
96  {
97  int_value(0, 0x4010); // bar colour 4, is dragggable
98  upper_bound(100);
99  step_size(1);
100  }
101 
107  bool generate_value_changed() const {return flag(0, 1<<0);}
113  void generate_value_changed(bool value) {flag(0,1<<0,value);}
120  bool generate_value_changed_while_dragging() const {return flag(0, 1<<1);}
127  void generate_value_changed_while_dragging(bool value) {flag(0,1<<1,value);}
133  bool vertical() const {return flag(0, 1<<3);}
139  void vertical(bool value) {flag(0,1<<3,value);}
145  bool bar_is_draggable() const {return flag(0, 1<<4);}
151  void bar_is_draggable(bool value) {flag(0,1<<4,value);}
157  WimpColour bar_colour() const {return WimpColour(flag_value(0, 61440)>>12);}
163  void bar_colour(WimpColour value) {flag_value(0,61440,((int)value)<<12);}
169  WimpColour background_colour() const {return WimpColour(flag_value(0, 983040)>>16);}
175  void background_colour(WimpColour value) {flag_value(0,983040,((int)value)<<16);}
176 
182  int lower_bound() const {return int_value(36);}
188  void lower_bound(int value) {int_value(36,value);}
194  int upper_bound() const {return int_value(40);}
200  void upper_bound(int value) {int_value(40,value);}
206  int step_size() const {return int_value(44);}
212  void step_size(int value) {int_value(44,value);}
218  int initial_value() const {return int_value(48);}
224  void initial_value(int value) {int_value(48,value);}
225 
226 };
227 
228 }
229 }
230 
231 #endif // TBX_RES_RESSLIDER_H
232 
A library for creating RISC OS toolbox applications.
Definition: abouttobeshownlistener.cc:34
void initial_value(int value)
Set the initial value for the slider.
Definition: resslider.h:224
int lower_bound() const
Get the minimum value for the slider.
Definition: resslider.h:182
Base class for gadget memory resources.
Definition: resgadget.h:42
bool bar_is_draggable() const
Check if the bar can be dragged.
Definition: resslider.h:145
bool flag(int offset, int mask) const
Check if any of the bits in a mask are set.
Definition: resbase.h:352
void generate_value_changed_while_dragging(bool value)
Set if the value changed event will be generated when the slider is dragged.
Definition: resslider.h:127
int flag_value(int offset, int mask) const
Get the bits for the given mask.
Definition: resbase.h:362
void bar_colour(WimpColour value)
Set the bar colour.
Definition: resslider.h:163
int step_size() const
Get the step size for the slider.
Definition: resslider.h:206
Classes to use/edit toolbox resources in memory.
Class to represent a standard desktop WIMP colour.
Definition: colour.h:146
void step_size(int value)
Set the step size for the slider.
Definition: resslider.h:212
ResSlider & operator=(const ResGadget &other)
Assign from a ResGadget.
Definition: resslider.h:71
Class for Slider gadget template.
Definition: resslider.h:37
int int_value(int offset) const
Get an integer value.
Definition: resbase.h:316
void bar_is_draggable(bool value)
Set if the bar can be dragged.
Definition: resslider.h:151
ResSlider & operator=(const ResSlider &other)
Assign from another slider gadget resource.
Definition: resslider.h:83
bool generate_value_changed() const
Check if value changed event will be generated.
Definition: resslider.h:107
void generate_value_changed(bool value)
Set if value changed event will be generated.
Definition: resslider.h:113
ResSlider()
Construct a slider gadget resource.
Definition: resslider.h:94
void lower_bound(int value)
Set the minimum value for the slider.
Definition: resslider.h:188
ResSlider(const ResGadget &other)
Construct an slider gadget resource.
Definition: resslider.h:49
ResSlider(const ResSlider &other)
Construct an slider gadget resource.
Definition: resslider.h:59
int initial_value() const
Get the initial value for the slider.
Definition: resslider.h:218
ResBase & operator=(const ResBase &other)
Assignment.
Definition: resbase.cc:1534
WimpColour bar_colour() const
Get the bar colour.
Definition: resslider.h:157
bool vertical() const
Check if the slider is vertical instead of horizontal.
Definition: resslider.h:133
bool generate_value_changed_while_dragging() const
Check if the value changed event will be generated when the slider is dragged.
Definition: resslider.h:120
void upper_bound(int value)
Set the maximum value for the slider.
Definition: resslider.h:200
void background_colour(WimpColour value)
Set the background colour.
Definition: resslider.h:175
int upper_bound() const
Get the maximum value for the slider.
Definition: resslider.h:194
void check_type(int type) const
Check if this gadgets type is as specified.
Definition: reswindow.cc:97
WimpColour background_colour() const
Get the background colour.
Definition: resslider.h:169
void vertical(bool value)
Set if the slider is vertical instead of horizontal.
Definition: resslider.h:139