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

Class representing a single menu item on a menu. More...

#include <menu.h>

Inheritance diagram for tbx::MenuItem:
tbx::Component

Public Member Functions

 MenuItem ()
 Construct an uninitialised menu item.
 
 MenuItem (const MenuItem &other)
 Construct a menu item from an existing menu item. More...
 
 MenuItem (const Component &other)
 Construct a menu item from a Component. More...
 
MenuItemoperator= (const MenuItem &other)
 Assign to another menu item. More...
 
MenuItemoperator= (const Component &other)
 Assign a menuitem field to refer to the same underlying toolbox component as an existing component. More...
 
bool operator== (const MenuItem &other)
 Check if this menu item refers to the same underlying toolbox menu option. More...
 
bool operator!= (const MenuItem &other)
 Check if this menu item refers to the same underlying toolbox menu option. More...
 
Menu menu ()
 Return the menu this menu item belongs to.
 
void tick (bool set)
 Put a tick by the menu item.
 
bool ticked () const
 Check if the menu item is ticked.
 
void fade (bool set)
 Fade the menu item.
 
bool faded () const
 Check if the menu item is faded.
 
void text (const std::string &text)
 Set the text for the menu item. More...
 
std::string text () const
 Get the text of the menu item.
 
int text_length () const
 Get the length of the buffer for the menu item text.
 
void sprite_name (const std::string &name)
 Set the sprite name for the menu item. More...
 
std::string sprite_name () const
 Get the sprite name for a sprite menu item.
 
int sprite_name_length () const
 Get the length of the buffer for the sprite name.
 
void submenu (const Object &object)
 Set the object to show as a submenu from this item.
 
void clear_submenu ()
 Clear the submenu from this item.
 
bool has_submenu () const
 Returns true if this object has a submenu.
 
Object submenu ()
 Return submenu or Object::null if none.
 
void submenu_event (int id)
 Set event to raise when mouse if moved over the submenu arrow. More...
 
int submenu_event () const
 Get the event raised when the mouse is moved over the submenu arrow. More...
 
void click_show (const Object &object, bool transient=true)
 Set object to show if menu item is clicked. More...
 
void clear_click_show ()
 Clear the click show object.
 
bool has_click_show () const
 Check if menu item has a click show object. More...
 
Object click_show (bool *transient=0)
 Get click show object for menu item. More...
 
void click_event (int id)
 Set click event for menu item. More...
 
int click_event () const
 Get the click event for this menu item. More...
 
void help_message (const std::string &msg)
 Set the help message for a menu item. More...
 
std::string help_message () const
 Get the items help message.
 
int help_message_length () const
 Get the length of the buffer for the help message.
 
void add_submenu_listener (SubMenuListener *listener)
 Add listener for mouse moving over the menu arrow when no other toolbox event is associated with this event. More...
 
void remove_submenu_listener (SubMenuListener *listener)
 Remove listener for mouse moving over the menu arrow when no other toolbox event is associated with this event. More...
 
void add_selection_listener (MenuSelectionListener *listener)
 Add listener for menu item selection. More...
 
void remove_selection_listener (MenuSelectionListener *listener)
 Remove menu selection listener. More...
 
void add_selection_command (Command *command)
 Add command to be run when this menu item is selected. More...
 
void remove_selection_command (Command *command)
 
- 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 Menu
 

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

Class representing a single menu item on a menu.

Constructor & Destructor Documentation

◆ MenuItem() [1/2]

tbx::MenuItem::MenuItem ( const MenuItem other)
inline

Construct a menu item from an existing menu item.

Both menu items will refer to the same underlying toolbox menu option

◆ MenuItem() [2/2]

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

Construct a menu item from a Component.

Exceptions
ObjectClassErrorif the component is not on a menu.

Member Function Documentation

◆ add_selection_command()

void tbx::MenuItem::add_selection_command ( Command command)

Add command to be run when this menu item is selected.

This is only generated if no other toolbox event is associated with the menu items selection.

Parameters
commandcommand to add

◆ add_selection_listener()

void tbx::MenuItem::add_selection_listener ( MenuSelectionListener listener)

Add listener for menu item selection.

This is only generated if no other toolbox event is assosiated with this event.

Parameters
listenerto add

◆ add_submenu_listener()

void tbx::MenuItem::add_submenu_listener ( SubMenuListener listener)

Add listener for mouse moving over the menu arrow when no other toolbox event is associated with this event.

Parameters
listenerto add

◆ click_event() [1/2]

void tbx::MenuItem::click_event ( int  id)

Set click event for menu item.

Parameters
idevent id or 0 to generate Menu_Selection toolbox event

◆ click_event() [2/2]

int tbx::MenuItem::click_event ( ) const

Get the click event for this menu item.

Returns
click event or 0 if no event was specified

◆ click_show() [1/2]

void tbx::MenuItem::click_show ( const Object object,
bool  transient = true 
)

Set object to show if menu item is clicked.

Parameters
objectobject to show
transientshow object as transient (defaults to true)

◆ click_show() [2/2]

Object tbx::MenuItem::click_show ( bool *  transient = 0)

Get click show object for menu item.

Parameters
transientpointer to variable to receive transient flag or 0 if not interested in transient flag. Defaults to 0
Returns
object to be shown or Object::null if nothing shown

◆ has_click_show()

bool tbx::MenuItem::has_click_show ( ) const

Check if menu item has a click show object.

Returns
true if click show defined

◆ help_message()

void tbx::MenuItem::help_message ( const std::string &  msg)

Set the help message for a menu item.

Exceptions
OsErrorthe entries help text buffer is not large enough to hold the message.

◆ operator!=()

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

Check if this menu item refers to the same underlying toolbox menu option.

Returns
true if they are not the same

◆ operator=() [1/2]

MenuItem& tbx::MenuItem::operator= ( const MenuItem other)
inline

Assign to another menu item.

Both menu items will refer to the same underlying toolbox menu option

◆ operator=() [2/2]

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

Assign a menuitem field to refer to the same underlying toolbox component as an existing component.

Exceptions
ObjectClassErrorif the component is not in a menu.

◆ operator==()

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

Check if this menu item refers to the same underlying toolbox menu option.

Returns
true if they are the same

◆ remove_selection_listener()

void tbx::MenuItem::remove_selection_listener ( MenuSelectionListener listener)

Remove menu selection listener.

Parameters
listenerto remove

◆ remove_submenu_listener()

void tbx::MenuItem::remove_submenu_listener ( SubMenuListener listener)

Remove listener for mouse moving over the menu arrow when no other toolbox event is associated with this event.

Parameters
listenerto remove

◆ sprite_name()

void tbx::MenuItem::sprite_name ( const std::string &  name)

Set the sprite name for the menu item.

Exceptions
OsErrorthe entries sprite name buffer is not large enough to hold the name or the entry is a sprite entry.

◆ submenu_event() [1/2]

void tbx::MenuItem::submenu_event ( int  id)

Set event to raise when mouse if moved over the submenu arrow.

If id is 0 then Menu_SubMenu toolbox event is raised instead

◆ submenu_event() [2/2]

int tbx::MenuItem::submenu_event ( ) const

Get the event raised when the mouse is moved over the submenu arrow.

If no event has been specified then 0 is returned.

◆ text()

void tbx::MenuItem::text ( const std::string &  text)

Set the text for the menu item.

Exceptions
OsErrorthe entries text buffer is not large enough to hold the text or the entry is a sprite entry.

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