X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/19c9f36f130144ac4ba03aa8daf5d35043c0b766..fd2ce1d1c18045f2ecce14d888473e8131c0d23c:/src/common/dcbufcmn.cpp?ds=sidebyside diff --git a/src/common/dcbufcmn.cpp b/src/common/dcbufcmn.cpp index d76a8a545e..ed6bb0e7bb 100644 --- a/src/common/dcbufcmn.cpp +++ b/src/common/dcbufcmn.cpp @@ -24,17 +24,64 @@ #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); +}