tbx  0.7.5
Public Member Functions | Friends | List of all members
tbx::Gadget Class Reference

This is the base class for all Gadgets. More...

#include <gadget.h>

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

Public Member Functions

 Gadget ()
 Construct an uninitialised gadget. More...
 
 Gadget (const Gadget &other)
 Construct a gadget as a copy of another gadget object. More...
 
 Gadget (const Component &other)
 Construct a gadget as a copy of another component object. More...
 
Window window ()
 Get the window that contains this gadget.
 
Window window () const
 Get the window that contains this gadget.
 
Gadgetoperator= (const Gadget &other)
 Assign this gadget to refer to the same underlying toolbox gadget as another gadget.
 
Gadgetoperator= (const Component &other)
 Assign this gadget to refer to the same underlying toolbox gadget as the specified Component. More...
 
bool operator== (const Component &other) const
 Check if this gadget refers to the same underlying toolbox component as the given Component. More...
 
bool operator!= (const Component &other) const
 Check if this gadget refers to the same underlying toolbox component as the given Component. More...
 
bool operator== (const Gadget &other) const
 Check if this gadget refers to the same underlying toolbox component as the given Gadget. More...
 
bool operator!= (const Gadget &other) const
 Check if this gadget refers to the same underlying toolbox component as the given Gadget. More...
 
void check_toolbox_class (int class_id) const
 Check the underlying gadget class for this object has the given class id. More...
 
int toolbox_class () const
 Get the toolbox class for a gadget. More...
 
int toolbox_class_and_size () const
 Get the toolbox class and size for a gadget. More...
 
unsigned int flags () const
 Return the gadget flags. More...
 
void set_flag (unsigned int set)
 Sets bits in the gadgets flags. More...
 
void clear_flag (unsigned int clear)
 Clear bits in the gadget flags. More...
 
void fade ()
 Fade the gadget.
 
void unfade ()
 Clear the gadgets fade state.
 
void fade (bool fade)
 Fade/unfade the gadget. More...
 
bool faded () const
 Check if the gadget is faded. More...
 
void focus ()
 Set input focus to the gadget. More...
 
std::vector< IconHandleicon_list ()
 Get list of icons used in this gadget. More...
 
BBox bounds () const
 Get the bounding box of the gadget.
 
void bounds (const BBox &bounds)
 Set the bounds of the gadget. More...
 
Point bottom_left () const
 Get the bottom left location of gadget. More...
 
Point top_left () const
 Get the top left location of gadget. More...
 
void move_to (const Point &pos)
 Move gadget (without resizing) More...
 
void move_to (int x, int y)
 Move gadget without resizing. More...
 
void move_by (int bx, int by)
 Move gadget relative to it's current position without resizing. More...
 
Size size () const
 Return the size of the gadget. More...
 
void size (const Size &sz)
 Set size of gadget without moving it. More...
 
void add_loader (Loader *loader, int file_type=-2)
 Add a file loader. More...
 
void remove_loader (Loader *loader, int file_type=-2)
 Remove a file loader. More...
 
- Public Member Functions inherited from tbx::Component
 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...
 
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...
 

Friends

class Window
 

Additional Inherited Members

- Protected Member Functions inherited from tbx::Component
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 inherited from tbx::Component
ObjectId _handle
 Underlying toolbox handle.
 
int _id
 Underlying toolbox component id.
 

Detailed Description

This is the base class for all Gadgets.

Gadget are the UI elements that are contained in a window. e.g. Text fields, buttons etc.

Each gadget has its own ComponentId that is set in the toolbox resources.

A gadget can be retrieved by using its ComponentId in the window.gadget() method call.

Constructor & Destructor Documentation

◆ Gadget() [1/3]

tbx::Gadget::Gadget ( )
inline

Construct an uninitialised gadget.

No other methods should be used until this has been assigned to a an initialised gadget.

◆ Gadget() [2/3]

tbx::Gadget::Gadget ( const Gadget other)
inline

Construct a gadget as a copy of another gadget object.

Both this and the original refer to the same underlying toolbox gadget.

◆ Gadget() [3/3]

tbx::Gadget::Gadget ( const Component other)
inline

Construct a gadget as a copy of another component object.

Both this and the original refer to the same underlying toolbox gadget.

