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"
30 #include "wx/dcbuffer.h"
32 // ============================================================================
34 // ============================================================================
36 // ----------------------------------------------------------------------------
37 // wxSharedDCBufferManager: helper class maintaining backing store bitmap
38 // ----------------------------------------------------------------------------
40 class wxSharedDCBufferManager
43 wxSharedDCBufferManager() { }
44 ~wxSharedDCBufferManager() { }
46 wxBitmap
GetBuffer(int w
, int h
)
48 if ( !m_buffer
.IsOk() ||
49 w
> m_buffer
.GetWidth() ||
50 h
> m_buffer
.GetHeight() )
52 // Create slightly larger bitmap so we don't need to
53 // be reallocating constantly when the user enlarges
54 // the frame for the first time.
55 m_buffer
= wxBitmap(w
, h
);
65 static wxSharedDCBufferManager gs_sharedDCBufferManager
;
68 // ============================================================================
70 // ============================================================================
72 void wxBufferedDC::UseBuffer(wxCoord w
, wxCoord h
)
74 if ( !m_buffer
.IsOk() )
76 if ( w
== -1 || h
== -1 )
77 m_dc
->GetSize(&w
, &h
);
79 m_buffer
= gs_sharedDCBufferManager
.GetBuffer(w
, h
);
82 SelectObject(m_buffer
);