class MASKING_DLL_DECLSPEC MenuItem

Internal helper widget for making menu items.

Inheritance:

MenuItem - Widget - Rect


Public Methods

[more] MenuItem(const char* text, Menu* child)
The constructor for making a menu item with a child menu
[more] MenuItem(const char* text = NULL, int id = 0)
The constructor for making a menu item with a message ID.
[more]virtual char* GetText()
Returns the item's text
[more]virtual void SetText(const char* t)
Sets the item's text
[more]virtual int GetCallbackID()
Returns callbackID of the menu item
[more]virtual Menu* GetChildMenu()
Returns pointer to child menu if any

Protected Fields

[more]char* text
The item's text.
[more]Menu* child
A pointer to the menu item's child menu if any
[more]int callbackID
The ID of the message the item is to send to its parent menu when it is selected.
[more]bool topBar
True if the item is part of a top bar menu
[more]int delayTimer
A frame counter that help implement a short delay before a submenu automatically pops up when the mouse is on top of an item

Protected Methods

[more]void MsgInitSkin()
Initilizes the menu item with the default bitmaps, fonts and font colours as defined by the skin
[more]bool MsgWantfocus()
Returns true
[more]void MsgGotfocus()
Start the timer counter that counts frames and controls when a submenu automatically pops up
[more]void MsgLostfocus()
Stops the timer counter that counts frames and controls when a submenu automatically pops up
[more]void MsgLPress()
Handles mouse clicks with the left mouse button
[more]void MsgLRelease()
Handles mouse clicks with the left mouse button.
[more]void MsgTick()
Increments the frame counter and after a certain time has passed it pops up the child menu
[more]void MsgKey()
Handles keyboard input
[more]void Draw(Bitmap &canvas)
Draws the menu item
[more]void UpdateSize()
Resizes the item according to the length of the text
[more]bool MsgWantTab()
Returns false to prevent the menu items from being tabbed to


Documentation

Internal helper widget for making menu items.

MenuItem implements a single item of a complex menu. Every item may have either a child menu which pops up when the item is selected or after a certain time delay or a message ID which is sent to the parent menu when the item is selected.

ochar* text
The item's text. See above for a description of the text formatting.

oMenu* child
A pointer to the menu item's child menu if any

oint callbackID
The ID of the message the item is to send to its parent menu when it is selected. This should normally be above the normal GUI MSG_SOMETHING constants, for example MSG_SUSER+1, MSG_SUSER+2, etc.

obool topBar
True if the item is part of a top bar menu

oint delayTimer
A frame counter that help implement a short delay before a submenu automatically pops up when the mouse is on top of an item

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

obool MsgWantfocus()
Returns true

ovoid MsgGotfocus()
Start the timer counter that counts frames and controls when a submenu automatically pops up

ovoid MsgLostfocus()
Stops the timer counter that counts frames and controls when a submenu automatically pops up

ovoid MsgLPress()
Handles mouse clicks with the left mouse button

ovoid MsgLRelease()
Handles mouse clicks with the left mouse button.

When a menu item is clicked it either pops up its submenu or sends its callback message ID to the parent menu.

ovoid MsgTick()
Increments the frame counter and after a certain time has passed it pops up the child menu

ovoid MsgKey()
Handles keyboard input

ovoid Draw(Bitmap &canvas)
Draws the menu item

ovoid UpdateSize()
Resizes the item according to the length of the text

obool MsgWantTab()
Returns false to prevent the menu items from being tabbed to

o MenuItem(const char* text, Menu* child)
The constructor for making a menu item with a child menu

o MenuItem(const char* text = NULL, int id = 0)
The constructor for making a menu item with a message ID.

A menuitem may have a submenu or a mesage ID (or none of those but that's quite pointless). The text of a menu item is made of two parts separated with a horizontal tab character ('\t'). The first part is printed on the left part of the item while the other part is printed on the right. Usually the left part contains the name of a command or selection and the right part contains a description of the matching keyboard shortcut. Also the left part may contain a character that is prefixed with '&'. This character will then be underlined and will act as a quick shortcut for navigating the menu. For example the text "&New\tCtrl-N" will produce a menu item that will read "New Ctrl-N". If text is NULL, the menu item will be a separator.

ovirtual char* GetText()
Returns the item's text

ovirtual void SetText(const char* t)
Sets the item's text

ovirtual int GetCallbackID()
Returns callbackID of the menu item

ovirtual Menu* GetChildMenu()
Returns pointer to child menu if any


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

Alphabetic index Hierarchy of classes


Back to front page   |   page generated with DOC++