KwikPeg Manuals
Home
PegNotebook
Examples
Examples
Index
Index


Members
Styles
Signals
Overview Derived from class PegWindow

The PegNotebook class generates a tabbed, notebook style window. The notebook can have any number of pages, each with a page tab. The page tabs can be displayed at the top or bottom of the notebook window.

Each notebook tab can contain a simple text heading. Other user defined objects (often bitmap images) can be placed on the tab. Text tabs use slightly less memory. However, tab decorations give the notebook a custom appearance. All tabs must be of the same style: all text or all decorated.

Each notebook page displays one application specific object called the notebook page client. There can be only one page client for each notebook page. If multiple child objects are to be drawn on a notebook page, a borderless container window must be constructed as the notebook page client. The child objects for the notebook page can then be added to this borderless container window.

To construct and display a PegNotebook window, proceed as follows:

  • Create the PegNotebook object, defining the number of notebook tabs and the style of the notebook tabs. For text tabs, use the NS_TEXTTABS style flag. For decorated tabs, omit the NS_TEXTTABS style flag.
  • To each notebook tab, add either a text string or a custom decoration object. The tab content must match the tab style you specified.
  • For each page of the notebook, create a page client, a KwikPeg window or control derived from the PegThing base class. This single page client object provides the container for all objects which will appear on the notebook page. Populate the container window with the desired collection of child objects. Then attach the page client to the particular page of the notebook.




 Styles

The PegNotebook class supports the following style flags:

FF_THICK Thick 3D frame.
FF_RAISED Raised 3D frame.
FF_RECESSED Recessed 3D frame.
NS_TOPTABS  The tabs of a PegNotebook object will be drawn above the notebook pages.
NS_BOTTOMTABS  The tabs of a PegNotebook object will be drawn below the notebook pages.
NS_TEXTTABS  The tabs of a PegNotebook object contain only simple text. If this style flag is set, the tabs cannot be drawn with custom objects attached to them.


 Signals

The PegTreeView class generates the following signals:

PSF_PAGE_SELECT Sent by PegNotebook when a new page is selected.
 
The signal message contains the following information:
 
Message.lData  Page index of the selected page.
Message.iData  Object ID of the PegNotebook object.
Message.pSource  Pointer to the PegNotebook object.
 

Top of page


 Members

Constructors:

PegNotebook(const PegRect &Rect,
  WORD wStyle, UCHAR uNumTabs)

This constructor creates a PegNotebook object at a specific location within a rectangle specified by parameter Rect. The window frame style and tab style must be defined. The number of notebook tabs (pages) must also be defined. You can adjust the number of tabs and their style after the notebook has been constructed, if necessary.

 

Public Functions:

void Draw(void)

The PegNotebook overrides the Draw() function to display the notebook background, border and tabs.

UCHAR GetCurrentPage(void)
  {return muSelectedTab;}

This function returns the page number of the active (currently displayed) page of the notebook. Notebook pages are numbered from 0.

PegThing *GetPageClient(UCHAR uIndex)

This function returns a pointer to the PegThing object which is the page client for notebook page uIndex. Notebook pages are numbered from 0.

PegThing *GetTabClient(UCHAR uIndex)

This function returns a pointer to the PegThing object which is the decoration applied to notebook tab uIndex. Notebook tabs (pages) are numbered from 0. This function returns NULL if the notebook is using text tabs or if no decoration has been provided for the specified tab.

SIGNED Message(const PegMessage &Mesg)

The PegNotebook class overrides the Message() function to catch screen pointer and keyboard messages to test for notebook tab selection.

PegThing *RemovePageClient(UCHAR uIndex)

This function removes the page client object from notebook page uIndex. Notebook pages are numbered from 0. The page client object is not deleted. The notebook page remains in place but no longer has any content for display.

The function returns a pointer to the removed PegThing object. The function returns NULL if the page has no page client (never assigned or already removed) or if uIndex exceeds the number of pages in the notebook.

You can use this function to remove one page client before installing another, thereby dynamically switching page clients.

void ResetNumTabs(UCHAR uNum)

This function sets (changes) the number of notebook pages to uNum. If uNum exceeds the current number of pages, new pages will be created. Be sure to populate the new pages with page clients after increasing the number of notebook pages.

If uNum is less than the current number of notebook pages, the notebook will delete the extra pages which are no longer required. If you have not already removed the page clients from these pages, you will no longer be able to access these page client objects via the notebook member functions. The page client objects will still exist, but the notebook will have lost track of them.

void ResetTabStyle(WORD wStyle)

This function changes the notebook tab style to the style specified by wStyle. For text tabs, use the NS_TEXTTABS style flag. For decorated tabs, use the value 0.

This function has no effect if the current notebook tab style matches that specified by wStyle. If the tab style is changed, all previous text strings or tab decorations are lost. You must assign new text strings or decorations to the tabs.

Note that when switching to text tabs, the previous objects used as tab decorations are not deleted. Your objects will still exist, but the notebook will have lost track of them.

void SelectTab(UCHAR uTab)

This function marks notebook tab (page) uTab as the selected tab. The notebook is redrawn to remove the previously selected page client from the notebook window and replace it with the newly selected page.

If the indicated tab is not visible, the notebook will automatically scroll the selected tab into view.

void SetFont(PegFont *pFont)

This function sets the font used to draw the text on the notebook tabs to the font specified by parameter pFont. The tabs are sized according to width of each text string when rendered in the selected font. Hence, the text font must only be changed before the notebook is displayed.

void SetPageClient(UCHAR uIndex,
  PegThing *PageClient)

This function assigns the page client PegThing object referenced by PageClient to page uIndex of the notebook. Notebook pages are numbered from 0.

There can be only one page client for each notebook page. If multiple child objects are to be drawn on a notebook page, a borderless container window must be constructed as the notebook page client. The child objects for the notebook page can then be added to this borderless container window.

Your application must call this function once for each notebook page to install the relevant page client.

If the SetPageClient() function is called to add a page client object to a notebook page that already has a page client object, the existing page client object is destroyed and replaced with the new page client object.

void SetTabClient(UCHAR uIndex,
  PegThing *TabClient)

This function assigns the PegThing object referenced by TabClient as a custom decoration for the notebook tab for page uIndex. This function has no effect if the notebook tab style has been set for text tabs.

Your application must call this function once for each notebook page to specify the page's tab decoration.

Tab decorations can be created by deriving a custom class from the PegThing class or from any other KwikPeg base class. An example is provided in the KwikPeg KPGnnn\EXAMPLES\NOTEBOOK installation directory.

void SetTabString(UCHAR uIndex,
  const PEGCHAR *Text)

This function assigns the text string referenced by Text to the notebook tab for page uIndex. This function has no effect unless the notebook tab style has been set for text tabs.

Your application must call this function once for each notebook page to specify the page's tab text.


Top of page


 Examples

The following example illustrates a PegNotebook window with text tabs, a raised frame and tabs located at the top of the notebook. The first page has a PegTextBox object as its page client.

The following example illustrates a PegNotebook window with custom tabs, a thick frame and tabs located at the bottom of the notebook. The first page has a PegTextBox object as its page client.



An example application is provided in the KwikPeg KPGnnn\EXAMPLES\NOTEBOOK installation directory.




Top of page
KwikPeg Manuals
Home
Index
Index

 
Copyright © 2000-2003