Exceptions
ObjectClassErrorif this is not a gadget. i.e. it is not a Component of a window.

Member Function Documentation

◆ add_loader()

void Gadget::add_loader ( Loader loader,
int  file_type = -2 
)

Add a file loader.

Parameters
loaderthe loader to add
file_typethe file type for the loader or -2 (the default) for any type.

◆ bottom_left()

Point Gadget::bottom_left ( ) const

Get the bottom left location of gadget.

Returns
Point containing bottom left of the gadget

◆ bounds()

void Gadget::bounds ( const BBox bounds)

Set the bounds of the gadget.

This can move and resize the gadget.

Parameters
bounds- new bounds for gadget

◆ check_toolbox_class()

void Gadget::check_toolbox_class ( int  class_id) const

Check the underlying gadget class for this object has the given class id.

Parameters
class_idclass id to check
Exceptions
GadgetClassErrorif gadget class id is different or NULL.

◆ clear_flag()

void Gadget::clear_flag ( unsigned int  clear)

Clear bits in the gadget flags.

Parameters
clearflags to clear

◆ fade()

void Gadget::fade ( bool  fade)

Fade/unfade the gadget.

Parameters
fadetrue to fade the gadget/false to unfade it.

◆ faded()

bool Gadget::faded ( ) const

Check if the gadget is faded.

Returns
true if the gadget is faded

◆ flags()

unsigned int Gadget::flags ( ) const

Return the gadget flags.

Returns
the current flags for the gadget

◆ focus()

void Gadget::focus ( )

Set input focus to the gadget.

The gadget must be a writeable field or a composite gadget that includes a writeable field.

◆ icon_list()

std::vector< IconHandle > Gadget::icon_list ( )

Get list of icons used in this gadget.

Returns
vector of icons used (could be empty)

◆ move_by()

void Gadget::move_by ( int  bx,
int  by 
)

Move gadget relative to it's current position without resizing.

Parameters
bxamount to move gadget in x direction (across)
byamount to move gadget in y direction (up)

◆ move_to() [1/2]

void Gadget::move_to ( const Point pos)

Move gadget (without resizing)

Parameters
pos- new bottom left of gadget

◆ move_to() [2/2]

void Gadget::move_to ( int  x,
int  y 
)

Move gadget without resizing.

Parameters
xnew minimum x coordinate
ynew minimum y coordinate

◆ operator!=() [1/2]

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

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

Returns
true if both do not refer to the same underlying toolbox component

◆ operator!=() [2/2]

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

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

Returns
true if both do not refer to the same underlying toolbox component

◆ operator=()

Gadget& tbx::Gadget::operator= ( const Component other)
inline

Assign this gadget to refer to the same underlying toolbox gadget as the specified Component.

Exceptions
ObjectClassErrorif this is not a gadget. i.e. it is not a Component of a window.

◆ operator==() [1/2]

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

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

Returns
true if both refer to the same underlying toolbox component

◆ operator==() [2/2]

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

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

Returns
true if both refer to the same underlying toolbox component

◆ remove_loader()

void Gadget::remove_loader ( Loader loader,
int  file_type = -2 
)

Remove a file loader.

Parameters
loaderthe loader to remove
file_typethe file type for the loader or -2 (the default) for any type.

◆ set_flag()

void Gadget::set_flag ( unsigned int  set)

Sets bits in the gadgets flags.

Parameters
setthe flags to set

◆ size() [1/2]

Size Gadget::size ( ) const

Return the size of the gadget.

Returns
size of gadget

◆ size() [2/2]

void Gadget::size ( const Size sz)

Set size of gadget without moving it.

Parameters
sznew size of gadget

◆ toolbox_class()

int Gadget::toolbox_class ( ) const

Get the toolbox class for a gadget.

Returns
gadget class
Exceptions
GadgetClassErrorif gadget class id is NULL.

◆ toolbox_class_and_size()

int Gadget::toolbox_class_and_size ( ) const

Get the toolbox class and size for a gadget.

Returns
gadget class (bottom 16 bits), size (top 16 bits)
Exceptions
GadgetClassErrorif gadget class id is NULL.

◆ top_left()

Point Gadget::top_left ( ) const

Get the top left location of gadget.

Returns
Point containing top left of the gadget

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