/[pcsx2_0.9.7]/trunk/3rdparty/wxWidgets/src/common/dcbufcmn.cpp
ViewVC logotype

Contents of /trunk/3rdparty/wxWidgets/src/common/dcbufcmn.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 31 - (show annotations) (download)
Tue Sep 7 03:24:11 2010 UTC (10 years, 2 months ago) by william
File size: 2820 byte(s)
committing r3113 initial commit again...
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: dcbufcmn.cpp 52152 2008-02-27 18:03:12Z VZ $
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
27 #include "wx/dcbuffer.h"
28
29 #ifndef WX_PRECOMP
30 #include "wx/module.h"
31 #endif
32
33 // ============================================================================
34 // implementation
35 // ============================================================================
36
37 // ----------------------------------------------------------------------------
38 // wxSharedDCBufferManager: helper class maintaining backing store bitmap
39 // ----------------------------------------------------------------------------
40
41 class wxSharedDCBufferManager : public wxModule
42 {
43 public:
44 wxSharedDCBufferManager() { }
45
46 virtual bool OnInit() { return true; }
47 virtual void OnExit() { wxDELETE(ms_buffer); }
48
49 static wxBitmap* GetBuffer(int w, int h)
50 {
51 if ( !ms_buffer ||
52 w > ms_buffer->GetWidth() ||
53 h > ms_buffer->GetHeight() )
54 {
55 delete ms_buffer;
56
57 // we must always return a valid bitmap but creating a bitmap of
58 // size 0 would fail, so create a 1*1 bitmap in this case
59 if ( !w )
60 w = 1;
61 if ( !h )
62 h = 1;
63
64 ms_buffer = new wxBitmap(w, h);
65 }
66 return ms_buffer;
67 }
68
69 private:
70 static wxBitmap *ms_buffer;
71
72 DECLARE_DYNAMIC_CLASS(wxSharedDCBufferManager)
73 };
74
75 wxBitmap* wxSharedDCBufferManager::ms_buffer = NULL;
76
77 IMPLEMENT_DYNAMIC_CLASS(wxSharedDCBufferManager, wxModule)
78
79 // ============================================================================
80 // wxBufferedDC
81 // ============================================================================
82
83 void wxBufferedDC::UseBuffer(wxCoord w, wxCoord h)
84 {
85 if ( !m_buffer || !m_buffer->IsOk() )
86 {
87 if ( w == -1 || h == -1 )
88 m_dc->GetSize(&w, &h);
89
90 m_buffer = wxSharedDCBufferManager::GetBuffer(w, h);
91 }
92
93 SelectObject(*m_buffer);
94 }
95

  ViewVC Help
Powered by ViewVC 1.1.22