class PMenuItem: public PMenuEntry

A class representing a menu item.

Inheritance:


Public Methods

[more] 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.
[more] PMenuItem ( PRESOURCE_ID newID, PSubMenu & menu, const char * itemName, const PKeyCode & accel )
Helper constructor for when creating menu from a resource.
[more]virtual ~PMenuItem ()
Destroy the menu item removing it from its owner menu.
[more]virtual void SetString ( const PString & str )
Set the string contents of the menu item.
[more]virtual PString GetString () const
Get the current string name of the menu entry.
[more]virtual BOOL IsMenuItemCheckGroup (const PMenuItem& groupItem) const
Determine if the menu entry is in a menu item check group.
[more]void SetAccelerator ( const PKeyCode & accel )
Set the accelerator key code associated with the menu item.
[more]PKeyCode GetAccelerator () const
Get the accelerator key code associated with the menu item.
[more]void SetNotifier ( const PNotifier & notify, BOOL notifyForStateUpdate = FALSE )
Set the notification function associated with the menu item.
[more]const PNotifier& GetNotifier () const
Get the notification function associated with the menu item.
[more]BOOL WillNotifyOnStateUpdate () const
Get the flag for notification function called when a menu item requires its enable or check state updated.
[more]void Enable ( BOOL enabled = TRUE )
Enable or disable the menu item.
[more]void Disable ()
Disable the menu item.
[more]BOOL IsEnabled () const
Determine if the menu item is currently enabled or disabled.
[more]void Check ( BOOL checked = TRUE )
Check or uncheck the menu item.
[more]void Uncheck ()
Uncheck the menu item.
[more]BOOL IsChecked () const
Determine if the menu item is currently checked or unchecked.
[more]void SetCheckPointer ( BOOL * ptr )
Set the current check state value pointer associated with the menu item.
[more]BOOL* GetCheckPointer () const
Get the current check state value pointer associated with the menu item.
[more]void 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.
[more]PINDEX 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.
[more]void Construct ( BOOL setID )
Do the common initialisation of a menu item amongst the constructors.

Public

[more] Overrides from class PMenuEntry
[more] New functions for class

Protected Fields

[more]PString name
Name of the menu item.
[more]PKeyCode accelerator
Accelerator for the menu item.
[more]PNotifier callback
Notification function to call on menu selection.
[more]BOOL* checkPointer
Pointer to variable to contain the check state of the menu item.
[more]PRESOURCE_ID menuID
Unique menu ID for resource binding
[more]BOOL notifyForStateUpdate
Flag for notification function called when a menu item requires its enable or check state updated

Protected Methods

[more]virtual void 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.

Protected

[more] New functions for class


Inherited from PMenuEntry:

Public Methods

ovirtual Comparison Compare( const PObject & obj ) const
oPSubMenu* GetMenu() const
oPRootMenu* GetRootMenu() const
oPINDEX GetPosition() const

Public

Overrides from PObject

Protected Fields

oPSubMenu* itsMenu


Inherited from PObject:

Public

Run Time Type functions

Comparison functions

I/O functions

Miscellaneous functions


Documentation

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 or disabled. 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.

o 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.
Parameters:
menu - Menu into which the new entry is to be placed.
itemName - Name of the menu item.
before - Menu entry before which the entry is to be inserted. If this is NULL then the menu entry is appended to the end of the menu.

o PMenuItem( PRESOURCE_ID newID, PSubMenu & menu, const char * itemName, const PKeyCode & accel )
Helper constructor for when creating menu from a resource. Creates the object given the menu ID as used in the resource template.
Parameters:
menu - Menu into which the new entry is to be placed.
itemName - Name of the menu item.
accel - Key code for accelerator on menu function.

ovirtual ~PMenuItem()
Destroy the menu item removing it from its owner menu.

o Overrides from class PMenuEntry

ovirtual void SetString( const PString & str )
Set the string contents of the menu item. This string is scanned for the special character '&' to place an underline attribute on the next character.
Parameters:
str - New string for the menu entry.

ovirtual PString GetString() const
Get the current string name of the menu entry.

Returns:
string for the menu item name.

ovirtual BOOL IsMenuItemCheckGroup(const PMenuItem& groupItem) const
Determine if the menu entry is in a menu item check group. If the entry is not a menu item or does not have the same notification function, the qualification for being in a menu check group, then returns FALSE.

Returns:
TRUE if in check group, FALSE otherwise.

o New functions for class

ovoid SetAccelerator( const PKeyCode & accel )
Set the accelerator key code associated with the menu item.
Parameters:
accel - New accelerator for the menu item.

oPKeyCode GetAccelerator() const
Get the accelerator key code associated with the menu item.

Returns:
key code for accelerator.

ovoid SetNotifier( const PNotifier & notify, BOOL notifyForStateUpdate = FALSE )
Set the notification function associated with the menu item. The extra integer on the indicates whether the menu item was selected (FALSE) or requires its state updated (TRUE). The latter is only called if the notifyForStateUpdate flag is set to TRUE.
Parameters:
notify - New notification function for menu item
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.

oconst PNotifier& GetNotifier() const
Get the notification function associated with the menu item.

Returns:
notification function for menu item.

oBOOL WillNotifyOnStateUpdate() const
Get the flag for notification function called when a menu item requires its enable or check state updated.

Returns:
current update flag for menu item.

ovoid Enable( BOOL enabled = TRUE )
Enable or disable the menu item.
Parameters:
enabled - New enable state for menu item.

ovoid Disable()
Disable the menu item. This is equivalent to Enable(FALSE).

oBOOL IsEnabled() const
Determine if the menu item is currently enabled or disabled.

Returns:
TRUE if the menu item is enabled.

ovoid Check( BOOL checked = TRUE )
Check or uncheck the menu item.
Parameters:
checked - New state for the menu check mark.

ovoid Uncheck()
Uncheck the menu item. This is equivalent to Check(FALSE).

oBOOL IsChecked() const
Determine if the menu item is currently checked or unchecked.

Returns:
TRUE if the menu item is checked.

ovoid SetCheckPointer( BOOL * ptr )
Set the current check state value pointer associated with the menu item. The boolean pointed to by this is automatically updated to the state of the check mark.
Parameters:
ptr - Pointer to variable to be updated with check state.

oBOOL* GetCheckPointer() const
Get the current check state value pointer associated with the menu item. The boolean pointed to by this is automatically updated to the state of the check mark.

Returns:
pointer to check state variable.

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

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.

Parameters:
newItem - Index of the menu item to be checked in the group.

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

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.

Returns:
index of selected menu item.

o New functions for class

ovoid Construct( BOOL setID )
Do the common initialisation of a menu item amongst the constructors.
Parameters:
setID - Flag for generating a new menu resource ID for the item.

ovirtual void 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.

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.

oPString name
Name of the menu item.

oPKeyCode accelerator
Accelerator for the menu item.

oPNotifier callback
Notification function to call on menu selection.

oBOOL* checkPointer
Pointer to variable to contain the check state of the menu item.

oPRESOURCE_ID menuID
Unique menu ID for resource binding

oBOOL notifyForStateUpdate
Flag for notification function called when a menu item requires its enable or check state updated


This class has no child classes.

Alphabetic index HTML hierarchy of classes or Java



This page was generated with the help of DOC++.