KwikPeg Manuals
Home
PegBitmapLight
Examples
Examples
Index
Index


Members
Styles
(none)
Signals
(none)
Overview Derived from class PegLight

The PegBitmapLight class creates a statelight that uses a bitmap image to graphically provide state information.

The PegBitmapLight class supports up to 65535 possible states for each derived statelight object.

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



 See Also

PegColorLight


Top of page


 Members

Constructors:

PegBitmapLight(const PegRect &Rect,
  WORD wNumStates)
PegBitmapLight(SIGNED iLeft, SIGNED iTop,
  WORD wNumStates)

The first constructor creates a PegBitmapLight statelight in the rectangle specified by parameter Rect.

The second constructor creates a PegBitmapLight statelight with its top left corner located at (iLeft,iTop). By default, an object created in this fashion will have a width and height of 100 pixels. However, the newly created statelight will size itself to the height and width of the first bitmap which you add to the statelight using function SetStateBitmap().

For both constructors, the following parameters are provided.

Parameter wNumStates defines the number of states which the statelight can assume. The allowable states are numbered from 0 to wNumStates-1. The initial state is set to 0.

 

Public Functions:

virtual void Draw(void)

The PegBitmapLight class overrides the Draw() function to draw the statelight bitmap image which correlates to the current state of the statelight.

virtual WORD SetNumStates(WORD wNumStates)

This function sets the number of states supported by the statelight to wNumStates. If wNumStates is 0, the number of states is left unaltered. If the current state of the statelight exceeds the revised upper limit, the current state is set to wNumStates-1.

If wNumStates is less than the current number of states, only the first wNumStates of the currently assigned bitmap images will be preserved. If wNumStates is greater than the current number of states, all of the currently assigned bitmap images will be preserved. The additional states will not have bitmaps assigned to them.

This function returns the revised number of states supported by the statelight.

BOOL SetStateBitmap(
  WORD wState,
  PegBitmap *pBmp)

This function sets the bitmap for state wState to the bitmap image referenced by parameter pBmp. This function returns TRUE if successful. If wState is outside the range 0 to mwNumStates-1, where mwNumStates is the maximum number of states which the statelight supports, the request is ignored and the value FALSE is returned.

You must set the bitmap image for a state before allowing the statelight to be drawn in that state. The state bitmap image, once set, remains set until you choose to alter it, if ever.


Top of page


 Examples

The following example illustrates a statelight derived from the PegBitmapLight class and drawn within a decorated window. The statelight has three states with a separate traffic light bitmap image for each.

 
The PegBitmapLight object illustrated above was created by the following code fragment:

    extern PegBitmap gbgreenltBitmap;
    extern PegBitmap gbredltBitmap;
    extern PegBitmap gbyellowltBitmap;
    :
    :
    PegBitmapLight *mpLight1;
    :
    :
    PegRect LightRect = mClient;
    LightRect.wTop += 20;
    LightRect.wLeft += 20;
    LightRect.wRight = LightRect.wLeft + 150;
    LightRect.wBottom = LightRect.wTop + 150;

    mpLight1 = new PegBitmapLight(LightRect, 3);
    mpLight1->SetStateBitmap(2, &gbredltBitmap);
    mpLight1->SetStateBitmap(1, &gbyellowltBitmap);
    mpLight1->SetStateBitmap(0, &gbgreenltBitmap);
    Add(mpLight1);



Top of page
KwikPeg Manuals
Home
Index
Index

 
Copyright © 2000-2003