tbx  0.7.6
Public Types | Public Member Functions | List of all members
tbx::Button Class Reference

A Button is a gadget that show a sprite or some text in the window. More...

#include <button.h>

Inheritance diagram for tbx::Button:
tbx::Gadget tbx::Component

Public Types

enum  { TOOLBOX_CLASS = 960 }
 
enum  ButtonType {
  IGNORE_CLICKS, CONTINUOUS, CLICK_AUTO_REPEAT, CLICK_ONCE,
  CLICK_SELECTS, CLICK_SELECTS_DOUBLE, CLICK_ONCE_DRAG, CLICK_SELECTS_DRAG,
  CLICK_SELECTS_DOUBLE_DRAG, OVER_SELECTS, CLICK_DOUBLE_DRAG, CLICK_NOTIFY_AND_SELECTS_DRAG,
  FOCUS_AND_DRAG = 14, WRITEABLE
}
 Enumeration for how the button processes clicks.
 

Public Member Functions

 Button ()
 Construct an uninitialised button.
 
 ~Button ()
 Destroy a button gadget. More...
 
 Button (const Button &other)
 Construct a button from another button. More...
 
 Button (const Gadget &other)
 Construct a button from another gadget. More...
 
 Button (const Component &other)
 Construct a button from a component. More...
 
Buttonoperator= (const Button &other)
 Assign a button to refer to the same underlying toolbox gadget as another.
 
Buttonoperator= (const Gadget &other)
 Assign a button to refer to the same underlying toolbox gadget as an existing Gadget. More...
 
Buttonoperator= (const Component &other)
 Assign a button to refer to the same underlying toolbox component as an existing Gadget. More...
 
bool operator== (const Gadget &other) const
 Check if this button refers to the same underlying toolbox gadget as another gadget. More...
 
bool operator!= (const Gadget &other) const
 Check if this button refers to the same underlying toolbox gadget as another gadget. More...
 
int flags () const
 Returns the flags for the button, these are the same as for a wimp icon. More...
 
void flags (int clear, int eor)
 Set the button flags. More...
 
bool has_text () const
 Check if the button shows text. More...
 
void has_text (bool value)
 Set if the button shows text. More...
 
bool is_sprite () const
 Check if the button shows a sprite. More...
 
void is_sprite (bool value)
 Set if the button shows a sprite. More...
 
bool has_border () const
 Check if the button has a border. More...
 
void has_border (bool value)
 Set if the button has a border. More...
 
bool hcentred () const
 Check if the contents of the button are horizontally centred. More...
 
void hcentred (bool value)
 Set if the contents of the button are horizontally centred. More...
 
bool vcentred () const
 Check if the contents of the button are vertically centred. More...
 
void vcentred (bool value)
 Set if the contents of the button are vertically centred. More...
 
bool filled () const
 Check if the button background is filled. More...
 
void filled (bool value)
 Set if the button background is filled. More...
 
bool anti_aliased_font () const
 Check if the button uses an anti aliased font. More...
 
void anti_aliased_font (bool value)
 Set if the button uses an anti aliased font. More...
 
bool redraw_needs_help () const
 Check if the button need help from the user application to be redrawn. More...
 
void redraw_needs_help (bool value)
 Set if the button need help from the user application to be redrawn. More...
 
bool text_right_justified () const
 Check if the text on the button is right justified. More...
 
void text_right_justified (bool value)
 Set if the text on the button is right justified. More...
 
bool adjust_does_not_cancel () const
 Check if the adjust does not cancel other selections in the same ESG group. More...
 
void adjust_does_not_cancel (bool value)
 Set if the adjust does not cancel other selections in the same ESG group. More...
 
bool half_size_sprite () const
 Check if the button display the sprite half size. More...
 
void half_size_sprite (bool value)
 Set if the button shows the sprite half size. More...
 
ButtonType button_type () const
 Get how the button processes mouse clicks. More...
 
void button_type (ButtonType type)
 Set how the button processes mouse clicks. More...
 
int esg () const
 Return the exclusive selection group (ESG) for the button. More...
 
void esg (int value)
 Set the exclusive selection group (ESG) for the button. More...
 
WimpColour foreground () const
 Return the foreground WIMP colour. More...
 
void foreground (WimpColour value)
 Set the foreground WIMP colour. More...
 
WimpColour background () const
 Return the background WIMP colour. More...
 
void background (WimpColour value)
 Set the background WIMP colour. More...
 
int font_handle () const
 Get the WIMP font handle for drawing text. More...
 
void font_handle (int value)
 Set the WIMP font handle for drawing text. More...
 
void value (std::string v)
 Set the button value. More...
 
std::string value () const
 Get the button value.
 
int value_length () const
 Return the length of the button value.
 
void validation (std::string v)
 Set the button validation.
 
std::string validation () const
 Get the button validation.
 
