KwikPeg Manuals
Home
PegLinearBitmapScale
Examples
Examples
Index
Index


Members
Styles
Signals
(none)
Overview Derived from class PegScale

The PegLinearBitmapScale class implements a linear scale. The linear bitmap scale provides a graphical representation of the value of some measured variable whose value varies between an upper and lower limit.

The linear bitmap scale is drawn within a bounding rectangle but has no frame, tick marks or line of travel indication. Instead, the face of the scale is drawn using a background bitmap image which, if necessary, can provide the frame, tick marks and travel indicator. The bitmap image can include transparent regions, allowing it to float over the background of the scale's parent. The color of the scale needle can be adjusted to provide the proper contrast with the scale's bitmap image. Alternatively, you can specify another bitmap image to be used to draw the needle.

Unlike the PegLinearScale class, the PegLinearBitmapScale class allows the line of travel to be restricted to a specific region within the scale's client area. Using this feature, a scale can be constructed which limits the needle travel to a specific region of the image used for the scale face. See the examples for an illustration of such a scale.

To use the PegLinearBitmapScale class or its derivatives, your KwikPeg configuration must have the following option enabled:
  Drawing: HMI graphics



 See Also

PegScale

PegLinearScale



 Styles

The PegLinearBitmapScale class supports the following style flags:

SS_FACELEFT  This style flag only applies if the scale is mounted vertically.
If this style flag is set, the needle will travel along the right side of the scale and face (point) to the left. If this style flag is reset, the needle will travel along the left side of the scale and face to the right.
SS_FACETOP  This style flag only applies if the scale is mounted horizontally.
If this style flag is set, the needle will travel along the bottom edge of the scale and face (point) upwards. If this style flag is reset, the needle will travel along the top edge of the scale and face downwards.
SS_BOTTOMTOTOP  This style flag only applies if the scale is mounted vertically.
If this style flag is set, the minimum value will be pegged to the bottom extreme of the scale's line of travel. If this style flag is reset, the minimum value will be pegged to the top extreme of the scale's line of travel.
SS_LEFTTORIGHT  This style flag only applies if the scale is mounted horizontally.
If this style flag is set, the minimum value will be pegged to the left extreme of the scale's line of travel. If this style flag is reset, the minimum value will be pegged to the right extreme of the scale's line of travel.
SS_ORIENTVERT  If this style flag is set, the scale will be mounted vertically so that the scale needle moves up and down. If this style flag is reset, the scale will be mounted horizontally so that the scale needle moves left and right.
SS_THINNEEDLE  If this style flag is set, the scale needle will be drawn as a thin single line, 1 pixel wide.
SS_THICKNEEDLE  If this style flag is set, the scale needle will be drawn as a thick single line, 3 pixels wide.
SS_POLYNEEDLE  If this style flag is set, the scale needle will be drawn as a filled polygon.
SS_STANDARDSTYLE  This style flag mask selects the following styles which are commonly used for scales:
SS_FACELEFT | SS_BOTTOMTOTOP | SS_ORIENTVERT | SS_TICMARKS | SS_POLYNEEDLE.
Note that derived classes may only support a subset of these style flags. For example, the linear bitmap scale simply ignores the SS_TICMARKS style flag since tick marks, if needed, can be provided by the bitmap image used for the scale face.
SS_USERTRAVEL  If this style flag is set, the scale's line of travel can be constrained to lie within a particular region of the scale's bounding rectangle. If this style flag is reset, the line of travel will extend to within a few pixels of the scale's bounding rectangle. Derived classes which support this style flag provide member functions to set the limits for the extremities of the line of travel.
AF_TRANSPARENT  If this style flag is set, the background color will be that of the scale's parent object.

The PegLinearBitmapScale class does not support tick marks or any of the frame styles because a bitmap image is used for the background of the scale's client area. Note that the line of travel is also not drawn. A frame, tick marks and line of travel indication can be added to the background bitmap image, if required.


Top of page


 Members

Constructors:

PegLinearBitmapScale(const PegRect &Rect,
  LONG lMinValue, LONG lMaxValue,
  SIGNED iMinTravelOffset,
  SIGNED iMaxTravelOffset,
  PegBitmap *pBkgBmp,
  PegBitmap *pNeedleBmp = NULL,
  WORD wStyle = SS_STANDARDSTYLE)
PegLinearBitmapScale(SIGNED iLeft, SIGNED iTop,
  LONG lMinValue, LONG lMaxValue,
  SIGNED iMinTravelOffset,
  SIGNED iMaxTravelOffset,
  PegBitmap *pBkgBmp,
  PegBitmap *pNeedleBmp = NULL,
  WORD wStyle = SS_STANDARDSTYLE)

The first constructor creates a linear bitmap scale in the rectangle specified by parameter Rect.

The second constructor creates a linear bitmap scale with its top left corner located at (iLeft,iTop). By default, an object created in this fashion will have a width of 100 pixels and a height of 150 pixels. However, if a background image is provided (parameter pBkgBmp is not NULL), the scale will be resized to fit within a rectangle of the same width and height as the background bitmap image.

For both constructors, the following parameters are provided.

Values for the measured variable which the scale represents are restricted to the range lMinValue to lMaxValue.

The minimum measured value is always pegged directly to one end of the scale's line of travel as specified by the scale's style flags. The maximum measured value maps directly to the other end of the line of travel. The needle then travels linearly from its minimum end to its maximum end as the measured value goes from its minimum value to its maximum value.

