Home |
Class PegStatusBar HMI (Human-Machine Interface) Classes |
Class PegStatusBarPegStatusBar is a window decoration that automatically sizes and positions itself at the bottom of the client area of its parent. PegStatusBar may have any number of children. Since PegPrompt object are the most common type of child object added to a status bar, the PegStatusBar class includes functions for easily displaying and accessing any number of PegPrompt objects. The last object added to a PegStatusBar is sized to extend to the rightmost edge of the status bar. A pointer to a status bar added to a PegDecoratedWindow can be obtained by calling the PegDecoratedWindow::StatusBar() function. class PegStatusBar : public PegThing { public: PegStatusBar(void); void Draw(void); PEGINT Message(const PegMessage &Mesg); void SetFont(PegFont * pFont); PegPrompt * AddTextField(int iWidth, PEGUINT wId, PEGCHAR * Text = NULL); void SetTextField(PEGUINT wId, PEGCHAR * Text); PegPrompt * GetPrompt(PEGUINT wId); }; Demo programs PegDemo and Spread use this class. SignalsPegStatusBar does not send signals. However, children of the status bar will send the normal signals supported by the child object types. PegStatusBar will pass any signal received on to the parent window. ConstructorThe constructor creates a PegStatusBar. The status bar is normally added to a PegDecoratedWindow or PegDialog. Method AddTextFieldAdds a PegPrompt field to the status bar. Parameter iWidth indicates the desired field width, in pixels. wId is the ID that will be assigned to the PegPrompt, and * Text is the initial prompt value. PegPrompts added to a PegStatusBar can be updated at run-time. They are located by calling GetPrompt with the ID of the prompt in question. Method DrawOverrides the Draw() function to draw the status bar frame. Method GetPromptReturns a pointer to the PegPrompt child of the status bar with the given ID value. Method MessagePegStatusBar catches the PM_SHOW and PM_PARENTSIZED messages to size itself and position the children of the status bar. Method SetFontSetFont resizes all of its children and itself based on the size of the new font. It also alerts its parent window that it has resized. Method SetTextFieldSetTextField provides a shorthand method for updating a prompt which has been added to the status bar. The wId parameter indicates the desired prompt ID, and the Text value is the new text value to assign to the prompt. ExamplesThe following is a PegStatusBar with several text fields, added to a PegDecoratedWindow: The following function creates a PegStatusBar with three text fields, and adds the status bar to a parent window. void MyWindow::AddStatusBar(void) { PegStatusBar * pStat = new PegStatusBar(); pStat->AddTextField(100, ID_FIELD1, "Fixed Field 1"); pStat->AddTextField(100, ID_FIELD2, "Fixed Field 2"); pStat->AddTextField( 20, ID_FIELD3, "Variable Field 3"); Add(pStat); } Any field in the status bar created above can be updated using the following code sequence: void MyWindow::UpdateSecondStatusField(PEGCHAR * NewVal) { StatusBar()->SetTextField(ID_FIELD2, NewVal); }
|