tbx  0.7.3
adjuster.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  * adjuster.h
27  *
28  * Created on: 6-Jul-2010
29  * Author: alanb
30  */
31 
32 #ifndef TBX_ADJUSTER_H_
33 #define TBX_ADJUSTER_H_
34 
35 #include "gadget.h"
36 #include "listener.h"
37 #include "eventinfo.h"
38 
39 namespace tbx
40 {
41 
42 class AdjusterClickedListener;
43 
48 class Adjuster: public tbx::Gadget
49 {
50 public:
51  enum {TOOLBOX_CLASS = 768};
52 
53  Adjuster() {}
54 
59  ~Adjuster() {}
60 
66  Adjuster(const Adjuster &other) : Gadget(other) {}
67 
77  Adjuster(const Gadget &other) : Gadget(other) {check_toolbox_class(Adjuster::TOOLBOX_CLASS);}
78 
85  Adjuster(const Component &other) : Gadget(other) {Window check(other.handle()); check_toolbox_class(Adjuster::TOOLBOX_CLASS);}
86 
91  Adjuster &operator=(const Adjuster &other) {_handle = other._handle; _id = other._id; return *this;}
92 
99  Adjuster &operator=(const Gadget &other) {_handle = other.handle(); _id = other.id(); check_toolbox_class(TOOLBOX_CLASS); return *this;}
100 
108  Adjuster &operator=(const Component &other) {Window check(other.handle()); _handle = other.handle(); _id = other.id(); check_toolbox_class(TOOLBOX_CLASS); return *this;}
109 
115  bool operator==(const Gadget &other) const {return (_handle == other.handle() && _id == other.id());}
116 
122  bool operator!=(const Gadget &other) const {return (_handle != other.handle() || _id != other.id());}
123 
126 };
127 
132 {
133 public:
138  EventInfo(id_block, data) {}
139 
144  bool up() const {return (_data.word[4] != 0);}
149  bool down() const {return (_data.word[4] == 0);}
150 };
151 
156 {
157 public:
158  virtual ~AdjusterClickedListener() {}
162  virtual void adjuster_clicked(const AdjusterClickedEvent &clicked_event) = 0;
163 };
164 
165 }
166 
167 #endif /* TBX_ADJUSTER_H_ */
bool operator!=(const Gadget &other) const
Check if this adjuster refers to the same underlying toolbox gadget as another gadget.
Definition: adjuster.h:122
An Adjuster is a gadget that shows two arrows facing in opposite directions either vertically or hori...
Definition: adjuster.h:48
This is the base class for all Gadgets.
Definition: gadget.h:48
Listener for Adjuster Clicked events.
Definition: adjuster.h:155
PollBlock & _data
raw data from the event
Definition: eventinfo.h:53
bool up() const
true if up/right arrow was clicked.
Definition: adjuster.h:144
Structure holding the raw data from a call to Wimp_Poll.
Definition: pollinfo.h:71
void check_toolbox_class(int class_id) const
Check the underlying gadget class for this object has the given class id.
Definition: gadget.cc:47
Adjuster(const Adjuster &other)
Construct a adjuster from another adjuster.
Definition: adjuster.h:66
~Adjuster()
Destroy a adjuster gadget.
Definition: adjuster.h:59
bool operator==(const Gadget &other) const
Check if this adjuster refers to the same underlying toolbox gadget as another gadget.
Definition: adjuster.h:115
ComponentId id() const
Get the component ID of this component.
Definition: component.h:103
Adjuster(const Gadget &other)
Construct a adjuster from another gadget.
Definition: adjuster.h:77
AdjusterClickedEvent(IdBlock &id_block, PollBlock &data)
Construct from toolbox event information.
Definition: adjuster.h:137
Adjuster()
Construct an uninitialised adjuster.
Definition: adjuster.h:53
Base class for components in an object.
Definition: component.h:42
virtual void adjuster_clicked(const AdjusterClickedEvent &clicked_event)=0
Called when an adjuster arrow was clicked.
void add_clicked_listener(AdjusterClickedListener *listener)
Add listener for.
Definition: adjuster.cc:46
Adjuster & operator=(const Adjuster &other)
Assign a adjuster to refer to the same underlying toolbox gadget as another.
Definition: adjuster.h:91
Event information for Adjuster Clicked event.
Definition: adjuster.h:131
void remove_clicked_listener(AdjusterClickedListener *listener)
Remove listener for.
Definition: adjuster.cc:54
The Window object represents a toolbox window.
Definition: window.h:69
Class to provide information on a toolbox event.
Definition: eventinfo.h:48
Adjuster & operator=(const Gadget &other)
Assign a adjuster to refer to the same underlying toolbox gadget as an existing Gadget.
Definition: adjuster.h:99
Base class for all toolbox event listeners.
Definition: listener.h:33
int word[64]
Array containing information return from Wimp_Poll.
Definition: pollinfo.h:76
Adjuster(const Component &other)
Construct a adjuster from a component.
Definition: adjuster.h:85
ObjectId _handle
Underlying toolbox handle.
Definition: component.h:45
bool down() const
false if up/right arrow was clicked.
Definition: adjuster.h:149
const IdBlock & id_block() const
IdBlock for the current event.
Definition: eventinfo.h:71
Information passed back by the Toolbox with each toolbox event providing information on where the eve...
Definition: pollinfo.h:41
int _id
Underlying toolbox component id.
Definition: component.h:46
ObjectId handle() const
Return the object handle for his component.
Definition: component.h:95
Adjuster & operator=(const Component &other)
Assign a adjuster to refer to the same underlying toolbox component as an existing Gadget...
Definition: adjuster.h:108