]>
git.saurik.com Git - wxWidgets.git/blob - src/common/dcbufcmn.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/common/dcbufcmn.cpp
3 // Purpose: Buffered DC implementation
4 // Author: Ron Lee, Jaakko Salli
6 // Created: Sep-20-2006
8 // Copyright: (c) wxWidgets team
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 // ============================================================================
14 // ============================================================================
16 // ----------------------------------------------------------------------------
18 // ----------------------------------------------------------------------------
20 // For compilers that support precompilation, includes "wx.h".
21 #include "wx/wxprec.h"
27 #include "wx/dcbuffer.h"
30 #include "wx/module.h"
33 // ============================================================================
35 // ============================================================================
37 // ----------------------------------------------------------------------------
38 // wxSharedDCBufferManager: helper class maintaining backing store bitmap
39 // ----------------------------------------------------------------------------
41 class wxSharedDCBufferManager
: public wxModule
44 wxSharedDCBufferManager() { }
46 virtual bool OnInit() { return true; }
47 virtual void OnExit() { wxDELETE(ms_buffer
); }
49 static wxBitmap
* GetBuffer(int w
, int h
)
52 w
> ms_buffer
->GetWidth() ||
53 h
> ms_buffer
->GetHeight() )
56 ms_buffer
= new wxBitmap(w
, h
);
62 static wxBitmap
*ms_buffer
;
64 DECLARE_DYNAMIC_CLASS(wxSharedDCBufferManager
)
67 wxBitmap
* wxSharedDCBufferManager::ms_buffer
= NULL
;
69 IMPLEMENT_DYNAMIC_CLASS(wxSharedDCBufferManager
, wxModule
)
71 // ============================================================================
73 // ============================================================================
75 void wxBufferedDC::UseBuffer(wxCoord w
, wxCoord h
)
77 if ( !m_buffer
|| !m_buffer
->IsOk() )
79 if ( w
== -1 || h
== -1 )
80 m_dc
->GetSize(&w
, &h
);
82 m_buffer
= wxSharedDCBufferManager::GetBuffer(w
, h
);
85 SelectObject(*m_buffer
);