Om
1.0.0
A universal framework for multimedia simulation
|
A class that represents a single item of a drop-down GUI menu. More...
#include <omGUIMenuItem.h>
Classes | |
class | Delegate |
A class that contains function objects that recieve menu item events. More... | |
Public Types | |
enum | Type { NORMAL = 0, MENU, SEPARATOR } |
An enum type that specifies special kinds of menu items. More... | |
Public Member Functions | |
MenuItem (Type newType=NORMAL) | |
Create a new menu item with the specified specialized type. More... | |
MenuItem (const UTF8String &name) | |
Create a new normal menu item with the specified name string and no keyboard shortcut. More... | |
MenuItem (const UTF8String &name, const input::KeyShortcut &shortcut, Bool isEnabled=true) | |
Create a new normal menu item with the specified name string and keyboard shortcut. More... | |
MenuItem (const UTF8String &name, Menu *menu, Bool isEnabled=true) | |
Create a new submenu menu item which uses the specified menu as a submenu. More... | |
MenuItem (Menu *menu) | |
Create a new submenu menu item which uses the specified menu as a submenu. More... | |
~MenuItem () | |
Destroy a menu item and release all internal state. More... | |
Bool | hasMenu () const |
Return whether or not this menu item has a child menu associated with it. More... | |
Menu * | getMenu () const |
Return a pointer to the child menu associated with this menu item. More... | |
Bool | setMenu (Menu *newSubmenu) |
Set the child menu which should be associated with this menu item. More... | |
void | removeMenu () |
Remove any child menu that was associated with this menu item. More... | |
const input::KeyShortcut & | getKeyShortcut () const |
Return an object that describes the keyboard shortcut to use for this menu item. More... | |
Bool | setKeyShortcut (const input::KeyShortcut &shortcut) |
Set an object that describes the keyboard shortcut to use for this menu item. More... | |
UTF8String | getName () const |
Return a string representing the name of this menu item. More... | |
Bool | setName (const UTF8String &newName) |
Set a string that specifies a new name for this menu item. More... | |
const Delegate & | getDelegate () const |
Return a reference to the delegate object associated with this menu item. More... | |
void | setDelegate (const Delegate &delegate) |
Set the delegate object to which this menu item sends events. More... | |
Bool | getIsEnabled () const |
Return whether or not this menu item is currently able to be selected by the user. More... | |
Bool | setIsEnabled (Bool newIsEnabled) |
Set whether or not this menu item is be able to be selected by the user. More... | |
Bool | getIsChecked () const |
Return whether or not this menu item displays a check mark next to the item. More... | |
Bool | setIsChecked (Bool newIsChecked) |
Set whether or not this menu item displays a check mark next to the item. More... | |
Type | getType () const |
Return an enum value indicating the type of this menu item. More... | |
Menu * | getParentMenu () const |
Return a pointer to the menu that this menu item belongs to. More... | |
Bool | hasParentMenu () const |
Return whether or not this menu item is part of a menu. More... | |
virtual void * | getInternalPointer () const |
Get a pointer to this menu item's platform-specific internal representation. More... | |
Public Member Functions inherited from om::gui::objects::GUIObject | |
virtual | ~GUIObject () |
Destroy a GUI element and release all resources associated with it. More... | |
A class that represents a single item of a drop-down GUI menu.
An enum type that specifies special kinds of menu items.
Create a new menu item with the specified specialized type.
This constructor allows one to create menu items that represent special kinds of items - separators, etc - that aren't able to be represented easily another way.
om::gui::objects::MenuItem::MenuItem | ( | const UTF8String & | name | ) |
Create a new normal menu item with the specified name string and no keyboard shortcut.
This menu item is enabled by default.
om::gui::objects::MenuItem::MenuItem | ( | const UTF8String & | name, |
const input::KeyShortcut & | shortcut, | ||
Bool | isEnabled = true |
||
) |
Create a new normal menu item with the specified name string and keyboard shortcut.
This constructor allows one to specify if the menu item should be enabled or not. The default behavior if the parameter is ommitted is for the item to be enabled.
om::gui::objects::MenuItem::MenuItem | ( | const UTF8String & | name, |
Menu * | menu, | ||
Bool | isEnabled = true |
||
) |
Create a new submenu menu item which uses the specified menu as a submenu.
If the specified menu is NULL or if it already has a parent item or menu bar, the menu is not used and the submenu is unitialized.
om::gui::objects::MenuItem::MenuItem | ( | Menu * | menu | ) |
Create a new submenu menu item which uses the specified menu as a submenu.
If the specified menu is NULL or if it already has a parent item or menu bar, the menu is not used and the submenu is unitialized.
om::gui::objects::MenuItem::~MenuItem | ( | ) |
Destroy a menu item and release all internal state.
The destructor for a menu item should not be called until it is not being used as part of any active GUI.
Bool om::gui::objects::MenuItem::hasMenu | ( | ) | const |
Return whether or not this menu item has a child menu associated with it.
This method always returns FALSE is this menu item is a separator or a normal menu item.
Menu* om::gui::objects::MenuItem::getMenu | ( | ) | const |
Return a pointer to the child menu associated with this menu item.
If there is no such menu, or if this menu item's type doesn't allow it to have a child menu, a NULL pointer is returned.
Set the child menu which should be associated with this menu item.
If the specified menu pointer is NULL, this has the effect of clearing any existing child menu from this menu item. The method returns whether or not the menu set operation was successful - it can fail if this menu item is a separator or normal menu item, since they can't have child menus.
void om::gui::objects::MenuItem::removeMenu | ( | ) |
Remove any child menu that was associated with this menu item.
const input::KeyShortcut& om::gui::objects::MenuItem::getKeyShortcut | ( | ) | const |
Return an object that describes the keyboard shortcut to use for this menu item.
Bool om::gui::objects::MenuItem::setKeyShortcut | ( | const input::KeyShortcut & | shortcut | ) |
Set an object that describes the keyboard shortcut to use for this menu item.
The method returns whether or not the keyboard shortcut was accepted as being valid. A shortcut can fail validation if it uses a modifier key combination that is not valid or if the menu item has a type that does not support a keyboard shortcut.
UTF8String om::gui::objects::MenuItem::getName | ( | ) | const |
Return a string representing the name of this menu item.
If this item is a separator menu item, this method always returns an empty string.
Bool om::gui::objects::MenuItem::setName | ( | const UTF8String & | newName | ) |
Set a string that specifies a new name for this menu item.
If this item is a type of menu item that can't have a name (such as a separator), or if the name change operation is not successful, FALSE is returned. Otherwise, the name of the menu item is changed and TRUE is returned.
const Delegate& om::gui::objects::MenuItem::getDelegate | ( | ) | const |
Return a reference to the delegate object associated with this menu item.
void om::gui::objects::MenuItem::setDelegate | ( | const Delegate & | delegate | ) |
Set the delegate object to which this menu item sends events.
Bool om::gui::objects::MenuItem::getIsEnabled | ( | ) | const |
Return whether or not this menu item is currently able to be selected by the user.
Set whether or not this menu item is be able to be selected by the user.
The method returns whether or not the state of the menu item was able to be changed.
Bool om::gui::objects::MenuItem::getIsChecked | ( | ) | const |
Return whether or not this menu item displays a check mark next to the item.
Set whether or not this menu item displays a check mark next to the item.
The method returns whether or not the state of the menu item was able to be changed.
Type om::gui::objects::MenuItem::getType | ( | ) | const |
Return an enum value indicating the type of this menu item.
The type of a menu item is determined at construction and cannot be changed.
Menu* om::gui::objects::MenuItem::getParentMenu | ( | ) | const |
Return a pointer to the menu that this menu item belongs to.
This method returns a NULL pointer if the menu item doesn't have a parent menu. Use the hasParentMenu() function to detect if the menu item has a parent menu.
Bool om::gui::objects::MenuItem::hasParentMenu | ( | ) | const |
Return whether or not this menu item is part of a menu.
|
virtual |
Get a pointer to this menu item's platform-specific internal representation.
On Mac OS X, this method returns a pointer to a subclass of NSMenuItem which represents the menu item.
On Windows, this method is unused and returns NULL.
Implements om::gui::objects::GUIObject.