KwikPeg Manuals
Home
PegMenuButton
Examples
Examples
Index
Index


Members
Styles
Signals
Overview Derived from class PegThing
and PegTextThing

The PegMenuButton class is a button class used to populate PegMenu and PegMenuBar objects. Each PegMenuButton object sends selection signals to the owner of the PegMenu or PegMenuBar on which it resides.

A custom appearance for a PegMenuButton object can be created in two ways. The preferred method is to derive a new menu variant from the PegMenuButton class. Alternatively, the Draw() function of the PegMenuButton object can be overridden to create any desired menu button appearance.

A menu item may represent one of many possible choices. In other cases, the menu item may be an option which is enabled by a 'dot' or 'checkmark' next to the item. In either case, the style flags for a PegMenuButton object define the menu item's characteristics.

PegMenuButton objects are automatically created by PegMenuBar and PegMenu objects to satisfy their PegMenuDescription specifications. Your application does NOT have to create individual PegMenuButton objects. Providing the PegMenuDescriptions for a PegMenu or PegMenuBar is all that is required to create a fully functional command menu.



 See Also

Menu Description Structure (PegMenuDescription)

PegMenuBar

PegMenu



 Styles

The PegMenuButton class supports the following style flags:

AF_ENABLED  This style flag is used to indicate that the object can be selected.
TT_COPY  Keep separate copy of text with the object. This flag should be used when the string value used to assign text to an object is located in temporary storage such as a local variable on the stack.
BF_SEPARATOR  A PegMenuButton with this style acts as a separator item on a menu.
BF_CHECKABLE  A PegMenuButton with this style can be checked or unchecked.
BF_CHECKED  This style flag defines the initial state (checked or unchecked) of a checkable PegMenuButton object. This style flag is only used if style flag BF_CHECKABLE is set.
BF_DOTABLE  A PegMenuButton with this style can be dotted or undotted. Dotted menu buttons are mutually exclusive. Only one dotable menu button on a menu can be dotted.
BF_DOTTED  This style flag defines the initial state (dotted or undotted) of a dotable PegMenuButton object. This style flag is only used if style flag BF_DOTABLE is set.


 Signals

The PegMenuButton class generates the following signals:

PSF_CLICKED Sent by any object when it is selected.
PSF_CHECK_ON Sent by check box and menu button when checked.
PSF_CHECK_OFF Sent by check box and menu button when unchecked.
PSF_DOT_ON Sent by radio button and menu button when selected.
PSF_DOT_OFF Sent by radio button and menu button when unselected.

Top of page


 Members

Constructors:

PegMenuButton(PegMenuDescription *pDesc)

The PegMenuButton constructor creates one or more PegMenuButton objects. The PegMenuDescription specification referenced by parameter pDesc must provide a valid menu button description. The description can include a forward reference to another PegMenuDescription specification. This linked list of menu buttons will be recursively traversed until all menu buttons in the list have been constructed.

The last menu button description in the list of PegMenuDescription specifications must have its sub-menu pointer pDesc.pSubMenu set to NULL.

 

Public Functions:

virtual void CloseMenu(void)

This function closes the submenu, if any, associated with the PegMenuButton.

virtual void Draw(void)

The PegMenuButton class overrides the Draw() function to display the menu command text string. This function may be overridden to define a custom menu button appearance.

PegThing *Find(WORD wID,
  BOOL bRecursive = TRUE)

This function searches through its child objects to find an object with an ID of wID. If bRecursive is true, it will search through the button's ancestry until it either finds the object or exhausts the list of child objects.

PegMenuButton *FindButton(const PEGCHAR *Who)

This function can be used to find a particular PegMenuButton object. This function is called by PegMenu and PegMenuBar to recursively search the menu tree when the associated functions of the same name are invoked.

virtual PegRect GetMinSize(UCHAR uType)

This function returns the minimum height and width required to display the PegMenuButton object. The returned rectangle includes space for checkmarks, dot selection and sub-menu indicator bitmaps.

PegThing *GetOwner(void) {return mpOwner;}

This function returns the owner object of the menu button.

inline PegMenu *GetSubMenu(void)

This function returns a pointer to the sub-menu associated with a menu button or NULL if the menu button has no sub-menu.

virtual BOOL IsChecked(void)

This function returns TRUE if the PegMenuButton object has the BF_CHECKABLE style flag and the menu item is currently selected, else FALSE.

virtual BOOL IsDotted(void)

This function returns TRUE if the PegMenuButton object has the BF_DOTABLE style flag and the menu item is currently selected, else FALSE.

BOOL IsPointerOver(void) {return mbPointerOver;}

This function returns TRUE if the screen pointer is over the menu button, else FALSE.

virtual BOOL IsSeparator(void)

This function returns TRUE if the menu button is a separator menu item, else FALSE.

BOOL IsSubVisible(void) {return mbSubVisible;}

This function returns TRUE if the sub-menu of this button is visible, else FALSE.

virtual SIGNED Message(const PegMessage &Mesg)

The PegMenuButton class catches PM_POINTERENTER, PM_POINTEREXIT, PM_LBUTTONDOWN and PM_LBUTTONUP messages.

virtual void SetChecked(BOOL State)

This function can be used by your application to directly check or uncheck a checkable menu item, whether or not the item is also user selectable.

virtual void SetDotted(BOOL State)

This function can be used by your application to directly add or remove the dot of a dotted menu item, whether or not the item is also user selectable.

virtual void SetEnabled(BOOL State)

This function can be used to enable or disable a menu button at any time. A disabled menu button is drawn with a modified appearance to indicate to the end user that it not operational.

virtual void SetOwner(PegThing *Who)

This function is called by PegMenu and PegMenuBar objects to assign the menu button's parent. This PegMenuButton object sends command signals to the menu owner identified as Who. If the menu owner is set to NULL, command signals will be sent to the menu button's parent.

void SetSubMenu(PegMenu *pMenu)

This function assigns a PegMenu sub-menu to the menu button. This function is commonly used to assign a PegMenu sub-menu created from a dynamically constructed PegMenuDescription specification. This function does NOT have to be called if the PegMenuDescription for a menu tree is statically defined.


Top of page


 Examples

The following are examples of PegMenuBar, PegMenu and PegMenuButton objects:




Top of page
KwikPeg Manuals
Home
Index
Index

 
Copyright © 2000-2003