tbx  0.7.5
fontdbox.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  * fontdbox.h
27  *
28  * Created on: 01-Jul-2010
29  * Author: alanb
30  */
31 
32 #ifndef TBX_FONTDBOX_H_
33 #define TBX_FONTDBOX_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 FontDboxApplyListener;
46 
47 namespace res
48 {
49  class ResFontDbox;
50 }
51 
58 {
59 public:
60  enum { TOOLBOX_CLASS = 0x82a00 };
61 
67  FontDbox() {};
76  FontDbox(const FontDbox &other) : ShowFullObject(other._handle) {}
87  FontDbox(const Object &other) : ShowFullObject(other) {check_toolbox_class(FontDbox::TOOLBOX_CLASS);}
95  FontDbox(const std::string &template_name) : ShowFullObject(template_name) {check_toolbox_class(FontDbox::TOOLBOX_CLASS);}
102  FontDbox(const res::ResFontDbox &object_template);
103 
112  FontDbox &operator=(const FontDbox &other) {_handle = other.handle(); return *this;}
124  FontDbox &operator=(const Object &other) {_handle = other.handle(); check_toolbox_class(TOOLBOX_CLASS); return *this;}
132  bool operator==(const Object &other) const {return (_handle == other.handle());}
140  bool operator!=(const Object &other) const {return (_handle != other.handle());}
141 
142 
143  // Properties
147  Window window() const {return Window((ObjectId)int_property(0));}
148 
154  void font(std::string value) {string_property(1, value);}
155 
159  void no_font() {int_property(1, 0);}
160 
164  std::string font() const {return string_property(2);}
165 
169  int font_length() const {return string_property_length(2);}
170 
174  void height(int size);
175 
179  int height() const;
180 
184  void aspect_ratio(int value);
185 
189  int aspect_ratio() const;
190 
194  void try_string(std::string value) {string_property(5, value);}
195 
199  std::string try_string() const {return string_property(6);}
200 
204  int try_string_length() const {return string_property_length(6);}
205 
209  void title(std::string value) {string_property(7, value);}
210 
214  std::string title() const {return string_property(8);}
215 
219  int title_length() const {return string_property_length(8);}
220 
221 
222  // Listeners
223  void add_about_to_be_shown_listener(AboutToBeShownListener *listener);
224  void remove_about_to_be_shown_listener(AboutToBeShownListener *listener);
225  void add_has_been_hidden_listener(HasBeenHiddenListener *listener);
226  void remove_has_been_hidden_listener(HasBeenHiddenListener *listener);
227  void add_apply_listener(FontDboxApplyListener *listener);
228  void remove_apply_listener(FontDboxApplyListener *listener);
229 };
230 
235 {
236 public:
243  FontDboxApplyEvent(const IdBlock &id_block, PollBlock &data) :
244  EventInfo(id_block, data) {}
245 
249  int height() const {return _data.word[4];}
250 
254  int aspect_ratio() const {return _data.word[5];}
255 
260  const std::string name() const {return reinterpret_cast<const char *>(&_data.word[6]);}
261 };
262 
267 {
268 public:
269  ~FontDboxApplyListener() {};
270 
276  virtual void fontdbox_apply(const FontDboxApplyEvent &apply_event) = 0;
277 };
278 
279 }
280 
281 #endif /* TBX_FONTDBOX_H_ */
std::string title() const
Get title.
Definition: fontdbox.h:214
A library for creating RISC OS toolbox applications.
Definition: abouttobeshownlistener.cc:34
Class for FontDbox object template.
Definition: resfontdbox.h:36
void no_font()
Set dialog to no font selected.
Definition: fontdbox.h:159
std::string font() const
Return selected font.
Definition: fontdbox.h:164
std::string try_string() const
Get string to shown in try box.
Definition: fontdbox.h:199
FontDbox(const FontDbox &other)
Construct a FontDbox from another FontDbox.
Definition: fontdbox.h:76
Listener for about to be shown event.
Definition: abouttobeshownlistener.h:76
FontDbox()
Construct creates an unassigned FontDbox.
Definition: fontdbox.h:67
Structure holding the raw data from a call to Wimp_Poll.
Definition: pollinfo.h:71
int height() const
Height selected.
Definition: fontdbox.h:249
void title(std::string value)
Set title.
Definition: fontdbox.h:209
FontDboxApplyEvent(const IdBlock &id_block, PollBlock &data)
Construct the event from the details return by the toolbox.
Definition: fontdbox.h:243
int font_length() const
Return selected font name length.
Definition: fontdbox.h:169
bool operator!=(const Object &other) const
Check if this FontDbox does not refers to the same underlying toolbox object as another.
Definition: fontdbox.h:140
Classes to use/edit toolbox resources in memory.
int try_string_length() const
Get length of string shown in try box.
Definition: fontdbox.h:204
bool operator==(const Object &other) const
Check if this FontDbox refers to the same underlying toolbox object as another.
Definition: fontdbox.h:132
Class to show a toolbox FontDbox object.
Definition: fontdbox.h:57
const std::string name() const
Name of font selected.
Definition: fontdbox.h:260
FontDbox & operator=(const FontDbox &other)
Assign this FontDbox from another.
Definition: fontdbox.h:112
unsigned int ObjectId
Type for underlying toolbox object id.
Definition: handles.h:31
FontDbox(const Object &other)
Construct a FontDbox from an Object that refers to a FontDbox.
Definition: fontdbox.h:87
void font(std::string value)
Set font to select.
Definition: fontdbox.h:154
int title_length() const
Get length of title.
Definition: fontdbox.h:219
Event information for FontDboxApplyListener.
Definition: fontdbox.h:234
FontDbox & operator=(const Object &other)
Assign this FontDbox from an Object that refers to a FontDbox.
Definition: fontdbox.h:124
The Window object represents a toolbox window.
Definition: window.h:69
Class to provide information on a toolbox event.
Definition: eventinfo.h:48
FontDbox(const std::string &template_name)
Create a FontDbox from the named template.
Definition: fontdbox.h:95
Listener for FontDbox Apply events.
Definition: fontdbox.h:266
int aspect_ratio() const
Aspect ratio selected.
Definition: fontdbox.h:254
void try_string(std::string value)
Set string to show in try box.
Definition: fontdbox.h:194
Base class for all toolbox event listeners.
Definition: listener.h:33
Window window() const
Return the underlying toolbox window used to implement the FontDbox object.
Definition: fontdbox.h:147
Listener for an object has been hidden event.
Definition: hasbeenhiddenlistener.h:36
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
ObjectId handle() const
Return the underlying toolbox object id this object references.
Definition: object.h:93