int validation_length () const
 Return the length of the button validation.
 
void font (const std::string &name, int width, int height)
 Set the font used for the button. More...
 
void system_font (int width, int height)
 Set the button to use the system font to display the text. More...
 
void add_mouse_click_listener (MouseClickListener *listener)
 Add listener for mouse click on the button.
 
void remove_mouse_click_listener (MouseClickListener *listener)
 Remove listener for mouse click on the button.
 
- Public Member Functions inherited from tbx::Gadget
 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...
 
 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...
 

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

A Button is a gadget that show a sprite or some text in the window.

It is similar to a Wimp icon, but has the following restrictions. A Button created as sprite only cannot be made into any sort of text Button. A Button created as text only cannot be made into a sprite only Button. A sprite only Button can only refer to sprites by name and these must be in the Wimp sprite pool or the task's sprite area.

Constructor & Destructor Documentation

◆ ~Button()

tbx::Button::~Button ( )
inline

Destroy a button gadget.

This does not delete the underlying toolbox gadget.

◆ Button() [1/3]

tbx::Button::Button ( const Button other)
inline

Construct a button from another button.

Both Button will refer to the same underlying toolbox gadget.

◆ Button() [2/3]

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

Construct a button from another gadget.

The Button and the Gadget will refer to the same underlying toolbox gadget.

Exceptions
GadgetClassErrorif the underlying toolbox gadget isn't a button

◆ Button() [3/3]

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

Construct a button from a component.

The Button and the Component will refer to the same underlying toolbox component.

Member Function Documentation

◆ adjust_does_not_cancel() [1/2]

bool tbx::Button::adjust_does_not_cancel ( ) const
inline

Check if the adjust does not cancel other selections in the same ESG group.

Returns
true if the button adjust does not cancel other selections

◆ adjust_does_not_cancel() [2/2]

void tbx::Button::adjust_does_not_cancel ( bool  value)
inline

Set if the adjust does not cancel other selections in the same ESG group.

Parameters
valuetrue so set the button so adjust does not cancel other selections

◆ anti_aliased_font() [1/2]

bool tbx::Button::anti_aliased_font ( ) const
inline

Check if the button uses an anti aliased font.

Returns
true if the button uses an anti aliased font

◆ anti_aliased_font() [2/2]

void tbx::Button::anti_aliased_font ( bool  value)
inline

Set if the button uses an anti aliased font.

Note: if the anti-aliased flag is set the font_handle methods become available, but the foreground and background methods should not be used.

Parameters
valuetrue to make the button use an anti aliased font

◆ background() [1/2]

WimpColour tbx::Button::background ( ) const
inline

Return the background WIMP colour.

This method is only valid when anti_aliased_font() == false

Returns
background WIMP colour (0-15)

◆ background() [2/2]

void tbx::Button::background ( WimpColour  value)
inline

Set the background WIMP colour.

This method is only valid when anti_aliased_font() == false

Parameters
valuebackground WIMP colour (0-15)

◆ button_type() [1/2]

ButtonType tbx::Button::button_type ( ) const
inline

Get how the button processes mouse clicks.

Returns
ButtonType value for how clicks are handled

◆ button_type() [2/2]

void tbx::Button::button_type ( ButtonType  type)
inline

Set how the button processes mouse clicks.

Parameters
typeButtonType for how clicks are handled

◆ esg() [1/2]

int tbx::Button::esg ( ) const
inline

Return the exclusive selection group (ESG) for the button.

Selecting one button that is an ESG will unselect all the others in the same ESG.

Returns
ESG number (0-31). 0 Means not in a group.

◆ esg() [2/2]

void tbx::Button::esg ( int  value)
inline

Set the exclusive selection group (ESG) for the button.

Selecting one button that is an ESG will unselect all the others in the same ESG.

Parameters
valueESG number (0-31). 0 Means not in a group.

◆ filled() [1/2]

bool tbx::Button::filled ( ) const
inline

Check if the button background is filled.

Returns
true if the button background is filled

◆ filled() [2/2]

void tbx::Button::filled ( bool  value)
inline

Set if the button background is filled.

Parameters
valuetrue to fill the button background

◆ flags() [1/2]

int tbx::Button::flags ( ) const
inline

Returns the flags for the button, these are the same as for a wimp icon.

See the RISC OS PRM for details of what the bits of the flags mean.

Other methods are provided to check the individual elements of these flags by name.

◆ flags() [2/2]

void tbx::Button::flags ( int  clear,
int  eor 
)

Set the button flags.

This is similar to Wimp_SetIconState but not all flags are settable. See the RISC OS PRM for details of the flags.

Other methods are provided to set the individual elements of these flags by name.

Parameters
clearbits to clear
eorbits to exclusive or

◆ font()

void tbx::Button::font ( const std::string &  name,
int  width,
int  height 
)

Set the font used for the button.

