class MASKING_DLL_DECLSPEC Menu

The Menu widget class.

Inheritance:

Menu - Dialog - Widget - Rect


Public Methods

[more]void HandleEvent(Widget& obj, int msg, int arg1=0, int arg2=0)
Handles events such as keyboard input, menu item clicks, etc
[more]virtual void Add(MenuItem* item)
Adds an existing menu item to the bottom of the menu
[more]virtual void Add(const char* text, Menu &child)
Creates a new menu item with a submenu and adds it to the bottom of the menu
[more]virtual void Add(const char* text = NULL, int id = 0)
Creates a new menu item with a message ID and adds it to the bottom of the menu
[more]virtual void Remove(int i)
Removes item i from the menu item list.
[more]virtual void RemoveByID(int ID)
Removes the item with the given callback ID
[more]virtual MenuItem* GetItem(int i)
Returns a pointer to menu item i from the menu item list
[more]virtual int GetItemByID(int ID)
Finds and returns the index of the menu item with the given callback ID.
[more]virtual void Enable(int i)
Enables item i
[more]virtual void Disable(int i)
Disables item i.
[more]virtual void Check(int i)
Checks item i.
[more]virtual void Uncheck(int i)
Unchecks item i
[more]virtual bool Disabled(int i)
Checks whether item i is disabled or not
[more]virtual bool Checked(int i)
Checks whether item i is checked or not
[more]virtual void Popup(Dialog* parentDialog, MenuItem* parentMenu, int x, int y)
[more]virtual void Popup(Dialog* parentDialog, MenuItem* parentMenu, const Point &p)
Pops up a menu at the given position.
[more]virtual void Close()
Closes a menu that was popped up with Popup().

Protected Fields

[more]Panel back
The menu's background panel
[more]bool topBar
True if the menu is a top bar menu
[more]MenuItem* parentMenu
The menu's parent menu if any
[more]Menu* openChildMenu
The currently open child menu if any

Protected Methods

[more]void MsgInitSkin()
Initilizes the menu with the default bitmaps, fonts and font colours as defined by the skin
[more]bool MsgXChar(int x)
Hnadles menu shortcuts (Alt + key) even when the menu doesn't have input focus
[more]bool MsgChar(int c)
Hnadles submenu shortcuts
[more]void MsgLostmouse()
Closes a popup menu after it has lost the mouse
[more]void UpdateSize()
Calculates the size of the menu and applies it.
[more]bool MouseInMenu()
Checks if the mouse is on top of the menu or a parent menu (recursively)
[more]bool MouseInChildMenu()
Recursively checks if the mouse is on top of any of the menu's child menus
[more]void OpenChildMenu(MenuItem* item)
Pops up the item's child menu
[more]void CloseChildMenu()
Closes the currently open child menu
[more]Menu* GetRootMenu()
Returns a pointer to the root menu of the menu structure
[more]int MenuAltKey(int k)
Looks for a shortcut in the menu item list.
[more]bool MenuKeyShortcut(int c, const char* s)
Checks whether the string s contains shortcut c.
[more]ActionType GetAction()
Makes sure a menu can't be moved
[more]void MoveFocus(int dir)
Moves the input focus around the menu in the given direction


Documentation

The Menu widget class.

Implements the entire menu system. A menu can be a top bar menu or a popup menu. Every menu item can have either a submenu that pops up when the item is selected or an message ID which is sent to the parent dialog when the item is selected.

Note: menu navigation with keyboard hasn't yet been implemented!

oPanel back
The menu's background panel

obool topBar
True if the menu is a top bar menu

oMenuItem* parentMenu
The menu's parent menu if any

oMenu* openChildMenu
The currently open child menu if any

ovoid MsgInitSkin()
Initilizes the menu with the default bitmaps, fonts and font colours as defined by the skin

obool MsgXChar(int x)
Hnadles menu shortcuts (Alt + key) even when the menu doesn't have input focus

obool MsgChar(int c)
Hnadles submenu shortcuts

ovoid MsgLostmouse()
Closes a popup menu after it has lost the mouse

ovoid UpdateSize()
Calculates the size of the menu and applies it. The height of a single menu item is defined by the skin while the width of the menu is the width of the widest menu item.

obool MouseInMenu()
Checks if the mouse is on top of the menu or a parent menu (recursively)

obool MouseInChildMenu()
Recursively checks if the mouse is on top of any of the menu's child menus

ovoid OpenChildMenu(MenuItem* item)
Pops up the item's child menu

ovoid CloseChildMenu()
Closes the currently open child menu

oMenu* GetRootMenu()
Returns a pointer to the root menu of the menu structure

oint MenuAltKey(int k)
Looks for a shortcut in the menu item list. If it finds an item with the given shortcut it returns the shortcuts ASCII code otherwise it returns 0.

obool MenuKeyShortcut(int c, const char* s)
Checks whether the string s contains shortcut c. Shortcut is the character prefixed with '&' if any.

oActionType GetAction()
Makes sure a menu can't be moved

ovoid MoveFocus(int dir)
Moves the input focus around the menu in the given direction

ovoid HandleEvent(Widget& obj, int msg, int arg1=0, int arg2=0)
Handles events such as keyboard input, menu item clicks, etc

ovirtual void Add(MenuItem* item)
Adds an existing menu item to the bottom of the menu

ovirtual void Add(const char* text, Menu &child)
Creates a new menu item with a submenu and adds it to the bottom of the menu

ovirtual void Add(const char* text = NULL, int id = 0)
Creates a new menu item with a message ID and adds it to the bottom of the menu

ovirtual void Remove(int i)
Removes item i from the menu item list. If the menu created the menu item it will delete it as well but if you created it yourself, you have take care of destroying it.

ovirtual void RemoveByID(int ID)
Removes the item with the given callback ID

ovirtual MenuItem* GetItem(int i)
Returns a pointer to menu item i from the menu item list

ovirtual int GetItemByID(int ID)
Finds and returns the index of the menu item with the given callback ID. If the item with the requested ID isn't find this function returns -1.

ovirtual void Enable(int i)
Enables item i

ovirtual void Disable(int i)
Disables item i. Disabled items are greyed out and can't be selected.

ovirtual void Check(int i)
Checks item i. Checked items usually have a little checkmark drawn on their right side (that depends on the skin).

ovirtual void Uncheck(int i)
Unchecks item i

ovirtual bool Disabled(int i)
Checks whether item i is disabled or not

ovirtual bool Checked(int i)
Checks whether item i is checked or not

ovirtual void Popup(Dialog* parentDialog, MenuItem* parentMenu, int x, int y)

ovirtual void Popup(Dialog* parentDialog, MenuItem* parentMenu, const Point &p)
Pops up a menu at the given position. You have to pass the menu's parent dialog (i.e. the dialog from where or on top of which the menu was popped up) and the menu's parent menu if any (usually NULL). Note that Popup() doesn't block the program but instead just adds the menu to the parent dialog and then execution continues in that dialog's main loop.

ovirtual void Close()
Closes a menu that was popped up with Popup(). You shouldn't normally have to call this as a menu closes itself when it loses focus.


This class has no child classes.
Friends:
class MASKING_DLL_DECLSPEC MenuItem
See Also:
MenuItem

Alphabetic index Hierarchy of classes


Back to front page   |   page generated with DOC++