tbx  0.7.6
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
tbx::Component Class Reference

Base class for components in an object. More...

#include <component.h>

Inheritance diagram for tbx::Component:
tbx::ext::TreeViewCurrentNode tbx::Gadget tbx::MenuItem tbx::ActionButton tbx::Adjuster tbx::Button tbx::DisplayField tbx::Draggable tbx::ext::Tabs tbx::ext::TreeView tbx::NumberRange tbx::OptionButton tbx::PopUp tbx::RadioButton tbx::ScrollList tbx::Slider tbx::StringSet tbx::TextArea tbx::ToolAction tbx::WritableField

Public Member Functions

 Component ()
 Construct an uninitialised component. More...
 
 Component (Object obj, ComponentId id)
 Construct a component from an object and component id. More...
 
 Component (ObjectId handle, ComponentId id)
 Construct a component from an object handle and component id. More...
 
bool null () const
 Check if this component is in an uninitialised state. More...
 
Object object ()
 Return the object his component belongs to.
 
Object object () const
 Return the object his component belongs to.
 
ObjectId handle () const
 Return the object handle for his component.
 
ComponentId id () const
 Get the component ID of this component. More...
 
Componentoperator= (const Component &other)
 Assign the Component to refer to the same underlying toolbox component.
 
bool operator== (const Component &other) const
 Check if this component refers to the same underlying toolbox component. More...
 
bool operator!= (const Component &other) const
 Check if this component refers to the same underlying toolbox gadget. More...
 
 operator bool () const
 Operator to check if this component has been initialised. More...
 
void add_command (int command_id, Command *command)
 Add a command to this Component. More...
 
void remove_command (int command_id, Command *command)
 Remove a command from this component. 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 component. More...
 
void remove_all_listeners ()
 Remove all the listeners on this component. More...
 

Protected Member Functions

void add_listener (int action, Listener *listener, RawToolboxEventHandler handler)
 Helper function to add listeners to this component. More...
 
void remove_listener (int action, Listener *listener)
 Helper function to remove listeners from this component.
 
void add_window_listener (int event_code, Listener *listener)
 Helper function to add a listener for a WIMP window event.
 
void remove_window_listener (int event_code, Listener *listener)
 Helper function to remove a listener for a WIMP window event.
 
int int_property (int property_id) const
 Get an integer property from the toolbox Component. More...
 
void int_property (int property_id, int value)
 Set an integer property from the toolbox object. More...
 
bool bool_property (int property_id) const
 Get a boolean property from the toolbox Component. More...
 
void bool_property (int property_id, bool value)
 Set a boolean property from the toolbox object. More...
 
std::string string_property (int property_id) const
 Get a string property from the toolbox object. More...
 
int string_property_length (int property_id) const
 Get a the length of a string property from the toolbox object. More...
 
void string_property (int property_id, const std::string &value)
 Set a string property in the toolbox object. More...
 
bool flag_property (int property_id, int flag) const
 Check if a particular flag is set in a property. More...
 
void flag_property (int property_id, int flag, bool value)
 Set a particular flag in a property. More...
 

Protected Attributes

ObjectId _handle
 Underlying toolbox handle.
 
int _id
 Underlying toolbox component id.
 

Detailed Description

Base class for components in an object.

Constructor & Destructor Documentation

◆ Component() [1/3]

tbx::Component::Component ( )
inline

Construct an uninitialised component.

The component should be assigned to an initialised component before it is used.

◆ Component() [2/3]

tbx::Component::Component ( Object  obj,
ComponentId  id 
)
inline

Construct a component from an object and component id.

Note: There is no checking of the object or id for validity

Parameters
objobject that contains the component
idtoolbox component id

◆ Component() [3/3]

tbx::Component::Component ( ObjectId  handle,
ComponentId  id 
)
inline

Construct a component from an object handle and component id.

Note: There is no checking of the object handle or id for validity

Parameters
handleObject toolbox handle
idtoolbox component id

Member Function Documentation

◆ add_command()

void tbx::Component::add_command ( int  command_id,
Command command 
)

Add a command to this Component.

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
ComponentNullErrortoolbox handle is NULL_ComponentId

◆ add_listener()

