KwikPeg Manuals
Home
PegWindow
Examples
Examples
Index
Index


Members
Styles
Signals
(none)
Overview Derived from class PegThing

The PegWindow class defines a basic rectangular area on the screen. Although a PegWindow object may be used in its basic form, it is more commonly used as the base class for more refined window classes such as the PegDecoratedWindow and PegDialog classes.

Windows of the PegWindow class can have any of several frame styles. The windows can also be resized and dragged.

The addition of non-client area scroll bars to the window allows the window to be used to view a virtual client area through the real client area of the window. The PegWindow class includes inherent support for scroll bars. A simple window with a scrolling client area can be created by nesting a large window within the client area of a smaller parent window. An example is provided which illustrates the concept.

A PegWindow drawn with a raised border provides a blank panel for use as a splash screen. A PegWindow with no border is a useful container for holding other objects. When the window is moved to a different location or added to a different parent object, the window's children move with the window.

By default, windows derived from the PegWindow class are viewports. Consequently, objects underneath the PegWindow object are not allowed to obscure the screen area owned by the window. KwikPeg's viewport implementation improves performance and increases the visual appeal of your windows.

When a PegWindow object is resized, all children of the window receive PM_PARENTSIZED system messages informing them of the resize operation. A child object can then resize and position itself relative to its parent's revised window.

By default, a PegWindow object with the FF_THICK frame style is also given the PSF_MOVEABLE and PSF_SIZEABLE styles. Windows with other frame styles are considered fixed in size and position. Of course, these window styles can be overridden using the AddStatus() or RemoveStatus() member functions.

By default, a PegWindow object operates without scroll bars and with automatic scrolling disabled. The member function SetScrollMode() can be used to alter the window's scrolling mode.



 See Also

Viewports

Client Area Bounds

How Scrolling Works

PegDecoratedWindow

PegDialog

PegMessageWindow

PegMLMessageWindow



 Styles

The PegWindow class supports the following style flags:

FF_NONE No frame.
FF_THIN Thin frame.
FF_THICK Thick 3D frame.
FF_RAISED Raised 3D frame.
FF_RECESSED Recessed 3D frame.

Top of page


 Members

Constructors:

PegWindow(const PegRect &Rect,
  WORD wStyle = FF_THICK)

This constructor creates a PegWindow object at a specific location within a rectangle specified by parameter Rect. The rectangle defines the mReal position of the window.

PegWindow(WORD wStyle = FF_THICK)

This constructor creates a PegWindow object. The position of the window will be determined by the window's constructor or after the window has been constructed. The window position must be determined before the PM_SHOW message is serviced to draw the window.

The window position must be established as follows:

1) Set the window's mReal member variable.

2) Call member function InitClient() to initialize the window's client area.

 

Public Functions:

virtual void Add(PegThing *pWho,
  BOOL bDraw = TRUE)

The PegWindow class overrides the Add() function to add the PegThing object referenced by parameter pWho to the window and to give that object focus, if necessary.

virtual void AddIcon(PegIcon *pIcon)

This function adds a PegIcon object to the window. The window will automatically determine the correct position to display the PegIcon object when the window is minimized. It should be noted that any PegWindow derived object can contain icons. It is sometimes incorrectly assumed that only the KwikPeg Presentation Manager, the PegPresentationManager object, can act as a PegIcon container.

BOOL CheckAutoScroll(void)

If the window has vertical scrolling (WSM_AUTOVSCROLL) or horizontal scrolling (WSM_AUTOHSCROLL) enabled, this function will be called when the window is resized to determine if the scroll bars need to be updated. Derived classes can also use this function to refresh the window when scroll bars are added or removed.

UCHAR CurrentMoveMode(void)
  {return muMoveMode;}

This function returns a non-zero value if the window is currently being moved or resized. Otherwise, the function returns 0. A summary of the possible non-zero move mode values is provided in the description of member variable muMoveMode.

virtual void Draw(void)

The PegWindow class overrides the Draw() function to draw the window in two steps. The function DrawFrame() is called to draw the window frame. Then the child objects of the window are drawn.

