Home |
HMI (Human-Machine Interface) Classes Class PegScale |
Class PegScalePegScale is the base class for PegLinearScale and PegLinearBitmapScale. PegScale facilitates a graphical representation of any given value in relation to a minimum and maximum value. class PegScale : public PegThing { public: PegScale(const PegRect &Size, LONG lMinValue, LONG lMaxValue, PEGUINT wStyle); PegScale(PEGINT iLeft, PEGINT iTop, LONG lMinValue, LONG lMaxValue, PEGUINT wStyle); virtual void SetValue(LONG lVal, BOOL bRedraw = TRUE); virtual LONG IncrementValue(LONG lVal, BOOL bRedraw = TRUE); LONG GetCurrentValue(void) const COLORVAL GetNeedleColor(void) const; void SetNeedleColor(COLORVAL tColor); LONG GetMinValue(void) const; void SetMinValue(LONG lVal, BOOL bRedraw = TRUE); LONG GetMaxValue(void) const; void SetMaxValue(LONG lVal, BOOL bRedraw = TRUE); protected: virtual void DrawNeedle(void); virtual void ValToPoint(LONG lVal, PegPoint& tPoint); virtual void SetTravelPoints(void); virtual void CalcClipAndDraw(void); virtual void CalcNeedleRect(const PegPoint& tPoint, PegRect& Rect); LONG mlCurValue; LONG mlMinValue; LONG mlMaxValue; PEGINT miMinTravel; PEGINT miMaxTravel; COLORVAL mtNeedleColor; PegPoint mtNeedlePoint; BOOL mbValueSet; }; Style FlagsPegScale supports the standard PegThingstyles for borders: FF_NONE, FF_THIN, FF_RECESSED and FF_RAISED. PegScale also supports the following additional styles: SS_FACELEFTIf the scale is vertical, this will cause the needle to face (point) to the left. If this flag is cleared and the scale is vertical, then the needle will face to the right. SS_FACETOPIf the scale is horizontal, this will cause the needle to face (point) to the top. If this flag is cleared and the scale is horizontal, then the needle will face the bottom. SS_BOTTOMTOTOPIf the scale is vertical, this will map the minimum value to the bottom of the scale. If this flag is cleared, and the scale is vertical, the minimum value will map to the top, making larger values drive the needle toward the bottom. SS_LEFTTORIGHTIf the scale is horizontal, this will map the minimum value to the left side of the scale. If this flag is cleared, and the scale is horizontal, the minimum value will map to the right, making larger values drive the needle toward the left. SS_ORIENTVERTThis flag forces the scale to orient itself vertically, with no regard to its bounding rectangle. Clearing this flag will force the scale to orient itself horizontally. SS_TICMARKSIf supported by the derived class, the scale will draw tick marks at user defined intervals when this flag is set. The tick marks are always drawn on the opposite side of the scale as the needle. Therefore, if the scale is oriented vertically, and the needle is facing the left, the tick marks will be drawn on the left side of the scale. SS_USERTRAVELIf this flag is set, the user may specify the start and end points that the scale will use when mapping values on the scale. By default, the scale uses its entire length, minus a few pixels, for its track. Setting this flag allows the user to restrict the travel of the needle to a specific region. SS_THINNEEDLEThis flag causes the needle to be drawn with a single thin line. SS_THICKNEEDLEThis flag causes the needle to be drawn with a single thick line. SS_POLYNEEDLEThis flag causes the needle to be drawn using a filled polygon. SS_STANDARDSTYLEThis flag ORs the SS_FACELEFT, SS_BOTTOMTOTOP, SS_ORIENTVERT, SS_TICMARKS and SS_POLYNEEDLE flags together. AF_TRANSPARENTThis flag causes the background of the scale to be drawn using the same color as its parent. This flag does not apply to PegLinearBitmapScale. SignalsPegScale does not send any signals. ConstructorsThe first constructor takes a reference to a PegRect to determine its size, a minimum value and a maximum value, and a style PEGUINT. The second constructor takes PEGINT values for the left and top of the object. By default, this will create a scale with a width of 100 pixels and a height of 150 pixels. It also takes LONG's for the minimum and maximum values of the scale, and a PEGUINT for the style. Method GetCurrentValueThis inline method returns the current value of the scale. Method GetNeedleColorThis inline method returns the current color of the needle as a COLORVAL. Method GetMaxValueThis inline method returns the current maximum value for the scale. Method GetMinValueThis inline method returns the current minimum value for the scale. Method IncrementValueThis method increments the current value of the scale by lValue. If the new value is less than the minimum value, then the current value is set to the minimum. If the new value is greater than the maximum value, then the new value is set to the maximum value. The method returns the current value. Method SetMaxValueThis method sets the current maximum value of the scale, and optionally redraws the scale. Method SetMinValueThis method sets the minimum value of the scale and optionally redraws it. Method SetNeedleColorThis inline method sets the current color of the needle. Method SetValueThis method sets the current value of the scale, and will optionally redraw the scale. If lValue is less than the minimum value or greater than the maximum value, then the internal value is left unchanged. ExamplesSee PegLinearScale or PegLinearBitmapScale for examples of PegScale derived objects.
|