Home |
HMI (Human-Machine Interface) Classes Class PegLinearBitmapScale |
Class PegLinearBitmapScalePegLinearBitmapScale is an output HMI gadget that facilitates a graphical representation of any given value in relation to a minimum and maximum value. PegLinearBitmapScale has the added benefits of allowing the user to specify a background bitmap as well as determining the needle travel start and end points. You may also specify a bitmap that is used to draw the needle. This allows for a very custom look for your scale. Style FlagsSee the PegScale Styles section for a detailed list of styles. PegLinearBitmapScale does not support the SS_TICMARKS style or any of the frame styles because it does not draw its own scale background. It uses the specified bitmap instead. SignalsPegLinearBitmapScale does not send any signals. class PegLinearBitmapScale : public PegScale { public: PegLinearBitmapScale(const PegRect &Size, LONG lMinValue, LONG lMaxValue, PEGINT iMinTravelOffset, PEGINT iMaxTravelOffset, PegBitmap * pBkgBmp, PegBitmap * pNeedleBmp = NULL, PEGUINT wStyle = SS_STANDARDSTYLE); PegLinearBitmapScale(PEGINT iLeft, PEGINT iTop, LONG lMinValue, LONG lMaxValue, PEGINT iMinTravelOffset, PEGINT iMaxTravelOffset, PegBitmap * pBkgBmp, PegBitmap * pNeedleBmp = NULL, PEGUINT wStyle = SS_STANDARDSTYLE); virtual void Draw(void); PegBitmap * GetBkgBitmap(void) const; void SetBkgBitmap(PegBitmap * pBmp); PegBitmap * GetNeedleBitmap(void) const; void SetNeedleBitmap(PegBitmap * pBmp); PEGINT GetNeedleOffset(void) const; void SetNeedleOffset(PEGINT iOffset); PEGINT GetMinTravelOffset(void) const; void SetMinTravelOffset(PEGINT iOffset); PEGINT GetMaxTravelOffset(void) const; void SetMaxTravelOffset(PEGINT iOffset) protected: virtual void SetTravelPoints(void); virtual void CalcNeedleRect(const PegPoint& tPoint, PegRect& Rect); void DrawToComposite(void); void DrawBitmapNeedle(void); PegBitmap * mpBkgBitmap; PegBitmap * mpNeedleBitmap; PegBitmap * mpCompBitmap; PEGINT miNeedleOffset; PEGINT miMinTravelOffset; PEGINT miMaxTravelOffset; }; ConstructorsThe first constructor takes a reference to a PegRect to determine its size, a minimum value and maximum value, an offset for the travel on the minimum side of the scale and an offset for the maximum side of the scale. The travel offset values are expressed in pixels and allow for restricting the needle travel to a specific region of the scale. For example, if the scale is oriented vertically, and you would like to keep the needle at least 100 pixels from the bottom, and the minimum value is at the bottom of the scale, then iMinTravelOffset should be set to 100. The pBkgBitmap parameter is a pointer to a PegBitmap structure that will be used to draw the background of the scale. The pNeedleBmp, if it is not NULL, will be used to draw the needle on the scale. By default the needle is assumed to have its zero travel point in the middle of the bitmap. Therefore, if the scale is oriented vertically, the needle's zero travel point is assumed to be half the height of the bitmap that is used for drawing. See below for an explanation on how to change this behavior. The final parameter is a PEGUINT for the style. Note that this object does not support any frame styles. It is assumed that the background bitmap contains all of the visual elements necessary to properly draw the background and frame of the scale. The second constructor takes PEGINT values to determine its left and top position on the screen. By default, if pBkgBitmap is not NULL, it will assign itself a rectangle the width and height of pBkgBitmap. It then takes the same parameters as the above constructor. Method DrawPegLinearBitmapScale overrides the Draw() function to draw the background bitmap and needle. Method GetBkgBitmapThis inline method returns a pointer to the background bitmap. Method GetMaxTravelOffsetThis inline method returns the travel offset for the maximum end of the scale. Method GetMinTravelOffsetThis inline method returns the travel offset for the minimum end of the scale. Method GetNeedleBitmapThis inline method returns a pointer to the bitmap used to draw the needle. Method GetNeedleOffsetThis inline method returns the current needle offset. Method SetBkgBitmapThis inline method sets the background bitmap to pBmp. Method SetMaxTravelOffsetThis inline method sets the travel offset for the maximum end of the scale. Method SetMinTravelOffsetThis inline method sets the travel offset for the minimum end of the scale. Method SetNeedleBitmapThis inline method sets the needle bitmap to pBmp. Method SetNeedleOffsetThis inline method sets the needle offset. The needle offset refers to the distance from the center of the bitmap that is used for the zero travel point of the needle bitmap. A negative value will move the zero travel reference above the center of the bitmap on vertically oriented scales, and to the left of the center of the bitmap on horizontally oriented scales. Likewise, a positive value will move the reference point below or to the right of center, dependent on the scale's orientation. ExamplesThe example below shows several PegLinearBitmapScale objects on a PegDecoratedWindow. You'll notice on the scale on the far left that travel is restricted to the top 2/3 of the total bounding rectangle of the scale. This allows for a digital readout of the current value to be within the rectangle of the bitmap. The following code snippet shows how to create and display a PegLinearBitmapScale. This particular example is for the scale on the far left of the above window. This also shows that the PegPrompt that displays the current value is added directly to the PegLinearBitmapScale. PegLinearBitmapScale * mpScale1; PegPrompt * mpValPrompt; . . WinRect.Set(50, 50, 125, 250); mpScale1 = new PegLinearBitmapScale(WinRect, 0, 100, 120, 23, &gbbluebkgBitmap, &gbBlueNeedleBitmap, SS_FACELEFT | SS_ORIENTVERT | SS_BOTTOMTOTOP | SS_USERTRAVEL); WinRect.Set(57, 215, 115, 240); mpValPrompt = new PegPrompt(WinRect, "0", 101, FF_RECESSED | TJ_CENTER | TT_COPY); mpScale1->Add(mpValPrompt, FALSE); Add(mpScale1);
|