Classes derived from the PegWindow class may also find it convenient to use the DrawFrame() function within their overridden Draw() member function.

virtual void DrawFrame(BOOL bFill = TRUE)

This function draws the window frame according to the current frame style flags. Classes derived from the PegWindow class may find it convenient to use this function within their overridden Draw() member function.

virtual SIGNED Execute(void)

This function generates (executes) the window as a modal window. The Execute() function does not return to its caller until the window is closed. The window should be added to the KwikPeg Presentation Manager (the PegPresentationManager object) before the window's Execute() function is called.

When using the KwikPeg multithread model, an application task which calls this function becomes a GUI Task. The window (and any windows which it spawns) will be serviced in the context of that task. In this case, KwikPeg will automatically add the window to the PegPresentationManager object to ensure the integrity of the screen presentation.

virtual void GetHScrollInfo(PegScrollInfo *pPut)

This function is called by the PegWindow object and by its horizontal, non-client area scroll bar child (a PegHScroll object), if any, to determine the state and required appearance of the window's horizontal scroll bar. The default PegWindow implementation queries the position of all client area child objects to derive the horizontal scroll information. This function is often overridden in derived PegWindow classes to customize the scrolling operation.

virtual PegBitmap *GetIcon(void)

This function returns a pointer to the PegBitmap object which provides the icon currently assigned to the window.

virtual UCHAR GetScrollMode(void)

This function returns the current window scroll mode. A summary of the possible scroll mode states is provided in the description of member variable muScrollMode.

virtual void GetVScrollInfo(PegScrollInfo *pPut)

This function is called by the PegWindow object and by its vertical, non-client area scroll bar child (a PegVScroll object), if any, to determine the state and required appearance of the window's vertical scroll bar. The default PegWindow implementation queries the position of all client area child objects to derive the vertical scroll information. This function is often overridden in derived PegWindow classes to customize the scrolling operation.

SIGNED GlobalModalExecute(void)

Normally a call to Execute() will make a window modal within the context of the task which is manipulating the window. Windows in other tasks can still get the input focus to read input devices such as the keyboard and screen pointer. This function makes a window modal within the context of all tasks.

virtual void InitClient(void)

This function initializes the client region of the window, taking into account the presence and size of a border.

BOOL IsMaximized(void)

This function returns TRUE if the window is maximized, else FALSE.

BOOL IsModal(void)

This function returns TRUE if the window is modal, else FALSE.

virtual SIGNED Message(const PegMessage &Mesg)

The PegWindow class catches screen pointer messages to support window resizing and movement. It also catches PSF_CLICKED signals from objects with ID IDB_CLOSE to close the window.

virtual void MoveFocusToFirstClientChild(void)

This function moves the focus to the first child of the window.

virtual void Resize(PegRect NewSize)

The PegWindow class overrides the Resize() function to send PM_PARENTSIZED notifications to its child objects and to update its scroll bars. This function is often overridden by derived classes to customize the resizing operation.

virtual void SetIcon(PegBitmap *pMap)

This function assigns the PegBitmap object referenced by parameter pMap as the icon to be associated with the window and used to represent the window when it is minimized.

virtual void SetScrollMode(UCHAR wMode)

This function establishes the operating mode of the window's non-client area scroll bars, if any. A summary of the allowable scroll mode values for parameter wMode is provided in the description of member variable muScrollMode.

 

Protected Members:

virtual UCHAR BorderContains(PegPoint Point)

This function is called on receipt of PM_POINTERMOVE messages to determine if the screen pointer is over the window border. The current move mode is returned if the screen pointer is over the window border. If the move mode value is 0, the window is not being resized or moved. If the screen pointer is not over the window border, the value 0 is returned.

A summary of the possible non-zero move mode values is provided in the description of member variable muMoveMode.

PegHScroll *mpHScroll

This variable provides a pointer to the horizontal, non-client area scroll bar (a PegHScroll object), if one exists, else NULL.

BOOL mbMaximized

This variable will have value TRUE if the window is currently maximized, else FALSE.

BOOL mbModal

This variable will have value TRUE if the window is executing modally, else FALSE.

