MGUI::MENU Class Reference

Definition and manager for menu. More...

#include <mgui/menu.h>

Inheritance diagram for MGUI::MENU:
Inheritance graph
[legend]

List of all members.

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
MENUoperator= (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)

Detailed Description

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.


Member Typedef Documentation

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).


Member Enumeration Documentation

Flags for use when adding items to menu.

Enumerator:
CREATEITEM_Default 
CREATEITEM_Check 

Create with check style, cannot be combined with CREATEITEM_Radio.

CREATEITEM_CheckOn 

Create with check style, initially toggled on.

CREATEITEM_Radio 

Create with radio style, cannot be combined with CREATEITEM_Check.

CREATEITEM_RadioOn 

Create with radio style, initially toggled on.

CREATEITEM_RadioFirst 

First item in new radio group, implies radio style, only need if multiple radio groups.

CREATEITEM_RadioFirstOn 

First item in new radio group, initially toggled on.

CREATEITEM_ToggleOn 

Create initially toggled on, requires CREATEITEM_Check or CREATEITEM_Radio.

CREATEITEM_Disabled 

Create initially disabled.

CREATEITEM_NoDelegate 

Create item with no delegate, use when menu has default delegate if want label.

CREATEITEM_MI_Internal 

Only create if MicroImages internal license.

CREATEITEM_MI_Programmer 

Only create if MicroImages programmer license.

CREATEITEM_Hidden 

Create item initially hidden.

Menu item handle.

Enumerator:
ITEMHND_None 
ITEMHND_Last 

Flags for Popup().

Enumerator:
POPUP_AlignLeft 

Align left side of menu with specified X coordinate.

POPUP_AlignCenter 

Align center of menu horizontally with specified X coordinate.

POPUP_AlignRight 

Align right side of menu with specified X coordinate.

POPUP_MouseLeft 

Allow selection via left mouse button.

POPUP_MouseRight 

Allow selection via right mouse button.

POPUP_MouseEither 

Allow selection via either mouse button.

POPUP_Default 

Menu types.

Enumerator:
TYPE_MenuBar 

Menubar for use in SHELL.

TYPE_SubMenu 

Submenu to add to menubar or another submenu.

TYPE_Popup 

Pop-up menu.


Constructor & Destructor Documentation

MGUI::MENU::MENU (  ) 

Default constructor.

MGUI::MENU::MENU ( const MENU rhs  ) 

Copy constructor.

MGUI::MENU::~MENU (  ) 

Destructor.


Member Function Documentation

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.

Returns:
Handle to item for subsequent reference, will be < 0 if error
Parameters:
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.

Returns:
Handle to item for subsequent reference, will be < 0 if error
Parameters:
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.

Returns:
Handle to item for subsequent reference, will be < 0 if error
Parameters:
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.

Returns:
Handle to item for subsequent reference, will be < 0 if error
Parameters:
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.

Returns:
Handle to item for subsequent reference, will be < 0 if error
Parameters:
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.

Returns:
Handle to item for subsequent reference, will be < 0 if error
Parameters:
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::AddSeparator ( ITEMHND  hndInsertAfter = ITEMHND_Last  ) 

Add separator to menu.

Parameters:
hndInsertAfter Handle for item to insert after, ITEMHND_Last to insert at end
ITEMHND MGUI::MENU::AddSpaceFixed ( int  space,
ITEMHND  hndInsertAfter = ITEMHND_Last 
)

Add fixed space to menu.

Parameters:
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.

Parameters:
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.

Parameters:
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.

Parameters:
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.

Parameters:
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.

Parameters:
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.

MENU& MGUI::MENU::operator= ( const MENU rhs  ) 

Assignment.

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.

Returns:
ID of selected item if no delegate was called, 0 if delegate called or no selection made.
Parameters:
ctrl Control which invoked popup action
point Point where menu is to appear, relative to specified control
popupflags Flags for positioning and selection
ID MGUI::MENU::Popup ( CTRL ctrl,
const LPOINT2D point,
POPUP  popupflags = POPUP_Default 
)

Display a popup menu and wait for user to make selection.

Returns:
ID of selected item if no delegate was called, 0 if delegate called or no selection made.
Parameters:
ctrl Control which invoked popup action
point Point where menu is to appear, relative to specified control
popupflags Flags for positioning and selection
void MGUI::MENU::SetDelegate ( ID  id,
DELEGATE  delegate 
)

Set delegate for existing item ID.

Parameters:
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.

Parameters:
delegate Delegate to set
void MGUI::MENU::SetEnabled ( ITEMHND  hndItem,
bool  enabled 
)

Set whether item is enabled or not, using ITEMHND.

Parameters:
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.

Parameters:
enabled true to enable, false to disable
void MGUI::MENU::SetEnabledID ( ID  id,
bool  enabled 
)

Set whether item is enabled or not, using ID.

Parameters:
id ID of item(s) to enable
enabled true to enable, false to disable
void MGUI::MENU::SetLabel ( ITEMHND  hndItem,
const MISTRING label 
)

Set menu item label, referenced by ITEMHND.

Parameters:
hndItem Handle returned by Append()
label Label
void MGUI::MENU::SetLabelID ( ID  id,
const MISTRING label 
)

Set menu item label, referenced by ID.

Parameters:
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.

Parameters:
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.

Parameters:
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.

Parameters:
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.

Parameters:
id ID of item(s) to show
visible true to show, false to hide

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

Generated on Sun Oct 7 21:36:12 2012 for TNTsdk 2012 by  doxygen 1.6.1