Home |
Class PegMenuButton HMI (Human-Machine Interface) Classes |
Class PegMenuButtonPegMenuButton is a button class used to populate PegMenu and PegMenuBar objects. PegMenuButton sends selection signals to the owner of the PegMenu or PegMenuBar. Custom appearance for PegMenuButton objects can be created by altering the PegMenuButton Draw() function or preferably by deriving new versions of PegMenuButton from the PegMenuButton class. Overriding the Draw() function of PegMenuButton allows the developer to create any desired menu button appearance. The styles for PegMenuButton descriptions are very important. They define whether the item sends a simple command, or if the item defines additional characteristics such as 'dotable' or 'checkable'. PegMenuButton objects are automatically created by PegMenuBar and PegMenu objects to satisfy the corresponding PegMenuDescriptions. It is NOT necessary to create individual PegMenuButton objects manually. Simply defining the PegMenuDescription is all that is require to create a fully functional command menu. class PegMenuButton : public PegThing, public PegTextThing { public: PegMenuButton(PegMenuDescription * pDesc); virtual PEGINT Message(const PegMessage &Mesg); virtual void Draw(void); virtual PegRect GetMinSize(UCHAR uType); virtual void CloseMenu(void); virtual void SetDotted(BOOL State); virtual void SetChecked(BOOL State); virtual void SetEnabled(BOOL State); PegMenuButton * FindButton(const PEGCHAR * Who); PegThing * Find(PEGUINT wId, BOOL bRecursive = TRUE); virtual void SetOwner(PegThing * Who); PegThing * GetOwner(void); PegMenu * GetSubMenu(void); void SetSubMenu(PegMenu * pMenu); virtual BOOL IsSeperator(void); virtual BOOL IsChecked(void); virtual BOOL IsDotted(void); BOOL IsSubVisible(void); BOOL IsPointerOver(void); }; Style FlagsBF_SEPARATOR, BF_CHECKABLE, BF_CHECKED, BF_DOTABLE, BF_DOTTED. ConstructorThe PegMenuButton constructor creates a PegMenuButton object. The description should contain either a valid button ID or the address of an additional PegMenuDescription array. Method CloseMenuCloses the submenu associated with the PegMenuButton, if any. Method DrawDisplays the menu command text string. This function may be overridden to define a custom menu button appearance. Method FindSearches through its child objects to find an object with an id of wID. If bRecursive is true, it will search through the button's ancestors until it either finds the object or exhausts the list of child objects. Method FindButtonFinds a particular PegMenuButton object. This function is called by PegMenu and PegMenuBar to recurse through the menu tree when the associated functions of the same name are invoked. Method GetMinSizeReturns the minimum height and width required to display the PegMenuButton object. The returned value includes space for checkmarks, dot selection, and sub-menu indicator bitmaps. Method GetOwnerReturns the owner object of the button. Method GetSubMenuReturns a pointer to the sub-menu associated with a menu button, or NULL if the button has no sub-menu. Method IsCheckedFor BF_CHECKABLE PegMenuButton objects, this function returns TRUE if the item is currently selected, else FALSE. Method IsDottedFor BF_DOTABLE PegMenuButton objects, this function returns TRUE is the item is currently selected, else FALSE. Method IsPointerOverReturns a boolean stating whether the mouse pointer is over this menu button. Method IsSeperatorReturns true if the menu button is a separator style button. Method IsSubVisibleReturns a boolean stating whether the sub menu of this button is visible. Method MessagePegMenuButton catches PM_PONTERENTER, PM_POINTEREXIT, PM_LBUTTONDOWN, and PM_LBUTTONUP messages. Method SetDottedSelects a dotable menu item under program control, rather than through the normal method of user selection. Method SetCheckedCheck or uncheck a checkable menu item under program control, rather than through the normal method of user selection. Method SetEnabledEnables or Disables a menu button. Disabled menu buttons are drawn with a modified appearance to indicate to the end user that they are not active. Method SetOwnerAssigns the button parent. This directs the menu button command signals to the menu owner window, instead of to the menu parent window. Method SetSubMenuAssigns the sub-menu associated with a menu button. This is commonly used when a PegMenu is defined or modified at run time using a dynamically constructed PegMenuDescription. This function does not need to be called if the PegMenuDescription for a menu tree is statically defined. Examples:The following are examples of PegMenuBar, PegMenu, and PegMenuButton:
|