void tbx::Component::add_listener ( int  action,
Listener listener,
RawToolboxEventHandler  handler 
)
protected

Helper function to add listeners to this component.

Derived classes usually call this specifying the action and handler for the events specific to them.

◆ add_user_event_listener()

void tbx::Component::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.
Exceptions
ComponentNullErrortoolbox handle is NULL_ComponentId

◆ bool_property() [1/2]

bool tbx::Component::bool_property ( int  property_id) const
protected

Get a boolean property from the toolbox Component.

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
OsError

◆ bool_property() [2/2]

void tbx::Component::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
valueThe new value for the property
Exceptions
OsError

◆ flag_property() [1/2]

bool tbx::Component::flag_property ( int  property_id,
int  flag 
) const
protected

Check if a particular flag is set in a property.

Parameters
property_id- id to check
flag- flag value to test
Returns
true if flag is set
Exceptions
OsError

◆ flag_property() [2/2]

void tbx::Component::flag_property ( int  property_id,
int  flag,
bool  value 
)
protected

Set a particular flag in a property.

Parameters
property_id- property id to get the flags, property_id+1 must be the id to set the flags
flag- flag value to set
value- true set the flag, false clear it
Exceptions
OsError

◆ id()

ComponentId tbx::Component::id ( ) const
inline

Get the component ID of this component.

Returns
Component id of this Component. This will be NULL_ComponentId if the component is uninitialised.

◆ int_property() [1/2]

int tbx::Component::int_property ( int  property_id) const
protected

Get an integer property from the toolbox Component.

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
OsError

◆ int_property() [2/2]

void tbx::Component::int_property ( int  property_id,
int  value 
)
protected

Set an integer 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
valuethe new value for the property
Exceptions
OsError

◆ null()

bool tbx::Component::null ( ) const
inline

Check if this component is in an uninitialised state.

Returns
true if the component is uninitialised.

◆ operator bool()

tbx::Component::operator bool ( ) const
inline

Operator to check if this component has been initialised.

Returns
true if the component has been initialised

◆ operator!=()

bool tbx::Component::operator!= ( const Component other) const
inline

Check if this component refers to the same underlying toolbox gadget.

Returns
true if the components are not the same.

◆ operator==()

bool tbx::Component::operator== ( const Component other) const
inline

Check if this component refers to the same underlying toolbox component.

Returns
true if the components are the same.

◆ remove_all_listeners()

void tbx::Component::remove_all_listeners ( )

Remove all the listeners on this component.

Remove all the listeners and commands from this component.

Exceptions
ComponentNullErrorif this is an uninitialised component

◆ remove_command()

void tbx::Component::remove_command ( int  command_id,
Command command 
)

Remove a command from this component.

Parameters
command_idThe event id that was associated with the command.
commandThe command to remove.
Exceptions
ComponentNullErrortoolbox handle is NULL_ComponentId

◆ remove_user_event_listener()

void tbx::Component::remove_user_event_listener ( int  event_id,
UserEventListener listener 
)

Remove a user event listener from this component.

Parameters
event_idThe event id that was associated with the listener.
listenerThe listener to remove.
Exceptions
ComponentNullErrortoolbox handle is NULL_ComponentId

◆ string_property() [1/2]

std::string tbx::Component::string_property ( int  property_id) const
protected

Get a string property from the toolbox object.

Helper function to implement specific properties in subclasses. Calls Toolbox_ObjectMiscOp and with buffer for return in r4, size in r5.

Parameters
property_idthe method code to get the property
Returns
The value from the property
Exceptions
OsError

◆ string_property() [2/2]

void tbx::Component::string_property ( int  property_id,
const std::string &  value 
)
protected

Set a string property in the toolbox object.

Helper function to implement specific properties in subclasses. Calls Toolbox_ObjectMiscOp and with value pointed to by r3.

Parameters
property_idthe method code to get the property
valuethe new string value for the property
Exceptions
OsError

◆ string_property_length()

int tbx::Component::string_property_length ( int  property_id) const
protected

Get a the length of a string property from the toolbox object.

Helper function to implement specific properties in subclasses. Calls Toolbox_ObjectMiscOp and with buffer for return in r3, size in r4.

Parameters
property_idthe method code to get the property
Returns
The length of the property
Exceptions
OsError

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