This simple class provides a simple way to avoid flicker: when drawing on it,
everything is in fact first drawn on an in-memory buffer (a
wxBitmap) and then copied to the screen only once, when this
object is destroyed.
It can be used in the same way as any other device context. wxBufferedDC itself
typically replaces wxClientDC, if you want to use it in
your OnPaint() handler, you should look at
wxBufferedDC(wxDC * dc, const wxSize& area, int style = wxBUFFER_CLIENT_AREA)
wxBufferedDC(wxDC * dc, const wxBitmap& buffer, int style = wxBUFFER_CLIENT_AREA)
If you use the first, default, constructor, you must call one of the
Init methods later in order to use the object.
The other constructors initialize the object immediately and Init()
must not be called after using them.
- The underlying DC: everything drawn to this object will be
flushed to this DC when this object is destroyed. You may pass NULL
in order to just initialize the buffer, and not flush it.
- The size of the bitmap to be used for buffering (this bitmap is
created internally when it is not given explicitly).
- Explicitly provided bitmap to be used for buffering: this is
the most efficient solution as the bitmap doesn't have to be recreated each
time but it also requires more memory as the bitmap is never freed. The bitmap
should have appropriate size, anything drawn outside of its bounds is clipped.
- wxBUFFER_CLIENT_AREA to indicate that just the client area of
the window is buffered, or wxBUFFER_VIRTUAL_AREA to indicate that the buffer bitmap
covers the virtual area (in which case PrepareDC is automatically called for the actual window
void Init(wxDC * dc, const wxSize& area, int style = wxBUFFER_CLIENT_AREA)
void Init(wxDC * dc, const wxBitmap& buffer, int style = wxBUFFER_CLIENT_AREA)
These functions initialize the object created using the default constructor.
Please see constructors documentation for details.
Copies everything drawn on the DC so far to the underlying DC associated with
this object, if any.