tbx  0.7.3
colourmenu.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  * colourmenu.h
27  *
28  * Created on: 01-Jul-2010
29  * Author: alanb
30  */
31 
32 #ifndef TBX_COLOURMENU_H_
33 #define TBX_COLOURMENU_H_
34 
35 #include "showpointobject.h"
36 #include "listener.h"
37 #include "window.h"
38 #include "colour.h"
39 
40 namespace tbx {
41 
42 // Listeners
43 class AboutToBeShownListener;
44 class HasBeenHiddenListener;
45 class ColourMenuSelectionListener;
46 
47 namespace res
48 {
49  class ResColourMenu;
50 }
51 
57 {
58 public:
59  enum { TOOLBOX_CLASS = 0x82980 };
60 
66  ColourMenu() {};
75  ColourMenu(const ColourMenu &other) : ShowPointObject(other._handle) {}
86  ColourMenu(const Object &other) : ShowPointObject(other) {check_toolbox_class(ColourMenu::TOOLBOX_CLASS);}
94  ColourMenu(const std::string &template_name) : ShowPointObject(template_name) {check_toolbox_class(ColourMenu::TOOLBOX_CLASS);}
101  ColourMenu(const res::ResColourMenu &object_template);
102 
111  ColourMenu &operator=(const ColourMenu &other) {_handle = other.handle(); return *this;}
123  ColourMenu &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  // Properties
142 
148  void colour(WimpColour colour) {int_property(0, (int)colour);}
149 
154 
160  void none_available(bool allow_none) {bool_property(2, allow_none);}
161 
165  bool none_availble() const {return bool_property(3);}
166 
167 
173  void title(std::string msg) {string_property(4, msg);}
174 
178  std::string title() const {return string_property(5);}
179 
183  int title_length() const {return string_property_length(5);}
184 
185  // Listeners
192 
193 };
194 
199 {
200 public:
202 
209  virtual void colourmenu_selection(ColourMenu colour_menu, WimpColour colour) = 0;
210 };
211 
212 }
213 
214 #endif /* TBX_COLOURMENU_H_ */
ColourMenu(const ColourMenu &other)
Construct a ColourMenu from another ColourMenu.
Definition: colourmenu.h:75
ObjectId _handle
Handle for toolbox object.
Definition: object.h:173
Listener for about to be shown event.
Definition: abouttobeshownlistener.h:76
void check_toolbox_class(int class_id) const
Check if this objects toolbox class is as specified.
Definition: object.cc:122
bool none_availble() const
Get if menu include "no colour" (none) option.
Definition: colourmenu.h:165
int string_property_length(int property_id) const
Gets the size of a string properties buffer.
Definition: object.cc:530
bool operator==(const Object &other) const
Check if this ColourMenu refers to the same underlying toolbox object as another. ...
Definition: colourmenu.h:131
bool operator!=(const Object &other) const
Check if this ColourMenu does not refers to the same underlying toolbox object as another...
Definition: colourmenu.h:139
void add_has_been_hidden_listener(HasBeenHiddenListener *listener)
This event is raised after the ColourMenu dialog has been completed.
Definition: colourmenu.cc:67
ColourMenu & operator=(const ColourMenu &other)
Assign this ColourMenu from another.
Definition: colourmenu.h:111
Class for ColourMenu object template.
Definition: rescolourmenu.h:36
void colour(WimpColour colour)
Set selected colour for menu.
Definition: colourmenu.h:148
void remove_selection_listener(ColourMenuSelectionListener *listener)
Remove listener for menu colour selection.
Definition: colourmenu.cc:105
Class to represent a standard desktop WIMP colour.
Definition: colour.h:146
void remove_has_been_hidden_listener(HasBeenHiddenListener *listener)
Remove has been hidden listener.
Definition: colourmenu.cc:77
ColourMenu()
Construct creates an unassigned ColourMenu.
Definition: colourmenu.h:66
void add_selection_listener(ColourMenuSelectionListener *listener)
Add listener to be called when the a colour has been selected from the menu.
Definition: colourmenu.cc:95
void title(std::string msg)
Set Title.
Definition: colourmenu.h:173
std::string title() const
Return title.
Definition: colourmenu.h:178
ColourMenu & operator=(const Object &other)
Assign this ColourMenu from an Object that refers to a ColourMenu.
Definition: colourmenu.h:123
int int_property(int property_id) const
Return the value of a property that returns an integer.
Definition: object.cc:435
std::string string_property(int property_id) const
Return the value of a property that returns text.
Definition: object.cc:477
virtual void colourmenu_selection(ColourMenu colour_menu, WimpColour colour)=0
Called when colour selected from menu.
Class to show a toolbox ColourMenu object.
Definition: colourmenu.h:56
bool bool_property(int property_id) const
Get a boolean property from the toolbox Cobject.
Definition: object.cc:553
WimpColour colour()
Get selected menu colour.
Definition: colourmenu.h:153
int title_length() const
Return the length of the title.
Definition: colourmenu.h:183
ColourMenu(const std::string &template_name)
Create a ColourMenu from the named template.
Definition: colourmenu.h:94
Listener for when an item is selected from the colour menu.
Definition: colourmenu.h:198
ObjectId handle() const
Return the underlying toolbox object id this object references.
Definition: object.h:93
void none_available(bool allow_none)
Set if "no colour" is available.
Definition: colourmenu.h:160
ColourMenu(const Object &other)
Construct a ColourMenu from an Object that refers to a ColourMenu.
Definition: colourmenu.h:86
Base class for all toolbox event listeners.
Definition: listener.h:33
Object that can be shown at a specific position as well as its default place.
Definition: showpointobject.h:42
Listener for an object has been hidden event.
Definition: hasbeenhiddenlistener.h:36
void add_about_to_be_shown_listener(AboutToBeShownListener *listener)
This event is raised just before the ColourMenu underlying window is about to be shown.
Definition: colourmenu.cc:47
Class to manipulate a toolbox object.
Definition: object.h:50
void remove_about_to_be_shown_listener(AboutToBeShownListener *listener)
Remove about to be shown listener.
Definition: colourmenu.cc:57