|
Main Page
Class Hierarchy
Alphabetical List
Compound List
File List
Compound Members
|
00001 /********************************************************************************
00002 * *
00003 * B a c k B u f f e r e d C a n v a s W i d g e t *
00004 * *
00005 *********************************************************************************
00006 * Copyright (C) 2003 by Davy Durham. With coding tips from Jeroen van der Zijp *
00007 *********************************************************************************
00008 * This library is free software; you can redistribute it and/or *
00009 * modify it under the terms of the GNU Lesser General Public *
00010 * License as published by the Free Software Foundation; either *
00011 * version 2.1 of the License, or (at your option) any later version. *
00012 * *
00013 * This library is distributed in the hope that it will be useful, *
00014 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
00015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
00016 * Lesser General Public License for more details. *
00017 * *
00018 * You should have received a copy of the GNU Lesser General Public *
00019 * License along with this library; if not, write to the Free Software *
00020 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
00021 ********************************************************************************/
00022 #ifndef FXBACKBUFFEREDCANVAS_H
00023 #define FXBACKBUFFEREDCANVAS_H
00024
00025 #ifndef FXCANVAS_H
00026 #include <fox/FXCanvas.h>
00027 using namespace FX;
00028 #endif
00029 namespace FXEX {
00030
00031
00032 /**
00033 * Back Buffered Canvas, an area drawn by another object, except a little more
00034 * expensive but to reduce flicker
00035 */
00036 class FXAPI FXBackBufferedCanvas : public FXCanvas {
00037 FXDECLARE(FXBackBufferedCanvas)
00038
00039 private:
00040 FXImage *backBuffer; // the off-screen buffer
00041 FXDC *currentDC; // handle to current FXDC
00042 FXbool inOnPaintEvent; // figure out if we are in a paint event
00043
00044 protected:
00045 /// serialisation
00046 FXBackBufferedCanvas();
00047
00048 public:
00049 long onPaint(FXObject *sender,FXSelector sel,void *ptr);
00050 long onConfigure(FXObject *sender,FXSelector sel,void *ptr);
00051
00052 public:
00053 /// Construct new back buffered drawing canvas widget
00054 FXBackBufferedCanvas(FXComposite* p,FXObject* tgt=NULL,FXSelector sel=0,FXuint opts=FRAME_NORMAL,FXint x=0,FXint y=0,FXint w=0,FXint h=0);
00055
00056 /// create resources
00057 void create();
00058
00059 /*
00060 * - This can be used to set the options of the back buffer to include
00061 * IMAGE_OWNED so that the drawing code can call getBackBufferData()
00062 * and render/modify the back buffer.
00063 * - When IMAGE_OWNED is included in the options, then backBuffer->render()
00064 * will be called just before the backbuffer is blitted to the screen.
00065 */
00066 void setBackBufferOptions(FXint options);
00067
00068 /// return handle to some backbuffered data
00069 void *getBackBufferData();
00070
00071 /**
00072 * Normally, the user should wait for the SEL_PAINT event to draw the the canvas, in which case
00073 * the ptr parameter would contain the DC to draw to.
00074 *
00075 * However, these two methods need to be used if the user is not waiting for the SEL_PAINT event
00076 * to draw to the canvas since the user should actually be drawing to the back buffer and not the
00077 * actual canvas on screen. (I suppose much more work could be done to make the use of back
00078 * buffering completly transparent and make it have the same interface as FXCanvas)
00079 */
00080 FXDC *beginPaint();
00081
00082 /// finish painting
00083 void endPaint();
00084
00085 /// Save object to stream
00086 virtual void save(FXStream& store) const;
00087
00088 /// Load object from stream
00089 virtual void load(FXStream& store);
00090
00091 /// dtor
00092 virtual ~FXBackBufferedCanvas();
00093
00094 };
00095
00096 } // namespace FXEX
00097 #endif // FXBACKBUFFEREDCANVAS_H