]> git.saurik.com Git - wxWidgets.git/blame - src/common/dcbufcmn.cpp
Minor header cleaning.
[wxWidgets.git] / src / common / dcbufcmn.cpp
CommitLineData
2e992e06
VZ
1/////////////////////////////////////////////////////////////////////////////
2// Name: src/common/dcbufcmn.cpp
3// Purpose: Buffered DC implementation
4// Author: Ron Lee, Jaakko Salli
5// Modified by:
6// Created: Sep-20-2006
7// RCS-ID: $Id$
8// Copyright: (c) wxWidgets team
9// Licence: wxWindows licence
10/////////////////////////////////////////////////////////////////////////////
11
12// ============================================================================
13// declarations
14// ============================================================================
15
16// ----------------------------------------------------------------------------
17// headers
18// ----------------------------------------------------------------------------
19
20// For compilers that support precompilation, includes "wx.h".
21#include "wx/wxprec.h"
22
23#ifdef __BORLANDC__
24 #pragma hdrstop
25#endif
26
576bdf85
PC
27#include "wx/dcbuffer.h"
28
2e992e06 29#ifndef WX_PRECOMP
37747da8 30 #include "wx/module.h"
2e992e06
VZ
31#endif
32
2e992e06
VZ
33// ============================================================================
34// implementation
35// ============================================================================
36
1a9a3ce9
VZ
37// ----------------------------------------------------------------------------
38// wxSharedDCBufferManager: helper class maintaining backing store bitmap
39// ----------------------------------------------------------------------------
77f62aa7 40
37747da8 41class wxSharedDCBufferManager : public wxModule
77f62aa7 42{
77f62aa7 43public:
77f62aa7 44 wxSharedDCBufferManager() { }
77f62aa7 45
37747da8
VZ
46 virtual bool OnInit() { return true; }
47 virtual void OnExit() { wxDELETE(ms_buffer); }
48
49 static wxBitmap GetBuffer(int w, int h)
77f62aa7 50 {
37747da8
VZ
51 if ( !ms_buffer ||
52 w > ms_buffer->GetWidth() ||
53 h > ms_buffer->GetHeight() )
77f62aa7 54 {
37747da8
VZ
55 delete ms_buffer;
56 ms_buffer = new wxBitmap(w, h);
77f62aa7
RD
57 }
58
37747da8 59 return *ms_buffer;
77f62aa7
RD
60 }
61
62private:
37747da8 63 static wxBitmap *ms_buffer;
77f62aa7 64
37747da8
VZ
65 DECLARE_DYNAMIC_CLASS(wxSharedDCBufferManager)
66};
77f62aa7 67
576bdf85
PC
68wxBitmap* wxSharedDCBufferManager::ms_buffer;
69
37747da8 70IMPLEMENT_DYNAMIC_CLASS(wxSharedDCBufferManager, wxModule)
77f62aa7
RD
71
72// ============================================================================
73// wxBufferedDC
74// ============================================================================
75
76void wxBufferedDC::UseBuffer(wxCoord w, wxCoord h)
77{
1a9a3ce9 78 if ( !m_buffer.IsOk() )
77f62aa7
RD
79 {
80 if ( w == -1 || h == -1 )
81 m_dc->GetSize(&w, &h);
82
37747da8 83 m_buffer = wxSharedDCBufferManager::GetBuffer(w, h);
77f62aa7
RD
84 }
85
1a9a3ce9 86 SelectObject(m_buffer);
77f62aa7 87}
2e992e06 88