Definition and manager for menu. More...
#include <mgui/menu.h>

Public Types | |
| enum | CREATEITEM { CREATEITEM_Default = 0, CREATEITEM_Check = 0x0001, CREATEITEM_CheckOn = 0x0009, CREATEITEM_Radio = 0x0002, CREATEITEM_RadioOn = 0x000A, CREATEITEM_RadioFirst = 0x0004, CREATEITEM_RadioFirstOn = 0x000C, CREATEITEM_ToggleOn = 0x0008, CREATEITEM_Disabled = 0x0010, CREATEITEM_NoDelegate = 0x0020, CREATEITEM_MI_Internal = 0x0040, CREATEITEM_MI_Programmer = 0x0080, CREATEITEM_Hidden = 0x0100 } |
| typedef fastdelegate::FastDelegate < void(MGUI::ID, bool)> | DELEGATE |
| typedef fastdelegate::FastDelegate < void(INT32)> | DELEGATE_ONWHEEL |
| enum | ITEMHND { ITEMHND_None = -1, ITEMHND_Last = -2 } |
| enum | POPUP { POPUP_AlignLeft = 0x0001, POPUP_AlignCenter = 0x0002, POPUP_AlignRight = 0x0004, POPUP_MouseLeft = 0x0010, POPUP_MouseRight = 0x0020, POPUP_MouseEither = 0x0030, POPUP_Default = POPUP_AlignLeft | POPUP_MouseEither } |
| enum | TYPE { TYPE_MenuBar, TYPE_SubMenu, TYPE_Popup } |
Public Member Functions | |
| MENU (const MENU &rhs) | |
| MENU () | |
| ~MENU () | |
| ITEMHND | Add (ICONID iconid, const MISTRING &label, MENU &submenu, CREATEITEM createflags=CREATEITEM_Default, ITEMHND hndInsertAfter=ITEMHND_Last, UINT32 icid=0) |
| ITEMHND | Add (const MISTRING &label, MENU &submenu, CREATEITEM createflags=CREATEITEM_Default, ITEMHND hndInsertAfter=ITEMHND_Last, UINT32 icid=0) |
| ITEMHND | Add (ICONID iconid, const MISTRING &label, MGUI::MENU::DELEGATE delegate, ID id=0, CREATEITEM createflags=CREATEITEM_Default, ITEMHND hndInsertAfter=ITEMHND_Last, UINT32 icid=0) |
| ITEMHND | Add (const MISTRING &label, MGUI::MENU::DELEGATE delegate, ID id=0, CREATEITEM createflags=CREATEITEM_Default, ITEMHND hndInsertAfter=ITEMHND_Last, UINT32 icid=0) |
| ITEMHND | Add (ICONID iconid, const MISTRING &label, ID id, CREATEITEM createflags=CREATEITEM_Default, ITEMHND hndInsertAfter=ITEMHND_Last, UINT32 icid=0) |
| ITEMHND | Add (const MISTRING &label, ID id, CREATEITEM createflags=CREATEITEM_Default, ITEMHND hndInsertAfter=ITEMHND_Last, UINT32 icid=0) |
| ITEMHND | AddSeparator (ITEMHND hndInsertAfter=ITEMHND_Last) |
| ITEMHND | AddSpaceFixed (int space, ITEMHND hndInsertAfter=ITEMHND_Last) |
| void | Create (TYPE type, MGUI::MENU::DELEGATE delegate) |
| void | Create (TYPE type) |
| void | Delete (ITEMHND hndItem) |
| void | DeleteAll () |
| bool | GetToggleState (ITEMHND hndItem) const |
| bool | GetToggleStateID (ID id) const |
| bool | IsCreated () const |
| bool | IsEmpty () const |
| MENU & | operator= (const MENU &rhs) |
| ID | Popup (CTRL &ctrl, const MGUI::POINT &point, POPUP popupflags=POPUP_Default) |
| ID | Popup (CTRL &ctrl, const LPOINT2D &point, POPUP popupflags=POPUP_Default) |
| void | SetDelegate (ID id, DELEGATE delegate) |
| void | SetDelegateOnPointerWheel (DELEGATE_ONWHEEL delegate) |
| void | SetEnabled (ITEMHND hndItem, bool enabled) |
| void | SetEnabledAll (bool enabled) |
| void | SetEnabledID (ID id, bool enabled) |
| void | SetLabel (ITEMHND hndItem, const MISTRING &label) |
| void | SetLabelID (ID id, const MISTRING &label) |
| void | SetToggleState (ITEMHND hndItem, bool ToggleOn, bool notify) |
| void | SetToggleStateID (ID id, bool ToggleOn, bool notify) |
| void | SetVisible (ITEMHND hndItem, bool visible) |
| void | SetVisibleID (ID id, bool visible) |
Static Public Member Functions | |
| static CREATEITEM | CREATEITEM_CheckSet (bool ToggleOn) |
| static CREATEITEM | CREATEITEM_RadioSet (bool ToggleOn, bool RadioFirst=false) |
Definition and manager for menu.
To create a menubar and attach to a shell:
int MYSHELL::v_CreateContent ( ) { // Create File menu (all choices call same delegate) MGUI::MENU MenuFile; MenuFile.Create(MGUI::MENU::TYPE_SubMenu,MGUI::MENU::DELEGATE(this,&MYSHELL::OnMenuFile)); MenuFile.Add(TEXTID_Generic_New,ID_FileNew); MenuFile.Add(TEXTID_Generic_Open,ID_FileOpen); ... MenuFile.Add(TEXTID_Generic_Exit,ID_FileExit); // Create View menu (each choice calls different delegate) MGUI::MENU MenuView; MenuView.Create(MGUI::MENU::TYPE_SubMenu); MenuView.Add(TEXTID_Generic_ZoomIn,MGUI::MENU::DELEGATE(this,&MYSHELL::OnMenuViewZoomIn)); MenuView.Add(TEXTID_Generic_ZoomOut,MGUI::MENU::DELEGATE(this,&MYSHELL::OnMenuViewZoomOut)); MenuView.Add(TEXTID_Generic_ZoomFull,MGUI::MENU::DELEGATE(this,&MYSHELL::OnMenuViewZoomFull)); // Create the menubar MGUI::MENU MenuBar; MenuBar.Create(MGUI::MENU::TYPE_MenuBar); MenuBar.Add(TEXTID_Generic_File,MenuFile); MenuBar.Add(TEXTID_Generic_View,MenuView); // Attach menubar to shell AttachMenuBar(menubar); return (TRUE); }
Note, MENU instances are reference-counted to allow enabling/disabling of menu items after actual control creation. For this reason, program must not attempt to use the same MENU instance in more then one control or shell.
| typedef fastdelegate::FastDelegate<void(MGUI::ID,bool)> MGUI::MENU::DELEGATE |
Delegate for selection from menu.
Values passed to delegate are ID and toggle state. If item is not a toggle the state will always be 'true'.
| typedef fastdelegate::FastDelegate<void(INT32)> MGUI::MENU::DELEGATE_ONWHEEL |
Delegate for mouse wheel movement on the menu Can be used to change state of the menu (TYPE_Popup).
Flags for use when adding items to menu.
| enum MGUI::MENU::ITEMHND |
| enum MGUI::MENU::POPUP |
Flags for Popup().
| enum MGUI::MENU::TYPE |
Menu types.
| TYPE_MenuBar |
Menubar for use in SHELL. |
| TYPE_SubMenu |
Submenu to add to menubar or another submenu. |
| TYPE_Popup |
Pop-up menu. |
| MGUI::MENU::MENU | ( | ) |
Default constructor.
| MGUI::MENU::MENU | ( | const MENU & | rhs | ) |
Copy constructor.
| MGUI::MENU::~MENU | ( | ) |
Destructor.
| ITEMHND MGUI::MENU::Add | ( | ICONID | iconid, | |
| const MISTRING & | label, | |||
| MENU & | submenu, | |||
| CREATEITEM | createflags = CREATEITEM_Default, |
|||
| ITEMHND | hndInsertAfter = ITEMHND_Last, |
|||
| UINT32 | icid = 0 | |||
| ) |
Add submenu item, with icon and label.
| iconid | Icon ID | |
| label | Label | |
| submenu | Submenu to add | |
| hndInsertAfter | Handle for item to insert after, ITEMHND_Last to insert at end | |
| icid | Interface customization ID |
| ITEMHND MGUI::MENU::Add | ( | const MISTRING & | label, | |
| MENU & | submenu, | |||
| CREATEITEM | createflags = CREATEITEM_Default, |
|||
| ITEMHND | hndInsertAfter = ITEMHND_Last, |
|||
| UINT32 | icid = 0 | |||
| ) |
Add submenu item, with label.
| label | Label | |
| submenu | Submenu to add | |
| hndInsertAfter | Handle for item to insert after, ITEMHND_Last to insert at end | |
| icid | Interface customization ID |
| ITEMHND MGUI::MENU::Add | ( | ICONID | iconid, | |
| const MISTRING & | label, | |||
| MGUI::MENU::DELEGATE | delegate, | |||
| ID | id = 0, |
|||
| CREATEITEM | createflags = CREATEITEM_Default, |
|||
| ITEMHND | hndInsertAfter = ITEMHND_Last, |
|||
| UINT32 | icid = 0 | |||
| ) |
Add item to the menu, with icon, label and specified delegate.
| iconid | Icon ID | |
| label | Label for item | |
| delegate | Delegate to call | |
| id | Optional application-defined ID to be passed to delegate | |
| hndInsertAfter | Handle for item to insert after, ITEMHND_Last to insert at end | |
| icid | Interface customization ID |
| ITEMHND MGUI::MENU::Add | ( | const MISTRING & | label, | |
| MGUI::MENU::DELEGATE | delegate, | |||
| ID | id = 0, |
|||
| CREATEITEM | createflags = CREATEITEM_Default, |
|||
| ITEMHND | hndInsertAfter = ITEMHND_Last, |
|||
| UINT32 | icid = 0 | |||
| ) |
Add item to the menu, with label and specified delegate.
| label | Label for item | |
| delegate | Delegate to call | |
| id | Optional application-defined ID to be passed to delegate | |
| hndInsertAfter | Handle for item to insert after, ITEMHND_Last to insert at end | |
| icid | Interface customization ID |
| ITEMHND MGUI::MENU::Add | ( | ICONID | iconid, | |
| const MISTRING & | label, | |||
| ID | id, | |||
| CREATEITEM | createflags = CREATEITEM_Default, |
|||
| ITEMHND | hndInsertAfter = ITEMHND_Last, |
|||
| UINT32 | icid = 0 | |||
| ) |
Add item to the menu, with icon, label and default delegate.
| iconid | Icon ID | |
| label | Label for item | |
| id | Application-defined ID to be passed to default delegate | |
| hndInsertAfter | Handle for item to insert after, ITEMHND_Last to insert at end | |
| icid | Interface customization ID |
| ITEMHND MGUI::MENU::Add | ( | const MISTRING & | label, | |
| ID | id, | |||
| CREATEITEM | createflags = CREATEITEM_Default, |
|||
| ITEMHND | hndInsertAfter = ITEMHND_Last, |
|||
| UINT32 | icid = 0 | |||
| ) |
Add item to the menu, with label and default delegate.
| label | Label for item | |
| id | Application-defined ID to be passed to default delegate | |
| hndInsertAfter | Handle for item to insert after, ITEMHND_Last to insert at end | |
| icid | Interface customization ID |
Add separator to menu.
| hndInsertAfter | Handle for item to insert after, ITEMHND_Last to insert at end |
Add fixed space to menu.
| space | Space in pixels to add | |
| hndInsertAfter | Handle for item to insert after, ITEMHND_Last to insert at end |
| void MGUI::MENU::Create | ( | TYPE | type, | |
| MGUI::MENU::DELEGATE | delegate | |||
| ) |
Create menu definition with specified default delegate.
May be called on previously created menu to reuse class instance.
| type | Type of menu to create | |
| delegate | Default delegate to use for items when none specified |
| void MGUI::MENU::Create | ( | TYPE | type | ) |
Create menu definition.
This does not actually create the interface controls, that is usually done using MGUI::SHELL or Popup(). May be called on previously created menu to reuse class instance.
| type | Type of menu to create |
| static CREATEITEM MGUI::MENU::CREATEITEM_CheckSet | ( | bool | ToggleOn | ) | [inline, static] |
Convenience method to get CREATEITEM flag for check item with control of whether initially on.
| static CREATEITEM MGUI::MENU::CREATEITEM_RadioSet | ( | bool | ToggleOn, | |
| bool | RadioFirst = false | |||
| ) | [inline, static] |
Convenience method to get CREATEITEM flag for radio item with control of whether initially on.
| void MGUI::MENU::Delete | ( | ITEMHND | hndItem | ) |
Delete item from menu.
| hndItem | Handle for item to delete |
| void MGUI::MENU::DeleteAll | ( | ) |
Delete all items from menu.
| bool MGUI::MENU::GetToggleState | ( | ITEMHND | hndItem | ) | const |
Get state of Check or Radio item.
Will return false if not a toggle item.
| hndItem | Handle returned by Append() |
| bool MGUI::MENU::GetToggleStateID | ( | ID | id | ) | const |
Get state of Check or Radio item.
Will return false if not a toggle item.
| id | ID of item |
| bool MGUI::MENU::IsCreated | ( | ) | const [inline] |
Determine if has been created.
| bool MGUI::MENU::IsEmpty | ( | ) | const |
Determine if menu is empty.
| ID MGUI::MENU::Popup | ( | CTRL & | ctrl, | |
| const MGUI::POINT & | point, | |||
| POPUP | popupflags = POPUP_Default | |||
| ) |
Display a popup menu and wait for user to make selection.
| ctrl | Control which invoked popup action | |
| point | Point where menu is to appear, relative to specified control | |
| popupflags | Flags for positioning and selection |
Display a popup menu and wait for user to make selection.
| ctrl | Control which invoked popup action | |
| point | Point where menu is to appear, relative to specified control | |
| popupflags | Flags for positioning and selection |
Set delegate for existing item ID.
| id | ID of item | |
| delegate | Delegate to set |
| void MGUI::MENU::SetDelegateOnPointerWheel | ( | DELEGATE_ONWHEEL | delegate | ) |
Set delegate for existing menu when the pointer's wheel moves.
| delegate | Delegate to set |
| void MGUI::MENU::SetEnabled | ( | ITEMHND | hndItem, | |
| bool | enabled | |||
| ) |
Set whether item is enabled or not, using ITEMHND.
| hndItem | Handle returned by Append() | |
| enabled | true to enable, false to disable |
| void MGUI::MENU::SetEnabledAll | ( | bool | enabled | ) |
Set whether all items enabled or not.
| enabled | true to enable, false to disable |
| void MGUI::MENU::SetEnabledID | ( | ID | id, | |
| bool | enabled | |||
| ) |
Set whether item is enabled or not, using ID.
| id | ID of item(s) to enable | |
| enabled | true to enable, false to disable |
Set menu item label, referenced by ITEMHND.
| hndItem | Handle returned by Append() | |
| label | Label |
Set menu item label, referenced by ID.
| id | ID of item(s) to show | |
| label | Label |
| void MGUI::MENU::SetToggleState | ( | ITEMHND | hndItem, | |
| bool | ToggleOn, | |||
| bool | notify | |||
| ) |
Set state of toggle item by ITEMHND.
If item is a "radio" button, previously selected item will be toggled off.
| hndItem | Handle returned by Append() | |
| ToggleOn | True to toggle on, false to toggle off | |
| notify | Invoke delegate if state changed |
| void MGUI::MENU::SetToggleStateID | ( | ID | id, | |
| bool | ToggleOn, | |||
| bool | notify | |||
| ) |
Set state of toggle item by ID.
If item is a "radio" button, previously selected item will be toggled off.
| id | ID of item | |
| ToggleOn | True to toggle on, false to toggle off | |
| notify | Invoke delegate if state changed |
| void MGUI::MENU::SetVisible | ( | ITEMHND | hndItem, | |
| bool | visible | |||
| ) |
Set whether item is visible or not, using ITEMHND.
| hndItem | Handle returned by Append() | |
| visible | true to show, false to hide |
| void MGUI::MENU::SetVisibleID | ( | ID | id, | |
| bool | visible | |||
| ) |
Set whether item is visible or not, using ID.
| id | ID of item(s) to show | |
| visible | true to show, false to hide |
1.6.1