Home |
Class PegMenuBar HMI (Human-Machine Interface) Classes |
Class PegMenuBarPegMenuBar is a window decoration used to position and display a user command menu. PegMenuBar is designed to work in conjunction with PegDecoratedWindow objects. PegMenuBar may be added to any type of object, however the client area of objects other than PegDecoratedWindow will not properly be reduced unless this is done in the application software. PegMenuBar automatically positions and sizes itself to the parent window. PegMenuBar may contain any number of PegMenuButton objects. PegMenuBar accepts a PegMenuDescription parameter. This description defines the PegMenuButton objects that will initially be created and displayed on the menu bar. The PegMenuDescription is most often defined statically, or defined by WindowBuilder, but the PegMenuDescription can also be created dynamically during program execution. When dynamically created PegMenuDescriptions are used to create instances of PegMenuBar, it is important to include the TT_COPY flag in each PegMenuDescription style. By default, the menu descriptions are not copied. PegMenuBar also provides functions for finding, adding, and removing PegMenuButton objects at any time. This allows PegMenu objects to be altered at run time under program control. The functions for finding and modifying menu command objects are recursive, and search the entire menu tree for the specified items. PegMenuBar automatically creates and displays PegMenu objects when top-level menu commands are selected. class PegMenuBar : public PegThing { public: PegMenuBar(PegMenuDescription * pDesc); virtual PEGINT Message(const PegMessage &Mesg); virtual void Draw(void); virtual void SetFlyoverMode(BOOL bState); virtual BOOL InFlyoverMode(void); virtual void CloseSiblings(PegMenuButton * pNotMe); PegMenuButton * FindButton(const PEGCHAR * Who); }; Demo programs PegDemo, Table, Notebook, and Spread use this class. ConstructorThe PegMenuBar constructor creates a PegMenuBar object with PegMenuButton children. The children are defined by the PegMenuDescription parameter. PegMenuBar automatically determines its position and size. Method CloseSiblingsCloses all of the siblings of pNotMe. Method DrawPegMenu overrides the Draw() function to draw the menu bar background. Method FindButtonSearches for a PegMenuButton child with a matching command string. This function is in addition to the normal Find(PEGUINT wId) which may also be used to find specific PegMenu command buttons. The pointer returned can be used to Enable/Disable/Remove the PegMenuButton. This function is recursive, and will search the entire menu tree for the indicated command button. Method InFlyoverModeReturns the state of the menu being in flyover mode. Method MessagePegMenuBar catches PM_PARENTSIZED and PM_NONCURRENT messages. Method SetFlyoverModePuts the PegMenuBar object in flyover mode. Flyover mode means that as the mouse is moved over submenu items, they are automatically highlighted. Examples:The following are examples of PegMenuBar, PegMenu, and PegMenuButton: The following example creates a PegMenuBar and adds the menu bar to the parent window. In this example, "HelpMenu", "WindowsMenu", "OptionsMenu", and "FileMenu" are additional PegMenuDescription arrays (not shown) that define the submenus of the menu bar. static PegMenuDescription MainMenu[] = { {"Help", 0, AF_ENABLED, HelpMenu}, {"Disabled", 1, 0, NULL}, {"Windows", 0, AF_ENABLED, WindowsMenu}, {"Options", 0, AF_ENABLED, OptionsMenu}, {"File", 0, AF_ENABLED, FileMenu}, {"", 0, 0, NULL} }; void MyWindow::AddMenuBar(void) { Add(new PegMenuBar(MainMenu)); }
|