]>
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"
17 #include "wx/wxprec.h"
24 #include "wx/window.h"
27 #include "wx/dcbuffer.h"
30 // ==============================================================
31 // Double buffering helper.
32 // --------------------------------------------------------------
34 wxBufferedDC::wxBufferedDC( wxDC
*dc
, const wxBitmap
&buffer
)
38 SelectObject( m_buffer
);
41 wxBufferedDC::wxBufferedDC( wxDC
*dc
, const wxSize
&area
)
43 , m_buffer( area
.GetWidth(), area
.GetHeight() )
45 SelectObject( m_buffer
);
48 wxBufferedDC::~wxBufferedDC()
56 void wxBufferedDC::Init( wxDC
*dc
, const wxBitmap
&buffer
)
58 wxASSERT_MSG( m_dc
== 0 && m_buffer
== wxNullBitmap
,
59 _T("wxBufferedDC already initialised") );
63 SelectObject( m_buffer
);
66 void wxBufferedDC::Init( wxDC
*dc
, const wxSize
&area
)
68 wxASSERT_MSG( m_dc
== 0 && m_buffer
== wxNullBitmap
,
69 _T("wxBufferedDC already initialised") );
72 m_buffer
= wxBitmap( area
.GetWidth(), area
.GetHeight() );
73 SelectObject( m_buffer
);
76 void wxBufferedDC::UnMask()
78 wxASSERT_MSG( m_dc
!= 0, _T("No low level DC associated with buffer (anymore)") );
80 m_dc
->Blit( 0, 0, m_buffer
.GetWidth(), m_buffer
.GetHeight(), this, 0, 0 );
85 // ==============================================================
86 // Double buffered PaintDC.
87 // --------------------------------------------------------------
89 wxBufferedPaintDC::wxBufferedPaintDC( wxWindow
*window
, const wxBitmap
&buffer
)
92 window
->PrepareDC( m_paintdc
);
94 if( buffer
!= wxNullBitmap
)
95 Init( &m_paintdc
, buffer
);
97 Init( &m_paintdc
, window
->GetClientSize() );
100 wxBufferedPaintDC::~wxBufferedPaintDC()
102 // We must UnMask here, else by the time the base class
103 // does it, the PaintDC will have already been destroyed.