]>
git.saurik.com Git - wxWidgets.git/blob - interface/dcbuffer.h
1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: interface of wxBufferedDC
4 // Author: wxWidgets team
6 // Licence: wxWindows license
7 /////////////////////////////////////////////////////////////////////////////
13 This class provides a simple way to avoid flicker: when drawing on it,
14 everything is in fact first drawn on an in-memory buffer (a
15 wxBitmap) and then copied to the screen, using the
16 associated wxDC, only once, when this object is destroyed. wxBufferedDC itself
17 is typically associated with wxClientDC, if you want to
18 use it in your @c EVT_PAINT handler, you should look at
19 wxBufferedPaintDC instead.
21 When used like this, a valid @e dc must be specified in the constructor
22 while the @e buffer bitmap doesn't have to be explicitly provided, by
23 default this class will allocate the bitmap of required size itself. However
24 using a dedicated bitmap can speed up the redrawing process by eliminating the
25 repeated creation and destruction of a possibly big bitmap. Otherwise,
26 wxBufferedDC can be used in the same way as any other device context.
28 There is another possible use for wxBufferedDC is to use it to maintain a
29 backing store for the window contents. In this case, the associated @e dc
30 may be @NULL but a valid backing store bitmap should be specified.
32 Finally, please note that GTK+ 2.0 as well as OS X provide double buffering
33 themselves natively. You can either use wxWindow::IsDoubleBuffered
34 to determine whether you need to use buffering or not, or use
35 wxAutoBufferedPaintDC to avoid needless double
36 buffering on the systems which already do it automatically.
41 @see wxDC, wxMemoryDC, wxBufferedPaintDC, wxAutoBufferedPaintDC
43 class wxBufferedDC
: public wxMemoryDC
48 If you use the first, default, constructor, you must call one of the
49 Init() methods later in order to use the object.
50 The other constructors initialize the object immediately and @c Init()
51 must not be called after using them.
54 The underlying DC: everything drawn to this object will be
55 flushed to this DC when this object is destroyed. You may pass @NULL
56 in order to just initialize the buffer, and not flush it.
58 The size of the bitmap to be used for buffering (this bitmap is
59 created internally when it is not given explicitly).
61 Explicitly provided bitmap to be used for buffering: this is
62 the most efficient solution as the bitmap doesn't have to be recreated each
63 time but it also requires more memory as the bitmap is never freed. The
65 should have appropriate size, anything drawn outside of its bounds is
68 wxBUFFER_CLIENT_AREA to indicate that just the client area of
69 the window is buffered, or wxBUFFER_VIRTUAL_AREA to indicate that the
71 covers the virtual area (in which case PrepareDC is automatically called
76 wxBufferedDC(wxDC
* dc
, const wxSize
& area
,
77 int style
= wxBUFFER_CLIENT_AREA
);
78 wxBufferedDC(wxDC
* dc
, wxBitmap
& buffer
,
79 int style
= wxBUFFER_CLIENT_AREA
);
83 Copies everything drawn on the DC so far to the underlying DC associated with
90 These functions initialize the object created using the default constructor.
91 Please see @ref ctor() "constructors documentation" for details.
93 void Init(wxDC
* dc
, const wxSize
& area
,
94 int style
= wxBUFFER_CLIENT_AREA
);
95 void Init(wxDC
* dc
, wxBitmap
& buffer
,
96 int style
= wxBUFFER_CLIENT_AREA
);
103 @class wxAutoBufferedPaintDC
104 @wxheader{dcbuffer.h}
106 This wxDC derivative can be used inside of an @c OnPaint() event handler to
108 double-buffered drawing. Just create an object of this class instead of
110 and make sure wxWindow::SetBackgroundStyle is called
111 with wxBG_STYLE_CUSTOM somewhere in the class initialization code, and that's
113 to do to (mostly) avoid flicker.
115 The difference between wxBufferedPaintDC and this class,
116 is the lightweigthness - on platforms which have native double-buffering,
117 wxAutoBufferedPaintDC is simply
118 a typedef of wxPaintDC. Otherwise, it is a typedef of wxBufferedPaintDC.
123 @see wxDC, wxBufferedPaintDC
125 class wxAutoBufferedPaintDC
: public wxBufferedPaintDC
129 Constructor. Pass a pointer to the window on which you wish to paint.
131 wxAutoBufferedPaintDC(wxWindow
* window
);
137 @class wxBufferedPaintDC
138 @wxheader{dcbuffer.h}
140 This is a subclass of wxBufferedDC which can be used
141 inside of an @c OnPaint() event handler. Just create an object of this class
143 of wxPaintDC and make sure wxWindow::SetBackgroundStyle
144 is called with wxBG_STYLE_CUSTOM somewhere in the class initialization code,
146 you have to do to (mostly) avoid flicker. The only thing to watch out for is
148 using this class together with wxScrolledWindow, you probably
149 do @b not want to call wxScrolledWindow::PrepareDC on it as it
150 already does this internally for the real underlying wxPaintDC.
155 @see wxDC, wxBufferedDC, wxAutoBufferedPaintDC
157 class wxBufferedPaintDC
: public wxBufferedDC
162 As with @ref wxBufferedDC::ctor wxBufferedDC, you may either provide the
163 bitmap to be used for buffering or let this object create one internally (in
164 the latter case, the size of the client part of the window is used).
165 Pass wxBUFFER_CLIENT_AREA for the @a style parameter to indicate that just the
167 the window is buffered, or wxBUFFER_VIRTUAL_AREA to indicate that the buffer
169 covers the virtual area (in which case PrepareDC is automatically called for
173 wxBufferedPaintDC(wxWindow
* window
, wxBitmap
& buffer
,
174 int style
= wxBUFFER_CLIENT_AREA
);
175 wxBufferedPaintDC(wxWindow
* window
,
176 int style
= wxBUFFER_CLIENT_AREA
);
180 Copies everything drawn on the DC so far to the window associated with this
181 object, using a wxPaintDC.