]>
git.saurik.com Git - wxWidgets.git/blob - src/generic/dcbuffer.cpp
1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxBufferedDC class
4 // Author: Ron Lee <ron@debian.org>
8 // Copyright: (c) Ron Lee
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
14 #pragma implementation "dcbuffer.h"
21 #include "wx/dcbuffer.h"
24 // ==============================================================
25 // Double buffering helper.
26 // --------------------------------------------------------------
28 wxBufferedDC::wxBufferedDC( wxDC
*dc
, const wxBitmap
&buffer
)
32 SelectObject( m_buffer
);
35 wxBufferedDC::wxBufferedDC( wxDC
*dc
, const wxSize
&area
)
37 , m_buffer( area
.GetWidth(), area
.GetHeight() )
39 SelectObject( m_buffer
);
42 wxBufferedDC::~wxBufferedDC()
50 void wxBufferedDC::Init( wxDC
*dc
, const wxBitmap
&buffer
)
52 wxASSERT_MSG( m_dc
== 0 && m_buffer
== wxNullBitmap
,
53 _T("wxBufferedDC already initialised") );
57 SelectObject( m_buffer
);
60 void wxBufferedDC::Init( wxDC
*dc
, const wxSize
&area
)
62 wxASSERT_MSG( m_dc
== 0 && m_buffer
== wxNullBitmap
,
63 _T("wxBufferedDC already initialised") );
66 m_buffer
= wxBitmap( area
.GetWidth(), area
.GetHeight() );
67 SelectObject( m_buffer
);
70 void wxBufferedDC::UnMask()
72 wxASSERT_MSG( m_dc
!= 0, _T("No low level DC associated with buffer (anymore)") );
74 m_dc
->Blit( 0, 0, m_buffer
.GetWidth(), m_buffer
.GetHeight(), this, 0, 0 );
79 // ==============================================================
80 // Double buffered PaintDC.
81 // --------------------------------------------------------------
83 wxBufferedPaintDC::wxBufferedPaintDC( wxWindow
*window
, const wxBitmap
&buffer
)
86 window
->PrepareDC( m_paintdc
);
88 if( buffer
!= wxNullBitmap
)
89 Init( &m_paintdc
, buffer
);
91 Init( &m_paintdc
, window
->GetClientSize() );
94 wxBufferedPaintDC::~wxBufferedPaintDC()
96 // We must UnMask here, else by the time the base class
97 // does it, the PaintDC will have already been destroyed.