Public Member Functions

# wxBufferedDC Class Reference
[Device Contexts]

`#include <wx/dcbuffer.h>`

Inheritance diagram for wxBufferedDC:
[legend]

## Detailed Description

This 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, using the associated wxDC, only once, when this object is destroyed.

wxBufferedDC itself is typically associated with wxClientDC, if you want to use it in your `EVT_PAINT` handler, you should look at wxBufferedPaintDC instead.

When used like this, a valid DC must be specified in the constructor while the buffer bitmap doesn't have to be explicitly provided, by default this class will allocate the bitmap of required size itself. However using a dedicated bitmap can speed up the redrawing process by eliminating the repeated creation and destruction of a possibly big bitmap. Otherwise, wxBufferedDC can be used in the same way as any other device context.

There is another possible use for wxBufferedDC is to use it to maintain a backing store for the window contents. In this case, the associated DC may be NULL but a valid backing store bitmap should be specified.

Finally, please note that GTK+ 2.0 as well as OS X provide double buffering themselves natively. You can either use wxWindow::IsDoubleBuffered() to determine whether you need to use buffering or not, or use wxAutoBufferedPaintDC to avoid needless double buffering on the systems which already do it automatically.

##

Library: wxCore
Category: Device Contexts

See also:
  wxDC, wxMemoryDC, wxBufferedPaintDC, wxAutoBufferedPaintDC

## Public Member Functions
| wxBufferedDC ()
| Default constructor.
| wxBufferedDC (wxDC *dc, const wxSize &area, int style=wxBUFFER_CLIENT_AREA)
| Creates a buffer for the provided dc.
| wxBufferedDC (wxDC *dc, wxBitmap &buffer=wxNullBitmap, int style=wxBUFFER_CLIENT_AREA)
| Creates a buffer for the provided dc.
virtual | ~wxBufferedDC ()
| Copies everything drawn on the DC so far to the underlying DC associated with this object, if any.
void | Init (wxDC *dc, const wxSize &area, int style=wxBUFFER_CLIENT_AREA)
| Initializes the object created using the default constructor.
void | Init (wxDC *dc, wxBitmap &buffer=wxNullBitmap, int style=wxBUFFER_CLIENT_AREA)
| Initializes the object created using the default constructor.

List of all members.

## Constructor & Destructor Documentation

wxBufferedDC::wxBufferedDC | ( |  | ) |

Default constructor.

You must call one of the Init() methods later in order to use the device context.

wxBufferedDC::wxBufferedDC | ( | wxDC * | dc,
|  | const wxSize & | area,
|  | int | style = `wxBUFFER_CLIENT_AREA` |
| ) |  |  |

Creates a buffer for the provided dc.

Init() must not be called when using this constructor.

Parameters:

  | dc | 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.
  | area | The size of the bitmap to be used for buffering (this bitmap is created internally when it is not given explicitly).
  | style | 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.

wxBufferedDC::wxBufferedDC | ( | wxDC * | dc,
|  | wxBitmap & | buffer = `wxNullBitmap`,
|  | int | style = `wxBUFFER_CLIENT_AREA` |
| ) |  |  |

Creates a buffer for the provided dc.

Init() must not be called when using this constructor.

Parameters:

  | dc | 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.
  | buffer | 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.
  | style | 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.

virtual wxBufferedDC::~wxBufferedDC | ( |  | ) | `[virtual]`

Copies everything drawn on the DC so far to the underlying DC associated with this object, if any.

## Member Function Documentation

void wxBufferedDC::Init | ( | wxDC * | dc,
|  | const wxSize & | area,
|  | int | style = `wxBUFFER_CLIENT_AREA` |
| ) |  |  |

Initializes the object created using the default constructor.

Please see the constructors for parameter details.

void wxBufferedDC::Init | ( | wxDC * | dc,
|  | wxBitmap & | buffer = `wxNullBitmap`,
|  | int | style = `wxBUFFER_CLIENT_AREA` |
| ) |  |  |

Initializes the object created using the default constructor.

Please see the constructors for parameter details.

|  | [ top ]