A class representing a menu item.
![]() | PMenuItem ( PSubMenu & menu, const PString & itemName, PMenuEntry * before = NULL ) Create a new menu items in the specified menu that has the specified name, accelerator key code and notification function. |
![]() | PMenuItem ( PRESOURCE_ID newID, PSubMenu & menu, const char * itemName, const PKeyCode & accel ) Helper constructor for when creating menu from a resource. |
![]() | ~PMenuItem () Destroy the menu item removing it from its owner menu. |
![]() | SetString ( const PString & str ) Set the string contents of the menu item. |
![]() | GetString () const Get the current string name of the menu entry. |
![]() | IsMenuItemCheckGroup (const PMenuItem& groupItem) const Determine if the menu entry is in a menu item check group. |
![]() | SetAccelerator ( const PKeyCode & accel ) Set the accelerator key code associated with the menu item. |
![]() | GetAccelerator () const Get the accelerator key code associated with the menu item. |
![]() | SetNotifier ( const PNotifier & notify, BOOL notifyForStateUpdate = FALSE ) Set the notification function associated with the menu item. |
![]() | GetNotifier () const Get the notification function associated with the menu item. |
![]() | WillNotifyOnStateUpdate () const Get the flag for notification function called when a menu item requires its enable or check state updated. |
![]() | Enable ( BOOL enabled = TRUE ) Enable or disable the menu item. |
![]() | Disable () Disable the menu item. |
![]() | IsEnabled () const Determine if the menu item is currently enabled or disabled. |
![]() | Check ( BOOL checked = TRUE ) Check or uncheck the menu item. |
![]() | Uncheck () Uncheck the menu item. |
![]() | IsChecked () const Determine if the menu item is currently checked or unchecked. |
![]() | SetCheckPointer ( BOOL * ptr ) Set the current check state value pointer associated with the menu item. |
![]() | GetCheckPointer () const Get the current check state value pointer associated with the menu item. |
![]() | SetGroupCheck ( PINDEX newItem ) Check this item, or the specified item, and uncheck all other items in the menu with the same notification function as this menu item. |
![]() | GetGroupCheck () const Get the index of the menu item that is checked in the set of items in the menu with the same notification function as this item. |
![]() | Construct ( BOOL setID ) Do the common initialisation of a menu item amongst the constructors. |
![]() | Overrides from class PMenuEntry |
![]() | New functions for class |
![]() | name Name of the menu item. |
![]() | accelerator Accelerator for the menu item. |
![]() | callback Notification function to call on menu selection. |
![]() | checkPointer Pointer to variable to contain the check state of the menu item. |
![]() | menuID Unique menu ID for resource binding |
![]() | notifyForStateUpdate Flag for notification function called when a menu item requires its enable or check state updated |
![]() | UpdateMyCommandSources () Scan through all menu items in the menu and execute their notification function to enable or disable and check or uncheck the menu item. |
![]() | New functions for class |
Overrides from PObject
Run Time Type functions
Comparison functions
I/O functions
Miscellaneous functions
A class representing a menu item.A menu item is a selectable command within a menu. The menu may carry with it a callback function which is executed when the menu item is selected. Also a menu item may have an
accelerator attached to it. This is a PKeyCode that represents a key that will execute the menu command when pressed.All menu items have a unique identifier across all items in a particular tree of menus, ie for a given PRootMenu class instance. The system will automatically guarentee this when menus are built manually. If they come from resources, they PWLib resource compiler takes this responsibility. If resources are generated in some other way then it is up to the programmer.
The menu name is processed for the special character '&' to place an underline attribute on the next character. To place an '&' itself into the string then two censecutive ampersands ("&&") must be used. The character in the string marked with the ampersand is the letter that selects the menu item when the menu selection operation is in progress, This is different from the accelerator which may be pressed at any time to select the menu item.
A menu may also be
enabled ordisabled . A disabled menu is visually distinct from an enabled menu item. This is also referred to as "greying" the menu item.A menu item may also have a
check mark next to it indicating a state for the menu item. The exact appearance is platform dependent.
The index numbers start with one for the first item with the same
notification function. A value of zero indicates no item is checked. This will give a similar functionality to a set of radio button
controls, setting one of mutually exclusive options.
The index numbers start with one for the first item with the same
notification function. A value of zero indicates no item is checked. This will give a similar functionality to a set of radio button
controls, setting one of mutually exclusive options.
For a menu item this calls the notification function if allowed by the
notifyForStateUpdate flag. This function is used internally by the library. It would normally not
be called directly.
PMenuItem( PRESOURCE_ID newID, PSubMenu & menu, const char * itemName, const PKeyCode & accel )
itemName - Name of the menu item.
accel - Key code for accelerator on menu function.virtual ~PMenuItem()
Overrides from class PMenuEntry
virtual void SetString( const PString & str )
virtual PString GetString() const
virtual BOOL IsMenuItemCheckGroup(const PMenuItem& groupItem) const
New functions for class
void SetAccelerator( const PKeyCode & accel )
PKeyCode GetAccelerator() const
void SetNotifier( const PNotifier & notify, BOOL notifyForStateUpdate = FALSE )
notifyForStateUpdate - Notification function is to be called when a menu item requires its
enable or check state updated. If FALSE the notification function is
only called when the item is selected.
const PNotifier& GetNotifier() const
BOOL WillNotifyOnStateUpdate() const
void Enable( BOOL enabled = TRUE )
void Disable()
BOOL IsEnabled() const
void Check( BOOL checked = TRUE )
void Uncheck()
BOOL IsChecked() const
void SetCheckPointer( BOOL * ptr )
BOOL* GetCheckPointer() const
void SetGroupCheck( PINDEX newItem )
PINDEX GetGroupCheck() const
New functions for class
void Construct( BOOL setID )
virtual void UpdateMyCommandSources()
PString name
PKeyCode accelerator
PNotifier callback
BOOL* checkPointer
PRESOURCE_ID menuID
BOOL notifyForStateUpdate
Alphabetic index HTML hierarchy of classes or Java