tbx
0.7.5
|
Class to manipulate a toolbox object. More...
#include <object.h>
Public Member Functions | |
Object () | |
Constructs an object unattached to a toolbox object. More... | |
Object (ObjectId handle) | |
Construct an object referencing the given toolbox object. More... | |
Object (const Object &other) | |
Construct an object referencing the same toolbox object as another. | |
Object (const std::string &template_name) | |
Create a toolbox object with the given name in the application resources and assign a reference to it in this object. More... | |
void | delete_object () |
Delete the underlying toolbox object. More... | |
bool | null () const |
Check if object has been initialised. More... | |
ObjectId | handle () const |
Return the underlying toolbox object id this object references. More... | |
Object & | operator= (const Object &other) |
Assign this object to reference the same toolbox object as another. More... | |
bool | operator== (const Object &other) const |
Check if this object references the same toolbox object as another. More... | |
bool | operator!= (const Object &other) const |
Check if this object does not reference the same toolbox object as another. More... | |
operator bool () const | |
Operator to check if an object has been initialised. More... | |
int | toolbox_class () const |
Get the toolbox class of this object. More... | |
void | check_toolbox_class (int class_id) const |
Check if this objects toolbox class is as specified. More... | |
void * | client_handle () const |
Return user defined handle stored against this object. More... | |
void | client_handle (void *client_handle) |
Set a user defined handle for this object. More... | |
Object | parent_object () const |
Get parent object. More... | |
Component | parent_component () const |
Get parent component. More... | |
Object | ancestor_object () const |
Get ancestor object. More... | |
Component | ancestor_component () const |
Get ancestor component. More... | |
void | show () |
Show the object at the default place. More... | |
void | hide () |
Hide the object. More... | |
bool | showing () const |
Check if an object is currently showing. | |
void | add_command (int command_id, Command *command) |
Add a command to this Object. More... | |
void | remove_command (int command_id, Command *command) |
Remove a command from this object. More... | |
void | add_user_event_listener (int event_id, UserEventListener *listener) |
Add a user event listener. More... | |
void | remove_user_event_listener (int event_id, UserEventListener *listener) |
Remove a user event listener from this object. More... | |
void | add_object_deleted_listener (ObjectDeletedListener *listener) |
Add listener for when the toolbox object referenced by this object has been deleted. More... | |
void | remove_object_deleted_listener (ObjectDeletedListener *listener) |
Remove listener for when the toolbox object referenced by this object has been deleted. More... | |
void | remove_all_listeners () |
Remove all listeners and commands from this object. More... | |
Protected Member Functions | |
Object (const res::ResObject &object_template) | |
Protected constructor to create an object. | |
void | add_listener (int action, Listener *listener, RawToolboxEventHandler handler) |
Add a listener for the given toolbox event. More... | |
void | remove_listener (int action, Listener *listener) |
Remove listener for toolbox event. More... | |
void | set_handler (int action, Listener *listener, RawToolboxEventHandler handler) |
Set handler for an event that should not have more than one listener. More... | |
int | int_property (int property_id) const |
Return the value of a property that returns an integer. More... | |
void | int_property (int property_id, int value) |
Set the value of a property that requires an integer. More... | |
std::string | string_property (int property_id) const |
Return the value of a property that returns text. More... | |
void | string_property (int property_id, const std::string &value) |
Set the value of a property that requires a string. More... | |
int | string_property_length (int property_id) const |
Gets the size of a string properties buffer. More... | |
bool | bool_property (int property_id) const |
Get a boolean property from the toolbox Cobject. More... | |
void | bool_property (int property_id, bool value) |
Set a boolean property from the toolbox object. More... | |
Protected Attributes | |
ObjectId | _handle |
Handle for toolbox object. | |
Class to manipulate a toolbox object.
This is the base class of all toolbox objects
|
inline |
Constructs an object unattached to a toolbox object.
This object should be assigned to an object that is attached before calling any of its methods apart from null()
|
inline |
Construct an object referencing the given toolbox object.
handle | ObjectId of the toolbox object to reference |
Object::Object | ( | const std::string & | template_name | ) |
Create a toolbox object with the given name in the application resources and assign a reference to it in this object.
template_name | name of template used to create the object |
OsError | creation of the toolbox object failed |
void Object::add_command | ( | int | command_id, |
Command * | command | ||
) |
Add a command to this Object.
For more details on events and commands see The tbx event system
command_id | The event id to associate the command with. |
command | The command to run when this event is received. |
ObjectNullError | toolbox handle is NULL_ObjectId |
|
protected |
Add a listener for the given toolbox event.
This is a helper function that can be called from derived classes to implement there toolbox event listeners
action | Toolbox event id |
listener | listener to add |
handler | function to translate event to listener to the event id. |
void Object::add_object_deleted_listener | ( | ObjectDeletedListener * | listener | ) |
Add listener for when the toolbox object referenced by this object has been deleted.
listener | listener to add |
void Object::add_user_event_listener | ( | int | event_id, |
UserEventListener * | listener | ||
) |
Add a user event listener.
For more details on events and commands see The tbx event system
event_id | The event ID to associate the listener with. |
listener | The listener to use. |
Component Object::ancestor_component | ( | ) | const |
Get ancestor component.
Returned component will be Component::null if there is no ancestor component.
Object Object::ancestor_object | ( | ) | const |
Get ancestor object.
Return object will be Object::null() if there is no ancestor.
|
protected |
Get a boolean property from the toolbox Cobject.
Helper function to implement specific properties in subclasses. Calls Toolbox_ObjectMiscOp and returns value in r0.
property_id | the method code to get the property |
OsError | failed to retrieve the property from the toolbox object |
|
protected |
Set a boolean property from the toolbox object.
Helper function to implement specific properties in subclasses. Calls Toolbox_ObjectMiscOp and with value in r4.
property_id | the method code to get the property |
value | new value for the property |
OsError | failed to set the property on the toolbox object |
void Object::check_toolbox_class | ( | int | class_id | ) | const |
Check if this objects toolbox class is as specified.
class_id | the toolbox class id to check against |
ObjectNullError | if this object is uninitialised (null) |
OsError | if the underlying toolbox object is no longer valid |
ObjectClassError | if the class id doesn't match the underlying class id |
void * Object::client_handle | ( | ) | const |
Return user defined handle stored against this object.
void Object::client_handle | ( | void * | client_handle | ) |
Set a user defined handle for this object.
client_handle | void pointer to client handle |
void Object::delete_object | ( | ) |
Delete the underlying toolbox object.
The toolbox will raise an ObjectDeletedEvent that will remove all the listeners on this object.
Once deleted the internal object handle is set to NULL so that all methods will throw an exception until it is assigned to another live object.
ObjectNullError | toolbox handle is NULL_ObjectId |
OsError | Underlying call to toolbox failed. |
|
inline |
Return the underlying toolbox object id this object references.
void Object::hide | ( | ) |
Hide the object.
ObjectNullError | toolbox handle is NULL_ObjectId |
OsError | Underlying call to toolbox failed. |
|
protected |
Return the value of a property that returns an integer.
This is a helper function for derived classes to make it easy to implement a wrapper to a toolbox property.
property_id | ID of property to return |
ObjectNullError | this is an uninitialised object |
OsError | failed to retrieve property from toolbox object |
|
protected |
Set the value of a property that requires an integer.
This is a helper function for derived classes to make it easy to implement a wrapper to a toolbox property.
property_id | ID of property to set |
value | the new value for the property |
ObjectNullError | this is an uninitialised object |
OsError | failed to set the property on the toolbox object |
|
inline |
Check if object has been initialised.
|
inline |
Operator to check if an object has been initialised.
|
inline |
Check if this object does not reference the same toolbox object as another.
other | object to compare against |
Assign this object to reference the same toolbox object as another.
other | object to assign reference from |
|
inline |
Check if this object references the same toolbox object as another.
other | object to compare against |
Component Object::parent_component | ( | ) | const |
Get parent component.
Returned component will be Component::null if there is no parent component.
Object Object::parent_object | ( | ) | const |
Get parent object.
Return object will be Object::null() if there is no parent.
void Object::remove_all_listeners | ( | ) |
Remove all listeners and commands from this object.
ObjectNullError | toolbox handle is NULL_ObjectId |
void Object::remove_command | ( | int | command_id, |
Command * | command | ||
) |
Remove a command from this object.
command_id | The event id that was associated with the command. |
command | The command to remove. |
ObjectNullError | toolbox handle is NULL_ObjectId |
|
protected |
Remove listener for toolbox event.
action | toolbox event id for listener |
listener | listener to remove |
void Object::remove_object_deleted_listener | ( | ObjectDeletedListener * | listener | ) |
Remove listener for when the toolbox object referenced by this object has been deleted.
listener | listener to remove |
void Object::remove_user_event_listener | ( | int | event_id, |
UserEventListener * | listener | ||
) |
Remove a user event listener from this object.
event_id | The event id that was associated with the listener. |
listener | The listener to remove. |
ObjectNullError | toolbox handle is NULL_ObjectId |
|
protected |
Set handler for an event that should not have more than one listener.
action | toolbox event id |
listener | listener to set |
handler | function to translate event to specific listener for the event id |
void Object::show | ( | ) |
Show the object at the default place.
Typically this means: Last place for a Window (uses template location first time) 64 OS units to the left of the pointer for a menu.
ObjectNullError | toolbox handle is NULL_ObjectId |
OsError | Underlying call to toolbox failed. |
|
protected |
Return the value of a property that returns text.
This is a helper function for derived classes to make it easy to implement a wrapper to a toolbox property.
property_id | ID of property to return |
ObjectNullError | this is an uninitialised object |
OsError | failed to retrieve property from toolbox object |
|
protected |
Set the value of a property that requires a string.
This is a helper function for derived classes to make it easy to implement a wrapper to a toolbox property.
property_id | ID of property to set |
value | the new value for the property |
ObjectNullError | this is an uninitialised object |
OsError | failed to set the property on the toolbox object |
|
protected |
Gets the size of a string properties buffer.
This is a helper function for derived classes to make it easy to implement a wrapper to a toolbox property.
property_id | ID of property to return buffer size for |
ObjectNullError | this is an uninitialised object |
OsError | failed to retrieve property from toolbox object |
int Object::toolbox_class | ( | ) | const |
Get the toolbox class of this object.
OsError | if the underlying toolbox object is no longer valid. |