Home |
HMI (Human-Machine Interface) Classes Class PegLight |
Class PegLightPegLight is the base class for PegColorLight and PegBitmapLight. PegLight provides the basic functionality necessary to implement a state driven object. PegLight is a state light that is capable of graphically displaying the state of an object. Given the necessary amount of memory, it is capable of supporting PEGUINT number of states. This, of course, is target dependent. Style FlagsPegLight supports the standard PegThingstyles for borders: FF_NONE, FF_THIN, FF_RECESSED and FF_RAISED. SignalsPegLight does not send any signals. class PegLight : public PegThing { public: PegLight(const PegRect &Size, PEGUINT wNumStates, PEGUINT wStyle); PegLight(PEGINT iLeft, PEGINT iTop, PEGUINT wNumStates, PEGUINT wStyle); virtual PEGUINT IncrementState(BOOL bRedraw = TRUE); virtual PEGUINT DecrementState(BOOL bRedraw = TRUE); virtual PEGUINT SetState(PEGUINT wState, BOOL bRedraw = TRUE); PEGUINT GetCurrentState(void) const; PEGUINT GetNumStates(void) const; virtual PEGUINT SetNumStates(PEGUINT wNumStates); protected: PEGUINT mwNumStates; PEGUINT mwCurState; }; ConstructorsThe first constructor takes a reference to a PegRect to determine its size, a PEGUINT value for the number of states it supports, and a style PEGUINT. It is important to remember that the light states are 0 based. Therefore, the first state is 0 and the last state is wNumStates - 1. The second constructor takes left and top coordinates for the placement of the light. By default, this will create a light 100 pixels in height and 100 pixels in width. It also takes a PEGUINT for the desired number of states and the typical style word. As stated above, it is important to remember that the states are 0 based. Method DecrementStateThis method decrements the current state of the light. If the state is already at the first state, then it will wrap up to the last state. This method returns the value of the current state of the light. Method GetCurrentStateThis inline method returns the current state of the light. Method GetNumStatesThis inline method returns the total number of states supported by the light. Method IncrementStateThis method increments the current state of the light. If the state is already at the last state, it will wrap back to the first state. This method returns the value of the current state of the light. Method SetNumStatesIn this class, this function merely sets the number of states supported by the object as well as ensures that the current state is within the range of the newly assigned number of states. In the derived classes, PegColorLight and PegBitmapLight, this method provides increased functionality. See those pages for a better description of setting the number of states at runtime after the object has been constructed. virtual PEGUINT SetState(PEGUINT wState, BOOL bRedraw = TRUE) This method attempts to set the current state of the light to wState. If wState is less than zero, or wState is greater than the number of states minus one, then the current state of the light is unchanged. This method returns the current state of the light. ExamplesSee PegColorLight or PegBitmapLight for examples of PegLight derived objects.
|