From 116627da194fc2ff567a1b3cc7d961dc6a34b7b6 Mon Sep 17 00:00:00 2001 From: Robin Dunn Date: Tue, 8 Mar 2005 00:38:53 +0000 Subject: [PATCH] Allow wxBufferedDC to be constructed with just a wxDC. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@32661 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/dcbuffer.h | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/include/wx/dcbuffer.h b/include/wx/dcbuffer.h index e7ccff4f55..cac6228a8e 100644 --- a/include/wx/dcbuffer.h +++ b/include/wx/dcbuffer.h @@ -37,7 +37,9 @@ public: } // Construct a wxBufferedDC using a user supplied buffer. - wxBufferedDC(wxDC *dc, const wxBitmap &buffer, int style = wxBUFFER_CLIENT_AREA) + wxBufferedDC(wxDC *dc, + const wxBitmap &buffer = wxNullBitmap, + int style = wxBUFFER_CLIENT_AREA) : m_dc( dc ), m_buffer( buffer ), m_style(style) @@ -67,7 +69,9 @@ public: // These reimplement the actions of the ctors for two stage creation, but // are not used by the ctors themselves to save a few cpu cycles. - void Init(wxDC *dc, const wxBitmap &buffer, int style = wxBUFFER_CLIENT_AREA) + void Init(wxDC *dc, + const wxBitmap &buffer=wxNullBitmap, + int style = wxBUFFER_CLIENT_AREA) { wxASSERT_MSG( m_dc == 0 && m_buffer == wxNullBitmap, _T("wxBufferedDC already initialised") ); @@ -112,7 +116,12 @@ private: // check that the bitmap is valid and use it void UseBuffer() { - wxASSERT_MSG( m_buffer.Ok(), _T("invalid bitmap in wxBufferedDC") ); + if (!m_buffer.Ok()) + { + wxCoord w, h; + m_dc->GetSize(&w, &h); + m_buffer = wxBitmap(w, h); + } SelectObject(m_buffer); } -- 2.45.2