UCHAR muMoveMode

This variable will assume one of the following non-zero values if the window is being moved or resized. Otherwise, the value of the variable will be 0.

PMM_MOVEALL  The window is being moved.
PMM_MOVETOP  Resizing the window using the top handle.
PMM_MOVEBOTTOM  Resizing the window using the bottom handle.
PMM_MOVELEFT  Resizing the window using the left handle.
PMM_MOVERIGHT  Resizing the window using the right handle.
PMM_MOVEUR  Resizing the window using the upper right handle.
PMM_MOVELR  Resizing the window using the lower right handle.
PMM_MOVEUL  Resizing the window using the upper left handle.
PMM_MOVELL  Resizing the window using the lower left handle.


UCHAR muScrollMode

This variable defines the window's current scroll mode. A value of 0 indicates that scrolling is not supported. The following scroll mode flags are supported:

WSM_AUTOVSCROLL  Add vertical scroll bar only when needed.
WSM_AUTOHSCROLL  Add horizontal scroll bar only when needed.
WSM_AUTOSCROLL  Add vertical and/or horizontal scroll bar only when needed.
WSM_VSCROLL  Add vertical scroll bar always.
WSM_HSCROLL  Add horizontal scroll bar always.
WSM_CONTINUOUS  Use continuous, smooth scrolling.

Automatic scrolling relies on the values returned by the GetVScrollInfo() and GetHScrollInfo() functions to determine when scroll bars should be added, refreshed or removed. If the PegScrollInfo.wVisible value is >= the overall scroll range, the particular scroll bar will not be added to the window.

The WSM_CONTINUOUS scroll mode flag can be merged with other mode flags. This flag causes the scroll bars to send scroll messages repetitively as they are dragged. Normally, a scroll message is only generated when the scroll button is released.

Do not use the WSM_CONTINUOUS flag unless your video device driver supports smooth scrolling or your target processor has the processing bandwidth to handle the extra screen drawing that will be needed to achieve the effect.

PegVScroll *mpVScroll

This variable provides a pointer to the vertical, non-client area scroll bar (a PegVScroll object), if one exists, else NULL.


Top of page


 Examples

Default PegWindow object:

A PegWindow object with the FF_RAISED frame style:

Two PegWindow objects nested within another PegWindow object. The child windows have scrolling enabled:



The following example creates a PegWindow object and adds the window to KwikPeg Presentation Manager (the PegPresentationManager object). The window has the default (thick) border which will be 5 pixels wide, unless altered by your KwikPeg Library configuration. The client area within the window will therefore be 190 pixels wide by 110 pixels high. The window is centered on the screen.

void SomeObject::CreateWindow(void)
{
    PegRect WinSize;
    WinSize.Set(10, 10, 200, 120);

    PegWindow *pWin = new PegWindow(WinSize);
    Presentation()->Center(pWin);

    Presentation()->Add(pWin);
}


The following example will create a PegWindow object with a recessed frame. The window is added to the current object. The window fills the client area of the current object.

void SomeObject::AddClientWindow(void)
{
    PegWindow *pWin =
        new PegWindow(mClient, FF_RECESSED);
    Add(pWin);
}


The following example creates two PegWindow objects. The second window will be a child of the first. The second window is also much larger than the first. The outer parent window is configured to provide scroll bars so that the user can pan to display all areas of the child window. The resulting parent/child window combination is centered on the screen.

void SomeObject::CreateScrollingWindow(void)
{
    PegRect ParentRect, ChildRect;

    ParentRect.Set(0, 0, 200, 140);
    ChildRect.Set(0, 0, 800, 800);

    PegWindow *pOuter = new PegWindow(ParentRect);
    PegWindow *pChild = new PegWindow(ChildRect, FF_NONE);
    pOuter->Center(pChild);
    pOuter->Add(pChild);
    pOuter->SetScrollMode(WSM_AUTOSCROLL);

    Presentation()->Center(pOuter);
    Presentation()->Add(pOuter);
}



Top of page
KwikPeg Manuals
Home
Index
Index

 
Copyright © 2000-2003