The travel offset parameters can be used to constrain the length of the needle's line of travel to a certain region of the bitmap image used for the scale face. These parameters are only used if the SS_USERTRAVEL style flag is set, allowing the length of the line of travel to be adjusted. Otherwise, the line of travel will extend close to the edges of the scale's client area.

If the scale is mounted vertically, parameters iMinTravelOffset and iMaxTravelOffset specify the distance, in pixels, from the top of the scale's client area to the upper and lower extremities of the line of travel, respectively.

If the scale is mounted horizontally, parameters iMinTravelOffset and iMaxTravelOffset specify the distance, in pixels, from the left edge of the scale's client area to the left and right extremities of the line of travel, respectively.

Parameter pBkgBmp is a pointer to the bitmap image which will be used as the scale background, forming the scale face. If the bitmap image includes transparent regions, be sure to use the AF_TRANSPARENT style flag so that the image will float over the parent's background or over the scale's background if the scale has no parent.

Parameter pNeedleBmp is a pointer to the needle bitmap image to be drawn at the scale's needle position. If this parameter is NULL, the needle will be drawn as a straight line as for linear scales.

When a bitmap image is used to draw the needle, the needle's position is determined by the middle point of the bitmap image. If the needle travels vertically, the middle of the needle will be determined by the bitmap height. If the needle travels horizontally, the middle of the needle will be determined by the bitmap width.

The scale characteristics will be governed by the style flags provided by parameter wStyle. Note that frame styles are not supported by linear bitmap scales.

 

Public Functions:

virtual void Draw(void)

The PegLinearBitmapScale class overrides the Draw() function to draw the bitmap image background and the scale needle to reflect the current value of the variable which the scale represents.

PegBitmap *GetBkgBitmap(void) const

This function returns a pointer to the PegBitmap bitmap image which is used as the scale background to form the scale face.

SIGNED GetMaxTravelOffset(void) const
void SetMaxTravelOffset(SIGNED iOffset)

These inline functions get or set the maximum travel offset. If the scale is mounted vertically, parameter iOffset specifies the distance, in pixels, from the top of the scale's client area to the lower extremity of the line of travel. If the scale is mounted horizontally, parameter iOffset specifies the distance, in pixels, from the left edge of the scale's client area to the right extremity of the line of travel. These functions have no effect unless the SS_USERTRAVEL style flag is set to allow the length of the line of travel to be adjusted.

SIGNED GetMinTravelOffset(void) const
void SetMinTravelOffset(SIGNED iOffset)

These inline functions get or set the minimum travel offset. These functions have no effect unless the SS_USERTRAVEL style flag is set to allow the length of the line of travel to be adjusted.

If the scale is mounted vertically, parameter iOffset specifies the distance, in pixels, from the top of the scale's client area to the upper extremity of the line of travel.

If the scale is mounted horizontally, parameter iOffset specifies the distance, in pixels, from the left edge of the scale's client area to the left extremity of the line of travel.

PegBitmap *GetNeedleBitmap(void) const

This function returns a pointer to the PegBitmap bitmap image which is used as the needle. The function returns NULL if the object does not have a needle bitmap installed.

SIGNED GetNeedleOffset(void) const
void SetNeedleOffset(SIGNED iOffset)

These inline functions get or set the bitmap needle offset value. These functions only have effect when a bitmap image is being used to draw the scale's needle.

If the scale is mounted vertically, parameter iOffset specifies the distance, in pixels, from the top of the scale's client area to the top edge of the needle's bounding rectangle as it exists when the needle is at the upper extreme of its line of travel.

If the scale is mounted horizontally, parameter iOffset specifies the distance, in pixels, from the left edge of the scale's client area to the left edge of the needle's bounding rectangle as it exists when the needle is at the leftmost extreme of its line of travel.

void SetBkgBitmap(PegBitmap *pBmp)

This inline function sets the background bitmap for the scale face to the bitmap image referenced by parameter pBmp.

void SetNeedleBitmap(PegBitmap *pBmp)

This function sets the bitmap for the needle to the bitmap image referenced by parameter pBmp. The scale is not redrawn.


Top of page


 Examples

The following example illustrates several linear bitmap scales derived from the PegLinearBitmapScale class and drawn within a decorated window. Notice that the leftmost scale has its line of travel restricted to the top region of the scale's bounding rectangle.

 
The leftmost PegLinearBitmapScale object illustrated above was created by the following code fragment. Notice that the PegPrompt object used to display the measured value has been added directly to the PegLinearBitmapScale object.

    extern PegBitmap gbbluebkgBitmap;
    PegLinearBitmapScale *mpScale1;
    PegPrompt *mpValPrompt;
    :
    :
    WinRect.Set(50, 50, 125, 250);
    mpScale1 = new PegLinearBitmapScale(WinRect,
        0, 100, 120, 23, &gbbluebkgBitmap);
    mpScale1->SetNeedleColor(WHITE);
    mpScale1->Style(
        (mpScale1->Style() & ~SS_POLYNEEDLE) |
        SS_THICKNEEDLE);

    WinRect.Set(57, 215, 115, 240);
    mpValPrompt = new PegPrompt(WinRect,
        "61", 101, FF_RECESSED | TJ_CENTER | TT_COPY);
    mpScale1->Add(mpValPrompt, FALSE);

    mpScale1->SetValue(61, FALSE);
    Add(mpScale1);



Top of page
KwikPeg Manuals
Home
Index
Index

 
Copyright © 2000-2003