Home |
HMI (Human-Machine Interface) Classes Class PegBitmapLight |
Class PegBitmapLightPegBitmapLight is a state driven object that allows for graphically displaying data states using a bitmap. Style FlagsPegBitmapLight does not support any styles. SignalsPegBitmapLight does not send any signals. class PegBitmapLight : public PegLight { public: PegBitmapLight(const PegRect &Size, PEGUINT wNumStates); PegBitmapLight(PEGINT iLeft, PEGINT iTop, PEGUINT wNumStates); virtual void Draw(void); virtual PEGUINT SetNumStates(PEGUINT wNumStates); BOOL SetStateBitmap(PEGUINT wState, PegBitmap * pBmp); protected: PegBitmap * * mpStateBitmap; }; ConstructorsThe first constructor takes a reference to a PegRect to determine its size, and a PEGUINT value for the number of states it supports. 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 designations for left and top where the object will be located. By default, the newly created PegBitmapLight object will size itself to the height and width of the first bitmap added with the SetStateBitmap method. Method DrawPegBitmapLight overrides the Draw() function to draw the correct bitmap for the current state of the light. Method SetNumStatesThis method allows resetting the number of states supported by the object at runtime. It will copy over the bitmaps that were already assigned to it, if there are any. If the new number of states is less than the previous number of states, it will only copy over as many as are newly assigned. If the new number of states is greater, then it will copy all of the previous bitmaps, and NULL out the remainder. It will also set the current state to a valid state if the current state is beyond the range of the number of states. Method SetStateBitmapThis method allows a bitmap to be associated with a state. It returns a boolean for success or failure. It will fail if wState is less than 0 or greater than maximum states - 1. ExamplesThe following is an example of a PegBitmapLight object on a PegDecoratedWindow. This particular light has 3 states. It is coincidental that this happens to be a bitmap of a traffic light. The bitmap associated with a state can be whatever is most useful in conveying the state of the object based on what the real world object is portraying. The above PegBitmapLight object was created by the following code snippet: 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);
|