Home |
Class PegSlider HMI (Human-Machine Interface) Classes |
Class PegSliderPegSlider is an analog adjustment control. The end user adjusts the slider value by dragging the slider handle. PegSlider can be either horizontal or vertical. The orientation is determined by the height and width of the passed in position rectangle. PegSlider draws tickmarks at specified intervals along the slider range, unless the specified interval < 1. The slider handle and tickmarks are automatically drawn proportional to the overall slider size. PegSlider sends PSF_SLIDER_CHANGE notification signals to the slider parent when the user adjusts the slider value. class PegSlider : public PegThing { public: PegSlider(const PegRect &Rect, int iMin, int iMax, PEGUINT wId = 0, PEGUINT wStyle = FF_RAISED, int iScale = -1); virtual PEGINT Message(const PegMessage &Mesg); virtual void Draw(void); void SetMinValue(int iMin); void SetMaxValue(int iMax); void SetScale(int iScale); int GetMinValue(void); int GetMaxValue(void); int GetScale(void); void SetCurrentValue(int iNewVal, BOOL bDraw = FALSE); int GetCurrentValue(void); void Reset(int iMin, int iMax, int iNew); }; Demo programs Robot and PegDemo use this class. Style FlagsFF_NONE, FF_THIN, FF_RAISED, FF_RECESSED, SF_SNAP, SF_SCALE, SF_VALUE. SignalsPegSlider sends PSF_SLIDER_CHANGE to the slider parent when adjusted by the user. pSource pointers to slider control, Data is the slider's ID value, and lData is the current slider value. ConstructorsThe PegSlider constructor creates a PegSlider control at the position and size specified in Rect. The iMin and iMax values specify the initial limits of the slider. The slider Id, if non-zero, enables the PSF_SLIDER_CHANGE notification signal. The slider scale determines the interval between slider tickmarks. Method DrawPegSlider overrides the Draw() function to draw the slider control. Method GetCurrentValueReturns the current slider value. Method GetMinValueReturns the slider minimum limit value. Method GetMaxValueReturns the slider maximum limit value. Method GetScaleReturns the slider scale interval. Method MessagePegSlider catches the PM_LBUTTONDOWN to capture the pointer and move the slider button as it receives PM_POINTER_MOVE messages. Method ResetResets the slider limits and current slider value. Method SetScaleResets the slider tickmark interval. Method SetCurrentValueResets the current slider value. Method SetMaxValueResets the slider maximum limit value. Method SetMinValueResets the slider minimum limit value. Examples:The following are each different styles of PegSlider: The following function creates a PegSlider. The slider will be vertical, and will have a minimum value of 0, a maximum value of 200, and a tick mark interval of 20 (i.e. 10 tickmarks will be drawn). This initial slider value will be 50. void MyWindow::AddSlider(void) { PegRect SliderRect; SliderRect.Set(20, 20, 60, 120); PegSlider * pSlider = new PegSlider(SliderRect, 0, 200, ID_SLIDER, 20); pSlider->SetCurrentValue(50); Add(pSlider); }
|