KwikPeg Manuals
Home
PegColorLight
Examples
Examples
Index
Index


Members
Styles
Signals
(none)
Overview Derived from class PegLight

The PegColorLight class creates a statelight that uses a shape (circle or rectangle) and color to provide state information.

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

To use the PegColorLight class or its derivatives, your KwikPeg configuration must have the following options enabled:
  Drawing: HMI graphics
  Drawing: Polygons, circles, ellipses and patterned lines



 See Also

PegBitmapLight



 Styles

The PegColorLight class supports the following style flags:

FF_NONE No frame.
FF_THIN Thin frame.
FF_THICK Thick 3D frame.
FF_RAISED Raised 3D frame.
FF_RECESSED Recessed 3D frame.
LS_CIRCLE  If this style flag is used, the statelight will be drawn as a circle filled with the statelight's current state color. The circle will have a shadowed border. This style flag and LS_RECTANGLE are mutually exclusive.
LS_RECTANGLE  If this style flag is used, the statelight will be drawn as a rectangle filled with the statelight's current state color. This style flag and LS_CIRCLE are mutually exclusive.
AF_TRANSPARENT  If this style flag and LS_CIRCLE are set, the background color around the circle will be that of the statelight's parent object. If the statelight has no parent, the background color of the statelight object will be used. This style flag is ignored if the statelight is a rectangle.

Top of page


 Members

Constructors:

PegColorLight(const PegRect &Rect,
  WORD wNumStates,
  WORD wStyle = FF_RAISED | LS_RECTANGLE)
PegColorLight(SIGNED iLeft, SIGNED iTop,
  WORD wNumStates,
  WORD wStyle = FF_RAISED | LS_RECTANGLE)

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

The second constructor creates a PegColorLight 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.

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.

The frame style will be governed by the style flags provided by parameter wStyle. The style flags also specify the shape of the statelight object.

If a rectangle is used for the statelight (style flag LS_RECTANGLE), the object's client area will be filled with the state color.

If a circle is used for the statelight (style flag LS_CIRCLE), the circle will be centered in the object's client area. The circle will be filled with the state color. If the AF_TRANSPARENT style flag is set, the color of the background around the circle will be determined by the background color of the statelight's parent. Otherwise the background color will be determined by the background color of the statelight object.

 

Public Functions:

virtual void Draw(void)

The PegColorLight class overrides the Draw() function to draw the statelight shape in the color 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 colors will be preserved. If wNumStates is greater than the current number of states, all of the currently assigned colors will be preserved. The additional states will not have colors assigned to them.

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

BOOL SetStateColor(
  WORD wState,
  COLORVAL tColor)

This function sets the color for state wState to the color specified by parameter tColor. 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 color for a state before allowing the statelight to be drawn in that state. The state color, once set, remains set until you choose to alter it, if ever.


Top of page


 Examples

The following example illustrates two statelights derived from the PegColorLight class and drawn within a decorated window. These statelights show the use of the LS_RECTANGLE and LS_CIRCLE style flags. The statelight on the left is drawn with a raised border. The one on the right uses the AF_TRANSPARENT style flag to allow the window background to surround the circle.

 
The PegColorLight objects illustrated above were created by the following code fragment:

    PegColorLight *mpLight1, *mpLight2;
    :
    :
    PegRect LightRect = mClient;
    LightRect.wTop += 20;
    LightRect.wLeft += 20;
    LightRect.wRight = LightRect.wLeft + 100;
    LightRect.wBottom = LightRect.wTop + 100;

    mpLight1 = new PegColorLight(LightRect, 3,
        FF_RAISED | LS_RECTANGLE);
    mpLight1->SetStateColor(0, RED);
    mpLight1->SetStateColor(1, BLUE);
    mpLight1->SetStateColor(2, GREEN);
    mpLight1->SetState(1, FALSE);
    Add(mpLight1);

    LightRect.Shift(120, 0);

    mpLight2 = new PegColorLight(LightRect, 4,
       LS_CIRCLE | FF_RECESSED | AF_TRANSPARENT);
    mpLight2->SetStateColor(0, CYAN);
    mpLight2->SetStateColor(1, BLUE);
    mpLight2->SetStateColor(2, GREEN);
    mpLight2->SetStateColor(3, LIGHTGREEN);
    mpLight1->SetState(3, FALSE);
    Add(mpLight2);



Top of page
KwikPeg Manuals
Home
Index
Index

 
Copyright © 2000-2003