Home |
Class PegWindow HMI (Human-Machine Interface) Classes |
Class PegWindowPegWindow defines a basic rectangular area on the screen. Important functionality added by PegWindow includes the concept of scrolling a virtual client area. PegWindow objects may be used as is, but more commonly serve as the base class for the more refined window classes such as PegDecoratedWindow and PegDialog. PegWindow provides the capabilities of being re-sized by the user, having a virtual client area, having one of several frame styles, and controlling non-client-area scroll bars. A PegWindow drawn with a raised border provides a blank panel that is useful for splash screens. A PegWindow with no border is useful as a container for other objects. The window can be moved to different locations or added to different parent objects, and all of the window's children will move with the window. A simple way to create a window with a virtual scrolling client area is to nest a large window within the client area of a parent window. An example of this is included in the examples section for PegWindow. PegWindow and PegWindow derived classes are also by default Viewports. This means that objects underneath PegWindow are not allowed to obscure the screen area owned by the window. This is an important performance enhancing feature of PEG, and also provides improved visual appeal. When a PegWindow object is resized, all children of the window receive PM_PARENTSIZED system messages. This message can be caught by child objects to position and size themselves relative to the their parent window. A window defaults to PSF_MOVEABLE and PSF_SIZEABLE if the FF_THICK frame style is used. For all other frame styles the Window will default to non-sizeable and non-moveable. This can be overridden by calling AddStatus() or RemoveStatus() after constructing the window. A window defaults to having no scroll bars, and automatic scrolling mode is disabled. The member function SetScrollMode() is used to alter the scrolling mode of the window. class PegWindow : public PegThing { public: PegWindow(const PegRect &Rect, PEGUINT wStyle = FF_THICK); PegWindow(PEGUINT wStyle = FF_THICK); virtual void Draw(void); virtual PEGINT Message(const PegMessage &Mesg); virtual PEGINT Execute(void); virtual void InitClient(void); virtual void Add(PegThing * Who, BOOL bDraw = TRUE); virtual void AddIcon(PegIcon * pIcon); virtual void SetScrollMode(UCHAR uMode); virtual UCHAR GetScrollMode(void); virtual void GetVScrollInfo(PegScrollInfo * Put); virtual void GetHScrollInfo(PegScrollInfo * Put); virtual void DrawFrame(BOOL bFill = TRUE); virtual PegBitmap * GetIcon(void); virtual void SetIcon(PegBitmap * nb); virtual void Resize(PegRect NewSize); virtual void MoveFocusToFirstClientChild(void); BOOL IsMaximized(void); UCHAR CurrentMoveMode(void); BOOL CheckAutoScroll(void); virtual UCHAR BorderContains(PegPoint Point); }; Demo programs PegDemo and Gauge use this class. Style FlagsFF_NONE, FF_THIN, FF_RAISED, FF_RECESSED, FF_THICK. ConstructorsThe first constructor is used when the initial size and position of the window are know at the time the window is created. Rect defines the mReal position of the window. The second constructor is used when the default position of the window is not known at the time the window is constructed, or the window size and position are self determined. When this constructor is used, the window should determine its position before or when the PM_SHOW message is received. This should be done in two steps:
Method AddPegWindow overrides this method to not only add the pWho object, but also to give this object focus if necessary. Method AddIconPositions and adds a PegIcon object to the window. The Window will automatically determine the correct position for the PegIcon object. It should be noted that any PegWindow derived object can contain icons. It is sometimes assumed that only PegPresentationManager can act as a PegIcon container, which is not the case. Method CurrentMoveModeReturns the current move mode of the window. Method DrawThe Draw() function of PegWindow is broken out into two sections. The function DrawFrame() is called first to draw the window frame, and then the child objects of the window are drawn. Classes derived from PegWindow may find it convenient to use the DrawFrame() function as part of an overridden Draw() routine. Method DrawFrameDraws the window frame using the current frame style flags. This function can be useful to PegWindow derived classes that have overridden the Draw() function. Parameter bFill specifies whether the windows client area should be cleared. Method ExecuteExecute the window Modally. The Execute() function does not return until the window is closed. Its return value is the ID of the object which closed the window (e.g. an IDB_OK if an OK button was pressed). In most cases window should be added to PegPresentationManager before calling the Execute() function of the window. The exception is when MULTITHREAD operation is enabled, and the user desires to execute the window from with a secondary thread. In this case, calling Execute() will automatically add the window to PegPresentationManager, and the window will run from within the thread of the calling task. Method GetHScrollInfoGetHScrollInfo is called by PegWindow and non-client PegHScroll children to determine the appearance and range of the window horizontal scroll bar. The default PegWindow implementation queries the position of all client-area child objects to determine the horizontal scroll information. This function is often overridden in derived PegWindow classes to provide custom scrolling operation. Method GetIconReturns a pointer to the PegBitmap currently associated with the window Icon. Method GetScrollModeReturns the current window scroll mode. Method GetVScrollInfoGetVScrollInfo is called by PegWindow and non-client PegVScroll children to determine the appearance and range of the window vertical scroll bar. The default PegWindow implementation queries the position of all client-area child objects to determine the vertical scroll information. This function is often overridden in derived PegWindow classes to provide custom scrolling operation. Method InitClientInitializes the client region, accommodating for a border, if present. Method IsMaximizedReturns TRUE if the window is maximized, else FALSE. Method IsMinimizedReturns TRUE if the window is minimized, else FALSE. Method MessageCatches mouse clicks for re-sizing and close the window. Method MoveFocusToFirstClientChildMoves the focus to the first child of the window. Method ResizeSends PM_PARENTSIZED notifications to child objects, and to update scroll bars. This function is often overridden to provide custom operation. Method SetIconAssigns the bitmap that will be associated with the window icon. Method SetScrollModeSets the operation of non-client-area scroll bars. Non-client-area scroll bars are used to provide the appearance of a virtual-client area. The available scroll modes are: WSM_AUTOVSCROLLAdd vertical scroll bar when needed WSM_VSCROLLAdd vertical scroll bar always WSM_AUTOHSCROLLAdd horizontal scroll bar when needed WSM_HSCROLLAdd horizontal scroll bar always WSM_AUTOSCROLLAUTOVSCROLL | AUTOHSCROLL WSM_CONTINUOUSContinuous, smooth scrolling Automatic scrolling relies on the values returned by the GetVScrollInfo() and GetHScrollInfo() functions to determine when each scroll bar is required. If the PegScrollInfo.wVisible value is >= to the overall scroll range, the corresponding scroll bar is not required. The WSM_CONTINUOUS mode can be included with any other modes. This flag causes the scroll bars to send scroll messages continuously as they are dragged by the user, rather than the default operation which is to send a scroll message only when the scroll button is released. Continuous scrolling requires greater hardware performance and/or hardware acceleration in the video controller to provide the best smooth scrolling. Performance-limited platforms should not use the WSM_CONTINUOUS flag. Method BorderContainsCalled on receipt of PM_POINTERMOVE message to determine if the mouse is over the window border. The return value is 0 if the mouse pointer is not over the window border, or a MoveMode. The MoveModes are defined in the include file Pwindow.hpp. Method CheckAutoScrollIf either WSM_AUTOVSCROLL or WSM_AUTOHSCROLL scroll modes are set, this function is called when the window is re-sized to determine if scroll bars need to be updated. Derived classes also call this function at times when the scroll bars may need to be added or removed. ExamplesDefault PegWindow: PegWindow with FF_RAISED frame style: Two PegWindow objects nested within another PegWindow. The child windows have scrolling enabled: The following example creates a PegWindow and adds the window to PegPresentationManager. The window will have a default (thick) border, and will be 190 pixels wide by 110 pixels tall, and will be 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 with a recessed frame and add the window to the current object. The window will fill 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. We will configure the outer parent window to provide scroll bars, so that the user can pan to display all areas of the child window. The resulting parent/child window combination will be 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); }
|