Home |
Class PegProgressBar HMI (Human-Machine Interface) Classes |
Class PegProgressBarPegProgressBar is a simple progress bar control used to indicate to an end user the completion status of a slow activity. PegProgressBar can assume any scale value within the range of the PEGINT data type, however it is most common to display a value that is a percentage of the completion status. PegProgressBar can assume any colors, controlled by calling the SetColor() function. For this control, PCI_NORMAL is the color index of the progress bar background, and PCI_SELECTED is the color index of the progress bar foreground. PCI_NTEXT is the color index of the optional text value displayed in the center of the progress bar. The style, range, and initial value of a PegProgressBar object are passed to the object constructor. As the operation being monitored progresses, the application software calls the Update() member function to change the displayed completion value. The progress bar control has two main styles. The most common style is a solid indicator, in which case the progress bar internally draws a PegButton within the specified frame style. The PS_LED, on the other hand, style does not use a client area button to indicate progress, but instead invokes a custom drawing style meant to appear as a series of LEDs, with the lighted LEDs indicating the current relative progress. While you can create any number of PegProgessBar instances directly, it is more common to use the PegProgressWindow class, as this is a simpler method of creating and displaying a progress indicator to the end user. class PegProgressBar : public PegThing { public: PegProgressBar(const PegRect &Rect, PEGUINT wStyle = FF_THIN | PS_SHOW_VAL | PS_PERCENT, int iMin = 0, int iMax = 100, int iCurrent = 0); void Draw(void); void SetFont(PegFont * pFont); void Update(int iVal, BOOL bDraw = TRUE); int Value(void); }; Demo program PegDemo uses this class. Style FlagsPS_SHOW_VAL, PS_RECESSED, PS_LED, PS_VERTICAL, PS_PERCENT. ConstructorThe default values construct a progress bar that displays both text and a graphical value. The graphical indicator has a raised border. The progress bar has a range of 0 to 100, and displays a "%" sign after the output value. Method DrawChecks for and draws the LED bar style. Method SetFontModifies the font used to display the progress bar value. Method UpdateUpdates the progress bar completion value. The progress bar will automatically redraw to reflect the new value if the bDraw value is TRUE. Method ValueReturns the current progress bar value. ExamplesThe following is a PegWindow containing several styles of PegProgressBar: The source code used to create the above example can be found in the file Pegdemo.cpp. The window class is named ProgBarWindow.
|