tbx  0.7.5
scale.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 /*
26  * scale.h
27  *
28  * Created on: 01-Jul-2010
29  * Author: alanb
30  */
31 
32 #ifndef TBX_SCALE_H_
33 #define TBX_SCALE_H_
34 
35 #include "showfullobject.h"
36 #include "listener.h"
37 #include "eventinfo.h"
38 #include "window.h"
39 
40 namespace tbx {
41 
42 // Listeners
43 class AboutToBeShownListener;
44 class HasBeenHiddenListener;
45 class ScaleApplyFactorListener;
46 
47 namespace res
48 {
49  class ResScale;
50 }
51 
58 class Scale : public tbx::ShowFullObject
59 {
60 public:
61  enum { TOOLBOX_CLASS = 0x82c00 };
62 
69  Scale() {};
78  Scale(const Scale &other) : ShowFullObject(other._handle) {}
89  Scale(const Object &other) : ShowFullObject(other) {check_toolbox_class(Scale::TOOLBOX_CLASS);}
97  Scale(const std::string &template_name) : ShowFullObject(template_name) {check_toolbox_class(Scale::TOOLBOX_CLASS);}
104  Scale(const res::ResScale &object_template);
105 
114  Scale &operator=(const Scale &other) {_handle = other.handle(); return *this;}
126  Scale &operator=(const Object &other) {_handle = other.handle(); check_toolbox_class(TOOLBOX_CLASS); return *this;}
134  bool operator==(const Object &other) const {return (_handle == other.handle());}
142  bool operator!=(const Object &other) const {return (_handle != other.handle());}
143 
144  // Properties
148  Window window() const {return Window((ObjectId)int_property(0));}
149 
155  void value(int pc) {int_property(1, pc);}
156 
160  int value() const {return int_property(2);}
161 
162  // Bounds and step
163  void lower_bound(int value);
164  int lower_bound() const;
165  void upper_bound(int value);
166  int upper_bound() const;
167  void step_size(int value);
168  int step_size() const;
169 
173  void title(std::string msg) {string_property(5, msg);}
174 
178  std::string title() const {return string_property(6);}
179 
183  int title_length() const {return string_property_length(6);}
184 
185  // Listeners
186  void add_about_to_be_shown_listener(AboutToBeShownListener *listener);
187  void remove_about_to_be_shown_listener(AboutToBeShownListener *listener);
188  void add_has_been_hidden_listener(HasBeenHiddenListener *listener);
189  void remove_has_been_hidden_listener(HasBeenHiddenListener *listener);
190  void add_apply_factor_listener(ScaleApplyFactorListener *listener);
191  void remove_apply_factor_listener(ScaleApplyFactorListener *listener);
192 };
193 
198 {
199 public:
207  EventInfo(id_block, data) {}
208 
212  int factor() const {return _data.word[4];}
213 };
214 
219 {
220 public:
222 
228  virtual void scale_apply_factor(const ScaleApplyFactorEvent &apply_event) = 0;
229 };
230 
231 }
232 
233 #endif /* TBX_SCALE_H_ */
A library for creating RISC OS toolbox applications.
Definition: abouttobeshownlistener.cc:34
void value(int pc)
Set the scale percentage.
Definition: scale.h:155
Listener for about to be shown event.
Definition: abouttobeshownlistener.h:76
Structure holding the raw data from a call to Wimp_Poll.
Definition: pollinfo.h:71
std::string title() const
Return the title of the scale dialogue.
Definition: scale.h:178
Classes to use/edit toolbox resources in memory.
Class to provide apply factor event information for Scale object.
Definition: scale.h:197
int title_length() const
Return the title length.
Definition: scale.h:183
bool operator!=(const Object &other) const
Check if this Scale does not refers to the same underlying toolbox object as another.
Definition: scale.h:142
unsigned int ObjectId
Type for underlying toolbox object id.
Definition: handles.h:31
Scale()
Uninitialised constructor.
Definition: scale.h:69
ScaleApplyFactorEvent(IdBlock &id_block, PollBlock &data)
Construct the event from Toolbox and WIMP event data.
Definition: scale.h:206
Scale & operator=(const Scale &other)
Assign this Scale from another.
Definition: scale.h:114
Listener for scale factor events.
Definition: scale.h:218
Window window() const
Return the underlying toolbox window used to implement the Scale object.
Definition: scale.h:148
Scale(const Object &other)
Construct a Scale from an Object that refers to a Scale.
Definition: scale.h:89
The Window object represents a toolbox window.
Definition: window.h:69
void title(std::string msg)
Set the title for the scale dialogue.
Definition: scale.h:173
Class to provide information on a toolbox event.
Definition: eventinfo.h:48
Base class for all toolbox event listeners.
Definition: listener.h:33
Class to show a toolbox Scale object.
Definition: scale.h:58
int value() const
Get the scale percentage.
Definition: scale.h:160
Listener for an object has been hidden event.
Definition: hasbeenhiddenlistener.h:36
Scale(const Scale &other)
Construct from another Scale object.
Definition: scale.h:78
int factor() const
Return the choses scale factor.
Definition: scale.h:212
Objects derived from this class can be shown with there full location and size specified as well as t...
Definition: showfullobject.h:40
Information passed back by the Toolbox with each toolbox event providing information on where the eve...
Definition: pollinfo.h:41
Class to manipulate a toolbox object.
Definition: object.h:50
Scale & operator=(const Object &other)
Assign this Scale from an Object that refers to a Scale.
Definition: scale.h:126
bool operator==(const Object &other) const
Check if this Scale refers to the same underlying toolbox object as another.
Definition: scale.h:134
Class for Scale object template.
Definition: resscale.h:36
Scale(const std::string &template_name)
Create a Scale from the named template.
Definition: scale.h:97
ObjectId handle() const
Return the underlying toolbox object id this object references.
Definition: object.h:93