Parameters
nameThe name of the font
widthfont width in 16ths of a point
heightfont height in 16ths of a point

◆ font_handle() [1/2]

int tbx::Button::font_handle ( ) const
inline

Get the WIMP font handle for drawing text.

This method is only valid when anti_aliased_font() == true

Returns
WIMP font handle

◆ font_handle() [2/2]

void tbx::Button::font_handle ( int  value)
inline

Set the WIMP font handle for drawing text.

This method is only valid when anti_aliased_font() == true

Returns
WIMP font handle

◆ foreground() [1/2]

WimpColour tbx::Button::foreground ( ) const
inline

Return the foreground WIMP colour.

This method is only valid when anti_aliased_font() == false

Returns
foreground WIMP colour (0-15)

◆ foreground() [2/2]

void tbx::Button::foreground ( WimpColour  value)
inline

Set the foreground WIMP colour.

This method is only valid when anti_aliased_font() == false

Parameters
valueforeground WIMP colour (0-15)

◆ half_size_sprite() [1/2]

bool tbx::Button::half_size_sprite ( ) const
inline

Check if the button display the sprite half size.

Returns
true if the button display the sprite half size

◆ half_size_sprite() [2/2]

void tbx::Button::half_size_sprite ( bool  value)
inline

Set if the button shows the sprite half size.

Parameters
valuetrue to set the button to display the sprite half size

◆ has_border() [1/2]

bool tbx::Button::has_border ( ) const
inline

Check if the button has a border.

Returns
true if the button border

◆ has_border() [2/2]

void tbx::Button::has_border ( bool  value)
inline

Set if the button has a border.

Parameters
valuetrue to give the button a border

◆ has_text() [1/2]

bool tbx::Button::has_text ( ) const
inline

Check if the button shows text.

Returns
true if the button shows text

◆ has_text() [2/2]

void tbx::Button::has_text ( bool  value)
inline

Set if the button shows text.

Parameters
valueset to true if the button should show text

◆ hcentred() [1/2]

bool tbx::Button::hcentred ( ) const
inline

Check if the contents of the button are horizontally centred.

Returns
true if the button is horizontally centred

◆ hcentred() [2/2]

void tbx::Button::hcentred ( bool  value)
inline

Set if the contents of the button are horizontally centred.

Parameters
valuetrue to horizontally centre the button

◆ is_sprite() [1/2]

bool tbx::Button::is_sprite ( ) const
inline

Check if the button shows a sprite.

Returns
true if the button shows a sprite

◆ is_sprite() [2/2]

void tbx::Button::is_sprite ( bool  value)
inline

Set if the button shows a sprite.

Parameters
valuetrue if the button will show a sprite

◆ operator!=()

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

Check if this button refers to the same underlying toolbox gadget as another gadget.

Returns
true if they do not refer to the same underlying toolbox gadget.

◆ operator=() [1/2]

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

Assign a button to refer to the same underlying toolbox component as an existing Gadget.

Exceptions
ObjectClassErrorif the component is not in a window.
GadgetClassErrorif the underlying toolbox gadget isn't a button

◆ operator=() [2/2]

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

Assign a button to refer to the same underlying toolbox gadget as an existing Gadget.

Exceptions
GadgetClassErrorif the underlying toolbox gadget isn't a button

◆ operator==()

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

Check if this button refers to the same underlying toolbox gadget as another gadget.

Returns
true if they refer to the same underlying toolbox gadget.

◆ redraw_needs_help() [1/2]

bool tbx::Button::redraw_needs_help ( ) const
inline

Check if the button need help from the user application to be redrawn.

Returns
true if the button needs help to be redrawn

◆ redraw_needs_help() [2/2]

void tbx::Button::redraw_needs_help ( bool  value)
inline

Set if the button need help from the user application to be redrawn.

Parameters
valuetrue if the button needs help to be redrawn

◆ system_font()

void tbx::Button::system_font ( int  width,
int  height 
)

Set the button to use the system font to display the text.

Parameters
widthfont width in 16ths of a point
heightfont height in 16ths of a point

◆ text_right_justified() [1/2]

bool tbx::Button::text_right_justified ( ) const
inline

Check if the text on the button is right justified.

Returns
true if the text on the button is right justified

◆ text_right_justified() [2/2]

void tbx::Button::text_right_justified ( bool  value)
inline

Set if the text on the button is right justified.

Parameters
valuetrue to make the text on the button right justified

◆ value()

void tbx::Button::value ( std::string  v)
inline

Set the button value.

i.e. the text or sprite name.

◆ vcentred() [1/2]

bool tbx::Button::vcentred ( ) const
inline

Check if the contents of the button are vertically centred.

Returns
true if the button is vertically centred

◆ vcentred() [2/2]

void tbx::Button::vcentred ( bool  value)
inline

Set if the contents of the button are vertically centred.

Parameters
valuetrue to vertically centre the button

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