tbx  0.7.5
Public Types | Public Member Functions | List of all members
tbx::Menu Class Reference

Class representing a toolbox menu. More...

#include <menu.h>

Inheritance diagram for tbx::Menu:
tbx::Object

Public Types

enum  { TOOLBOX_CLASS = 0x828c0 }
 

Public Member Functions

 Menu ()
 Construct an uninitiased menu. More...
 
 Menu (const Menu &other)
 Construct a menu from another menu. More...
 
 Menu (const Object &other)
 Construct a menu from another toolbox object. More...
 
 Menu (const char *template_name)
 Create the toolbox object with the given name from the Toolbox resources for the application and assign a reference to it to this application. More...
 
Menuoperator= (const Menu &other)
 Assign a menu to an existing menu. More...
 
Menuoperator= (const Object &other)
 Assign a menu to an existing object. More...
 
bool operator== (const Object &other) const
 Checks if this menu refers to the same underlying toolbox object as the given object. More...
 
bool operator!= (const Object &other) const
 Checks if this menu refers to the same underlying toolbox object as the given object. More...
 
MenuItem item (ComponentId id)
 Retrieve the menu item for a given component id. More...
 
void help_message (const std::string &msg)
 Set the help message text for the menu.
 
std::string help_message () const
 Get the help message text.
 
int help_message_length () const
 Get the length of buffer for the help message text.
 
MenuItem add (const res::ResMenuItem &res_item, MenuItem *after=0)
 Add a new menu entry to the menu. More...
 
MenuItem insert (const res::ResMenuItem &res_item, MenuItem *before=0)
 Insert a new menu entry in the menu. More...
 
void erase (ComponentId id)
 Erase the menu item with the given id. More...
 
void erase (MenuItem &item)
 Erase the menu item given. More...
 
int height () const
 Return the height of the work area of the menu in OS units.
 
int width () const
 Return the width of the work area of the menu in OS units.
 
void title (const std::string &title)
 Set the title of the menu.
 
std::string title () const
 Get the title of the menu.
 
int title_length () const
 Get the size of the buffer for the title.
 
void add_about_to_be_shown_listener (AboutToBeShownListener *listener)
 Add listener triggered when a menu is about to be shown. More...
 
void remove_about_to_be_shown_listener (AboutToBeShownListener *listener)
 Remover listener triggered when a menu is about to be shown. More...
 
void add_has_been_hidden_listener (HasBeenHiddenListener *listener)
 Add listener triggered when a menu is hidden. More...
 
void remove_has_been_hidden_listener (HasBeenHiddenListener *listener)
 Remove listener triggered when a menu is about to be shown. More...
 
void add_submenu_listener (SubMenuListener *listener)
 Add listener for mouse moving over the menu arrow when no other toolbox event is assosiated 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 assosiated 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...
 
- Public Member Functions inherited from tbx::Object
 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...
 

Additional Inherited Members

- Protected Member Functions inherited from tbx::Object
 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 inherited from tbx::Object
ObjectId _handle
 Handle for toolbox object.
 

Detailed Description

Class representing a toolbox menu.

Constructor & Destructor Documentation

◆ Menu() [1/4]

tbx::Menu::Menu ( )
inline

Construct an uninitiased menu.

The menu should not be used until it has been initialised by assigning it to another initialised menu.

◆ Menu() [2/4]

tbx::Menu::Menu ( const Menu other)
inline

Construct a menu from another menu.

Both menus will refer to the same underlying toolbox menu

◆ Menu() [3/4]

tbx::Menu::Menu ( const Object other)
inline

Construct a menu from another toolbox object.

The menu and the object will refer to the same underlying toolbox menu

Exceptions
ObjectClassErrorThe object assigned to does not refer to a toolbox menu

◆ Menu() [4/4]

tbx::Menu::Menu ( const char *  template_name)
inline

Create the toolbox object with the given name from the Toolbox resources for the application and assign a reference to it to this application.

Exceptions
OsErrorThe toolbox object could not be created from the tmeplate
ObjectClassErrorThe created object is not a Toolbox menu

Member Function Documentation

◆ add()

MenuItem tbx::Menu::add ( const res::ResMenuItem res_item,
MenuItem after = 0 
)

Add a new menu entry to the menu.

If the component id of the menu item definition is set to -1 then the lowest available component id is used.

Parameters
res_itemdefinition of new entry.
afteritem to add it after or 0 (the default) to add to end of the menu
Returns
MenuItem added
Exceptions
OsErroradd failed.

◆ add_about_to_be_shown_listener()

void tbx::Menu::add_about_to_be_shown_listener ( AboutToBeShownListener listener)

Add listener triggered when a menu is about to be shown.

This event is only triggered if the menu has been set to deliver the default event before showing.

Parameters
listenerto add

◆ add_has_been_hidden_listener()

void tbx::Menu::add_has_been_hidden_listener ( HasBeenHiddenListener listener)

Add listener triggered when a menu is hidden.

This event is only triggered if the menu has been set to deliver the default event when hidden.

Parameters
listenerto add

◆ add_selection_listener()

void tbx::Menu::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.

This will be called for any menu item that has no other event associated with it. (including those with their own menu selection listener).

Parameters
listenerto add

◆ add_submenu_listener()

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

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

Parameters
listenerto add

◆ erase() [1/2]

void tbx::Menu::erase ( ComponentId  id)

Erase the menu item with the given id.

Exceptions
OsErrorerase failed.

◆ erase() [2/2]

void tbx::Menu::erase ( MenuItem item)

Erase the menu item given.

Sets item to uninitialised state.

Exceptions
OsErrorerase failed.

◆ insert()

MenuItem tbx::Menu::insert ( const res::ResMenuItem res_item,
MenuItem before = 0 
)

Insert a new menu entry in the menu.

If the component id of the menu item definition is set to -1 then the lowest available component id is used.

Parameters
res_itemdefinition of new entry.
beforeitem to insert it before or 0 (the default) to insert at the beginning of the menu
Returns
MenuItem inserted
Exceptions
OsErrorinsert failed.

◆ item()

MenuItem tbx::Menu::item ( ComponentId  id)

Retrieve the menu item for a given component id.

Note: There is no check the id is valid.

◆ operator!=()

bool tbx::Menu::operator!= ( const Object other) const
inline

Checks if this menu refers to the same underlying toolbox object as the given object.

Returns
true if the menu and object do not refer to the same thing.

◆ operator=() [1/2]

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

Assign a menu to an existing menu.

Both menus will refer to the same underlying toolbox menu

◆ operator=() [2/2]

Menu& tbx::Menu::operator= ( const Object other)
inline

Assign a menu to an existing object.

The menu and the object will refer to the same underlying toolbox menu

Exceptions
ObjectClassErrorThe object assigned to does not refer to a toolbox menu

◆ operator==()

bool tbx::Menu::operator== ( const Object other) const
inline

Checks if this menu refers to the same underlying toolbox object as the given object.

Returns
true if the menu and object refer to the same thing.

◆ remove_about_to_be_shown_listener()

void tbx::Menu::remove_about_to_be_shown_listener ( AboutToBeShownListener listener)

Remover listener triggered when a menu is about to be shown.

Parameters
listenerto remove

◆ remove_has_been_hidden_listener()

void tbx::Menu::remove_has_been_hidden_listener ( HasBeenHiddenListener listener)

Remove listener triggered when a menu is about to be shown.

Parameters
listenerto remove

◆ remove_selection_listener()

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

Remove menu selection listener.

Parameters
listenerto remove

◆ remove_submenu_listener()

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

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

Parameters
listenerto remove

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