+public:
+ // Default ctor, must subsequently call Init for two stage construction.
+ wxBufferedDC()
+ : m_dc(NULL),
+ m_buffer(NULL),
+ m_style(0)
+ {
+ }
+
+ // Construct a wxBufferedDC using a user supplied buffer.
+ wxBufferedDC(wxDC *dc,
+ wxBitmap& buffer = wxNullBitmap,
+ int style = wxBUFFER_CLIENT_AREA)
+ : m_dc(NULL), m_buffer(NULL)
+ {
+ Init(dc, buffer, style);
+ }
+
+ // Construct a wxBufferedDC with an internal buffer of 'area'
+ // (where area is usually something like the size of the window
+ // being buffered)
+ wxBufferedDC(wxDC *dc, const wxSize& area, int style = wxBUFFER_CLIENT_AREA)
+ : m_dc(NULL), m_buffer(NULL)
+ {
+ Init(dc, area, style);
+ }
+
+ // The usually desired action in the dtor is to blit the buffer.
+ virtual ~wxBufferedDC()
+ {
+ if ( m_dc )
+ UnMask();
+ }
+
+ // These reimplement the actions of the ctors for two stage creation
+ void Init(wxDC *dc,
+ wxBitmap& buffer = wxNullBitmap,
+ int style = wxBUFFER_CLIENT_AREA)
+ {
+ InitCommon(dc, style);
+
+ m_buffer = &buffer;
+
+ UseBuffer();
+ }
+
+ void Init(wxDC *dc, const wxSize &area, int style = wxBUFFER_CLIENT_AREA)
+ {
+ InitCommon(dc, style);
+
+ UseBuffer(area.x, area.y);
+ }
+
+ // Blits the buffer to the dc, and detaches the dc from the buffer (so it
+ // can be effectively used once only).
+ //
+ // Usually called in the dtor or by the dtor of derived classes if the
+ // BufferedDC must blit before the derived class (which may own the dc it's
+ // blitting to) is destroyed.
+ void UnMask();