tbx  0.7.5
fontmenu.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  * fontmenu.h
27  *
28  * Created on: 01-Jul-2010
29  * Author: alanb
30  */
31 
32 #ifndef TBX_FONTMENU_H_
33 #define TBX_FONTMENU_H_
34 
35 #include "showpointobject.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 FontMenuSelectionListener;
46 
47 namespace res
48 {
49  class ResFontMenu;
50 }
51 
57 {
58 public:
59  enum { TOOLBOX_CLASS = 0x82a40 };
60 
66  FontMenu() {};
75  FontMenu(const FontMenu &other) : ShowPointObject(other._handle) {}
86  FontMenu(const Object &other) : ShowPointObject(other) {check_toolbox_class(FontMenu::TOOLBOX_CLASS);}
94  FontMenu(const std::string &template_name) : ShowPointObject(template_name) {check_toolbox_class(FontMenu::TOOLBOX_CLASS);}
101  FontMenu(const res::ResFontMenu &object_template);
102 
111  FontMenu &operator=(const FontMenu &other) {_handle = other.handle(); return *this;}
123  FontMenu &operator=(const Object &other) {_handle = other.handle(); check_toolbox_class(TOOLBOX_CLASS); return *this;}
131  bool operator==(const Object &other) const {return (_handle == other.handle());}
139  bool operator!=(const Object &other) const {return (_handle != other.handle());}
140 
141 
142  // Properties
148  void font(std::string value) {string_property(0, value);}
149 
153  void no_font() {int_property(0, 0);}
154 
158  std::string font() const {return string_property(1);}
159 
163  int font_length() const {return string_property_length(1);}
164 
165  // Listeners
166  void add_about_to_be_shown_listener(AboutToBeShownListener *listener);
167  void remove_about_to_be_shown_listener(AboutToBeShownListener *listener);
168  void add_has_been_hidden_listener(HasBeenHiddenListener *listener);
169  void remove_has_been_hidden_listener(HasBeenHiddenListener *listener);
170  void add_selection_listener(FontMenuSelectionListener *listener);
171  void remove_selection_listener(FontMenuSelectionListener *listener);
172 };
173 
174 
179 {
180 public:
188  EventInfo(id_block, data) {}
189 
193  std::string font() const {return reinterpret_cast<const char *>(_data.word[4]);}
194 };
195 
200 {
201 public:
203 
209  virtual void fontmenu_selection(const FontMenuSelectionEvent &font_selected) = 0;
210 };
211 
212 }
213 
214 #endif /* TBX_FONTMENU_H_ */
A library for creating RISC OS toolbox applications.
Definition: abouttobeshownlistener.cc:34
FontMenuSelectionEvent(IdBlock &id_block, PollBlock &data)
Constructor from event data returned from the toolbox.
Definition: fontmenu.h:187
FontMenu(const std::string &template_name)
Create a FontMenu from the named template.
Definition: fontmenu.h:94
FontMenu()
Construct creates an unassigned FontMenu.
Definition: fontmenu.h:66
Listener for about to be shown event.
Definition: abouttobeshownlistener.h:76
FontMenu(const FontMenu &other)
Construct a FontMenu from another FontMenu.
Definition: fontmenu.h:75
Class to return information on font menu selection event.
Definition: fontmenu.h:178
FontMenu & operator=(const Object &other)
Assign this FontMenu from an Object that refers to a FontMenu.
Definition: fontmenu.h:123
FontMenu & operator=(const FontMenu &other)
Assign this FontMenu from another.
Definition: fontmenu.h:111
Structure holding the raw data from a call to Wimp_Poll.
Definition: pollinfo.h:71
Classes to use/edit toolbox resources in memory.
bool operator==(const Object &other) const
Check if this FontMenu refers to the same underlying toolbox object as another.
Definition: fontmenu.h:131
std::string font() const
Returns id of the font selected or "SystemFont" for the system entry.
Definition: fontmenu.h:193
std::string font() const
Return selected font.
Definition: fontmenu.h:158
Listener for font menu selection events.
Definition: fontmenu.h:199
void font(std::string value)
Set font to select.
Definition: fontmenu.h:148
Class to provide information on a toolbox event.
Definition: eventinfo.h:48
Base class for all toolbox event listeners.
Definition: listener.h:33
int font_length() const
Return selected font name length.
Definition: fontmenu.h:163
Object that can be shown at a specific position as well as its default place.
Definition: showpointobject.h:42
Class for FontMenu object template.
Definition: resfontmenu.h:36
Listener for an object has been hidden event.
Definition: hasbeenhiddenlistener.h:36
bool operator!=(const Object &other) const
Check if this FontMenu does not refers to the same underlying toolbox object as another.
Definition: fontmenu.h:139
FontMenu(const Object &other)
Construct a FontMenu from an Object that refers to a FontMenu.
Definition: fontmenu.h:86
void no_font()
Set dialog to no font selected.
Definition: fontmenu.h:153
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
Class to show a toolbox FontMenu object.
Definition: fontmenu.h:56