Home |
Class PegNotebook HMI (Human-Machine Interface) Classes |
Class PegNotebookPegNotebook is a PegWindow derived class for displaying and using a tabbed-notebook style control. The notebook can have any number of tabs, and each notebook tab is associated with a different notebook page. Each notebook page displays any user defined group of objects. Each notebook tab can either contain simple text, or any user-defined object type. Text tabs use slightly less memory, while user-defined tab decorations can give the notebook control a very custom appearance. Regardless of tab type, the tabs can be displayed at the top or bottom of the notebook window. Constructing and displaying PegNotebook requires the following steps:
class PegNotebook : public PegWindow { public: PegNotebook(const PegRect &Rect, PEGUINT wStyle, UCHAR uNumTabs); PEGINT Message(const PegMessage &Mesg); void Draw(void); void SetTabClient(UCHAR uIndex, PegThing * TabClient); void SetPageClient(UCHAR uIndex, PegThing * PageClient); PegThing * GetPageClient(UCHAR uIndex); PegThing * RemovePageClient(UCHAR uIndex); PegThing * GetTabClient(UCHAR uIndex); UCHAR GetCurrentPage(void); void SetTabString(UCHAR uIndex, const PEGCHAR * Text); void ResetTabStyle(PEGUINT wStyle); void ResetNumTabs(UCHAR uNum); void SetFont(PegFont * pFont); void SelectTab(UCHAR uTab); }; Demo program Notebook uses this class. Style FlagsFF_RAISED, FF_RECESSED, NS_TOPTABS, NS_BOTTOMTABS, NS_TEXTTABS. SignalsPegNotebook sends the PSF_PAGE_SELECT signal when a new notebook page is selected. pSource has a pointer to the notebook window. iData is the ID of notebook window. lData is the page index of selected page. ConstructorThe PegNotebook constructor accept a PegRect defining the notebook position and size, a style value, and the number of tabs that the notebook will initially display. The number of tabs can be modified at run time. Method DrawDisplays the notebook background, border, and tabs. Method GetCurrentPageReturns the active (displayed) page of the notebook. Method GetPageClientReturns the top-level client object of the current page. Method GetTabClientReturns the client object used to decorate the indicated notebook tab. This function returns NULL if the notebook is operating in NS_TEXTTABS mode, or if no decoration has been defined for the requested tab. Method MessagePegNotebook catches mouse click messages to test for notebook tab selection. PegNotebook also catches PM_KEY messages to allow navigation via a keyboard. Method RemovePageClientRemoves the client object from any notebook page. This is sometimes useful when the application desires to switch the client object displayed on a notebook page during program run time. Method ResetNumTabsResets the number of tabs available on the notebook window after the notebook object has been constructed. If uNum is greater than the current number of pages, the user should populate the new tabs and notebook client pages after this call. If uNum is less than the current number of notebook pages, the notebook will delete any page clients for pages that are no longer required. Method ResetTabStyleMoves the notebook tabs, or toggles between text tabs and custom decorated tabs. Method SelectTabChanges the current tab selection under program control. The current tab is usually selected by the user via mouse, touch screen, or keyboard. If the indicated tab is not visible, the notebook will automatically scroll the selected tab into view. Method SetFontChanges the font used to draw the text on the notebook tabs. Since the tabs are sized based on the string with of each text string in the selected font, the font can only be changed BEFORE the notebook is displayed. Method SetPageClientAssociate an object with each notebook page. There can be only one top-level client for each notebook page. For this reason, if multiple child objects are to be associated with one or more notebook pages, a borderless container window should be constructed as the notebook page client. The child objects for the notebook page should then be added to this borderless container window. This function should be called once for each notebook page, setting the page clients for page indexes 0 through (nTabs - 1). If the SetPageClient function is called to link an object with a notebook page that already has a client object, the existing client object is destroyed and replaced with the new child object. Method SetTabClientAssigns the custom decoration which will be displayed on each notebook tab. This function only works if the notebook is NOT configured for NS_TEXTTABS mode. Custom tab decorations can be created by deriving a new custom class from PegThing or from any other PEG base class. An example of this is shown in the PegNotebook example application. Method SetTabStringSets the text string displayed on each notebook tab. This function only operates when the notebook window is configured for NS_TEXTTABS mode. This function should be called once for each notebook tab, setting the text value for tab indexes 0 through (nTabs - 1). ExamplesThe following is an example of a PegNotebook window with text tabs, a raised frame, and tabs on top: The following is an example of a PegNotebook window with custom tabs, a thick frame, and tabs on bottom: An example application program using PegNotebook is found in program Notebook.
|