Home |
Class PegAnimationWindow HMI (Human-Machine Interface) Classes |
Class PegAnimationWindowPegAnimationWindow is a window class for displaying a series of PegBitmap images. If these images are displayed in rapid sequence, the effect if smooth motion animation is produced. PegAnimationWindow allows the programmer to specify the position and size of each displayed frame. The animation can be run automatically by PegAnimationWindow via the Start() function, or individual frames may be displayed by the caller. PegAnimationWindow can be used in applications which support multiple palettes, and will install the correct palette for the animation when displayed. The default operation of PegAnimationWindow is to render each animation frame to video memory during program execution. Custom implementations are often modified to render all frames into unused portions of video memory when PegAnimationWindow is initially displayed, and then use the video hardware bit-blitting functions to draw each frame on the visible screen. This yields superior performance on platforms which have advanced video controller hardware. An x and y offset value may be specified for the animation window. This value indicates the offset from the window origin to the display the animation frames. This allows the animation frames to be part of a larger background bitmap. Note that each animation frame must be displayed in the same relative position, i.e. there are not unique offset values for each frame. class PegAnimationWindow : public PegWindow { public: PegAnimationWindow(const PegRect &Rect, PegBitmap * pBackground, PegBitmap * * FrameList, UCHAR uNumFrames, PEGINT xPos, PEGINT yPos, UCHAR * Palette = NULL, PEGUINT wStyle = FF_NONE); PEGINT Message(const PegMessage &Mesg); virtual void Draw(void); virtual void Run(PEGUINT wPeriod, UCHAR uFrame = 0); virtual void Stop(void); virtual void SetFrame(UCHAR uFrame = 0); }; Demo program Robot uses this class. Style FlagsFF_NONE, FF_THIN, FF_RAISED, FF_RECESSED, FF_THICK. ConstructorParameter pBackground is a pointer to the background bitmap for the animation. pBackground may be NULL if no background is desired. pFrameList is the address of an array of PegBitmap images. These images are displayed in sequence when the animation window runs. The animation window will wrap back to the start frame after displaying the final frame, allowing continuous animation to be displayed. uNumFrames indicates the total number of frames in the frame list. xPos and yPos indicate the upper-left corner position at which the animation frames will be displayed. This allows the animation window to be larger than and offset relative to the actual animation bitmaps. pPallete is a pointer to an array of unsigned characters. This array is typically generated by PegImageConvert. The array should contain the RGB (Red, Green, Blue) values for the palette desired. There number of entries in the array should be 3 * NUM_COLORS. wStyle is used to set the frame style for the animation window. The default is to display no frame, allowing the animation window to be placed within a larger parent window and provide a seamless animation appearance. Method DrawPegAnimationWindow overrides the Draw() function to display the animation bitmaps. Method MessagePegAnimationWindow overrides the Message method to set the custom palette (if there is one), when the window is displayed and to draw the correct animation frame when the timer message is received. Method RunStarts the animation sequence. The parameter wPeriod is used to indicate the number of ticks which should elapse between the display of each animation frame. Method SetFrameResets the animation frame, or manually displays the animation sequence. Method StopStops the animation playback sequence. ExampleAn example of creating and using PegAnimationWindow can be found in program Robot.
|