#pragma hdrstop
#endif
+#include "wx/dcbuffer.h"
+
#ifndef WX_PRECOMP
+ #include "wx/module.h"
#endif
-#include "wx/dcbuffer.h"
+// ============================================================================
+// implementation
+// ============================================================================
+
+// ----------------------------------------------------------------------------
+// wxSharedDCBufferManager: helper class maintaining backing store bitmap
+// ----------------------------------------------------------------------------
+class wxSharedDCBufferManager : public wxModule
+{
+public:
+ wxSharedDCBufferManager() { }
+
+ virtual bool OnInit() { return true; }
+ virtual void OnExit() { wxDELETE(ms_buffer); }
+
+ static wxBitmap* GetBuffer(int w, int h)
+ {
+ if ( !ms_buffer ||
+ w > ms_buffer->GetWidth() ||
+ h > ms_buffer->GetHeight() )
+ {
+ delete ms_buffer;
+ ms_buffer = new wxBitmap(w, h);
+ }
+ return ms_buffer;
+ }
+
+private:
+ static wxBitmap *ms_buffer;
+
+ DECLARE_DYNAMIC_CLASS(wxSharedDCBufferManager)
+};
+
+wxBitmap* wxSharedDCBufferManager::ms_buffer = NULL;
+
+IMPLEMENT_DYNAMIC_CLASS(wxSharedDCBufferManager, wxModule)
// ============================================================================
-// implementation
+// wxBufferedDC
// ============================================================================
-// This file is intentionally empty. It has not been removed in case another
-// wxBufferedDC reimplementation is attempted in the near future. If not then
-// this file can be removed and the bakefiles updated.
+void wxBufferedDC::UseBuffer(wxCoord w, wxCoord h)
+{
+ if ( !m_buffer || !m_buffer->IsOk() )
+ {
+ if ( w == -1 || h == -1 )
+ m_dc->GetSize(&w, &h);
+
+ m_buffer = wxSharedDCBufferManager::GetBuffer(w, h);
+ }
+
+ SelectObject(*m_buffer);
+}