tbx  0.7.3
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
tbx::Object Class Reference

Class to manipulate a toolbox object. More...

#include <object.h>

Inheritance diagram for tbx::Object:
tbx::Iconbar tbx::Menu tbx::ShowPointObject tbx::ColourDbox tbx::ColourMenu tbx::FontMenu tbx::ShowFullObject tbx::DCS tbx::FileInfo tbx::FontDbox tbx::PrintDbox tbx::ProgInfo tbx::Quit tbx::SaveAs tbx::Scale tbx::Window

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...
 
Objectoperator= (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.
 

Detailed Description

Class to manipulate a toolbox object.

This is the base class of all toolbox objects

Constructor & Destructor Documentation

tbx::Object::Object ( )
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()

tbx::Object::Object ( ObjectId  handle)
inline

Construct an object referencing the given toolbox object.

Parameters
handleObjectId 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.

Parameters
template_namename of template used to create the object
Exceptions
OsErrorcreation of the toolbox object failed

Member Function Documentation

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

Parameters
command_idThe event id to associate the command with.
commandThe command to run when this event is received.
Exceptions
ObjectNullErrortoolbox handle is NULL_ObjectId
void Object::add_listener ( int  action,
Listener listener,
RawToolboxEventHandler  handler 
)
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

Parameters
actionToolbox event id
listenerlistener to add
handlerfunction 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.

Parameters
listenerlistener 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

Parameters
event_idThe event ID to associate the listener with.
listenerThe 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.

bool Object::bool_property ( int  property_id) const
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.

Parameters
property_idthe method code to get the property
Returns
value of property
Exceptions
OsErrorfailed to retrieve the property from the toolbox object
void Object::bool_property ( int  property_id,
bool  value 
)
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.

Parameters
property_idthe method code to get the property
valuenew value for the property
Exceptions
OsErrorfailed 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.

Parameters
class_idthe toolbox class id to check against
Exceptions
ObjectNullErrorif this object is uninitialised (null)
OsErrorif the underlying toolbox object is no longer valid
ObjectClassErrorif the class id doesn't match the underlying class id
void * Object::client_handle ( ) const

Return user defined handle stored against this object.

Returns
void pointer to client handle
void Object::client_handle ( void *  client_handle)

Set a user defined handle for this object.

Parameters
client_handlevoid 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.

Exceptions
ObjectNullErrortoolbox handle is NULL_ObjectId
OsErrorUnderlying call to toolbox failed.
ObjectId tbx::Object::handle ( ) const
inline

Return the underlying toolbox object id this object references.

Returns
ObjectId of the toolbox object
void Object::hide ( )

Hide the object.

Exceptions
ObjectNullErrortoolbox handle is NULL_ObjectId
OsErrorUnderlying call to toolbox failed.
int Object::int_property ( int  property_id) const
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.

Parameters
property_idID of property to return
Returns
integer value of the property
Exceptions
ObjectNullErrorthis is an uninitialised object
OsErrorfailed to retrieve property from toolbox object
void Object::int_property ( int  property_id,
int  value 
)
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.

Parameters
property_idID of property to set
valuethe new value for the property
Exceptions
ObjectNullErrorthis is an uninitialised object
OsErrorfailed to set the property on the toolbox object
bool tbx::Object::null ( ) const
inline

Check if object has been initialised.

Returns
true if the object has not been initialised
tbx::Object::operator bool ( ) const
inline

Operator to check if an object has been initialised.

Returns
true if the object has been initialised
bool tbx::Object::operator!= ( const Object other) const
inline

Check if this object does not reference the same toolbox object as another.

Parameters
otherobject to compare against
Returns
true if the objects refer to different toolbox object
Object& tbx::Object::operator= ( const Object other)
inline

Assign this object to reference the same toolbox object as another.

Parameters
otherobject to assign reference from
bool tbx::Object::operator== ( const Object other) const
inline

Check if this object references the same toolbox object as another.

Parameters
otherobject to compare against
Returns
true if both objects refer to the same toolbox object
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.

Exceptions
ObjectNullErrortoolbox handle is NULL_ObjectId
void Object::remove_command ( int  command_id,
Command command 
)

Remove a command from this object.

Parameters
command_idThe event id that was associated with the command.
commandThe command to remove.
Exceptions
ObjectNullErrortoolbox handle is NULL_ObjectId
void Object::remove_listener ( int  action,
Listener listener 
)
protected

Remove listener for toolbox event.

Parameters
actiontoolbox event id for listener
listenerlistener to remove
void Object::remove_object_deleted_listener ( ObjectDeletedListener listener)

Remove listener for when the toolbox object referenced by this object has been deleted.

Parameters
listenerlistener to remove
void Object::remove_user_event_listener ( int  event_id,
UserEventListener listener 
)

Remove a user event listener from this object.

Parameters
event_idThe event id that was associated with the listener.
listenerThe listener to remove.
Exceptions
ObjectNullErrortoolbox handle is NULL_ObjectId
void Object::set_handler ( int  action,
Listener listener,
RawToolboxEventHandler  handler 
)
protected

Set handler for an event that should not have more than one listener.

Parameters
actiontoolbox event id
listenerlistener to set
handlerfunction 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.

Exceptions
ObjectNullErrortoolbox handle is NULL_ObjectId
OsErrorUnderlying call to toolbox failed.
std::string Object::string_property ( int  property_id) const
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.

Parameters
property_idID of property to return
Returns
string value of the property
Exceptions
ObjectNullErrorthis is an uninitialised object
OsErrorfailed to retrieve property from toolbox object
void Object::string_property ( int  property_id,
const std::string &  value 
)
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.

Parameters
property_idID of property to set
valuethe new value for the property
Exceptions
ObjectNullErrorthis is an uninitialised object
OsErrorfailed to set the property on the toolbox object
int Object::string_property_length ( int  property_id) const
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.

Parameters
property_idID of property to return buffer size for
Returns
string buffer size of the property
Exceptions
ObjectNullErrorthis is an uninitialised object
OsErrorfailed to retrieve property from toolbox object
int Object::toolbox_class ( ) const

Get the toolbox class of this object.

Returns
toolbox class or 0 if uninitialised (null) object.
Exceptions
OsErrorif the underlying toolbox object is no longer valid.

The documentation for this class was generated from the following files: