tbx  0.7.3
displayfield.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 #ifndef TBX_DISPLAYFIELD_H_
27 #define TBX_DISPLAYFIELD_H_
28 
29 #include "gadget.h"
30 
31 namespace tbx {
32 
38 class DisplayField: public tbx::Gadget {
39 public:
40  enum {TOOLBOX_CLASS = 448};
41 
43 
49 
55  DisplayField(const DisplayField &other) : Gadget(other) {}
56 
66  DisplayField(const Gadget &other) : Gadget(other) {check_toolbox_class(DisplayField::TOOLBOX_CLASS);}
67 
74  DisplayField(const Component &other) : Gadget(other) {Window check(other.handle()); check_toolbox_class(DisplayField::TOOLBOX_CLASS);}
75 
80  DisplayField &operator=(const DisplayField &other) {_handle = other._handle; _id = other._id; return *this;}
81 
88  DisplayField &operator=(const Gadget &other) {_handle = other.handle(); _id = other.id(); check_toolbox_class(TOOLBOX_CLASS); return *this;}
89 
97  DisplayField &operator=(const Component &other) {Window check(other.handle()); _handle = other.handle(); _id = other.id(); check_toolbox_class(TOOLBOX_CLASS); return *this;}
98 
104  bool operator==(const Gadget &other) const {return (_handle == other.handle() && _id == other.id());}
105 
111  bool operator!=(const Gadget &other) const {return (_handle != other.handle() || _id != other.id());}
112 
118  void text(const std::string &value) {string_property(448, value);}
119 
125  std::string text() const {return string_property(449);}
126 
132  int text_length() const {return string_property_length(449);}
133 
134  void font(const std::string &name, int width, int height);
135  void system_font(int width, int height);
136 };
137 
138 }
139 
140 #endif /* TBX_DISPLAYFIELD_H_ */
void system_font(int width, int height)
Set the display field to use the system font to display the text.
Definition: displayfield.cc:65
This is the base class for all Gadgets.
Definition: gadget.h:48
DisplayField(const Gadget &other)
Construct a display field from another gadget.
Definition: displayfield.h:66
DisplayField & operator=(const Component &other)
Assign a display field to refer to the same underlying toolbox component as an existing Gadget...
Definition: displayfield.h:97
bool operator==(const Gadget &other) const
Check if this display field refers to the same underlying toolbox gadget as another gadget...
Definition: displayfield.h:104
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
int string_property_length(int property_id) const
Get a the length of a string property from the toolbox object.
Definition: component.cc:302
DisplayField & operator=(const DisplayField &other)
Assign a display field to refer to the same underlying toolbox gadget as another. ...
Definition: displayfield.h:80
ComponentId id() const
Get the component ID of this component.
Definition: component.h:103
Base class for components in an object.
Definition: component.h:42
DisplayField()
Construct an uninitialised display field.
Definition: displayfield.h:42
DisplayField(const Component &other)
Construct a display field from a gadget.
Definition: displayfield.h:74
void text(const std::string &value)
Set the the text to display.
Definition: displayfield.h:118
bool operator!=(const Gadget &other) const
Check if this display field refers to the same underlying toolbox gadget as another gadget...
Definition: displayfield.h:111
std::string string_property(int property_id) const
Get a string property from the toolbox object.
Definition: component.cc:261
void font(const std::string &name, int width, int height)
Set the font used for the display field.
Definition: displayfield.cc:45
The Window object represents a toolbox window.
Definition: window.h:69
DisplayField wrapper for an underlying toolbox DisplayField gadget.
Definition: displayfield.h:38
ObjectId _handle
Underlying toolbox handle.
Definition: component.h:45
DisplayField(const DisplayField &other)
Construct a display field from another display field.
Definition: displayfield.h:55
std::string text() const
Get the the text this is being displayed.
Definition: displayfield.h:125
int _id
Underlying toolbox component id.
Definition: component.h:46
DisplayField & operator=(const Gadget &other)
Assign a display field to refer to the same underlying toolbox gadget as an existing Gadget...
Definition: displayfield.h:88
ObjectId handle() const
Return the object handle for his component.
Definition: component.h:95
~DisplayField()
Destroy a Display Field gadget.
Definition: displayfield.h:48
int text_length() const
Get the length of the text property.
Definition: displayfield.h:132