]>
Commit | Line | Data |
---|---|---|
67e2efca | 1 | ///////////////////////////////////////////////////////////////////////////// |
1cc8c8b7 | 2 | // Name: generic/dcbuffer.cpp |
67e2efca RL |
3 | // Purpose: wxBufferedDC class |
4 | // Author: Ron Lee <ron@debian.org> | |
1cc8c8b7 | 5 | // Modified by: Vadim Zeitlin (refactored, added bg preservation) |
67e2efca RL |
6 | // Created: 16/03/02 |
7 | // RCS-ID: $Id$ | |
8 | // Copyright: (c) Ron Lee | |
9 | // Licence: wxWindows licence | |
10 | ///////////////////////////////////////////////////////////////////////////// | |
11 | ||
14f355c2 | 12 | #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) |
67e2efca RL |
13 | #pragma implementation "dcbuffer.h" |
14 | #endif | |
15 | ||
2981a033 RL |
16 | #include "wx/wxprec.h" |
17 | ||
67e2efca RL |
18 | #ifdef __BORLANDC__ |
19 | #pragma hdrstop | |
20 | #endif | |
21 | ||
2981a033 | 22 | #ifndef WX_PRECOMP |
1cc8c8b7 | 23 | #include "wx/window.h" |
2981a033 RL |
24 | #endif |
25 | ||
67e2efca RL |
26 | #include "wx/dcbuffer.h" |
27 | ||
1cc8c8b7 VZ |
28 | // ---------------------------------------------------------------------------- |
29 | // Double buffering helper. | |
30 | // ---------------------------------------------------------------------------- | |
67e2efca | 31 | |
1cc8c8b7 VZ |
32 | wxBufferedDC::wxBufferedDC(wxDC *dc, const wxBitmap& buffer) |
33 | : m_dc( dc ), | |
34 | m_buffer( buffer ) | |
67e2efca | 35 | { |
1cc8c8b7 | 36 | UseBuffer(); |
67e2efca RL |
37 | } |
38 | ||
1cc8c8b7 VZ |
39 | wxBufferedDC::wxBufferedDC(wxDC *dc, const wxSize& area, int flags) |
40 | : m_dc( dc ), | |
41 | m_buffer( area.GetWidth(), area.GetHeight() ) | |
67e2efca | 42 | { |
1cc8c8b7 | 43 | UseBuffer(); |
67e2efca | 44 | |
1cc8c8b7 | 45 | SaveBg(area, flags); |
67e2efca RL |
46 | } |
47 | ||
48 | void wxBufferedDC::Init( wxDC *dc, const wxBitmap &buffer ) | |
49 | { | |
50 | wxASSERT_MSG( m_dc == 0 && m_buffer == wxNullBitmap, | |
51 | _T("wxBufferedDC already initialised") ); | |
52 | ||
53 | m_dc = dc; | |
54 | m_buffer = buffer; | |
1cc8c8b7 VZ |
55 | |
56 | UseBuffer(); | |
67e2efca RL |
57 | } |
58 | ||
1cc8c8b7 | 59 | void wxBufferedDC::Init(wxDC *dc, const wxSize& area, int flags) |
67e2efca | 60 | { |
1cc8c8b7 | 61 | Init(dc, wxBitmap(area.GetWidth(), area.GetHeight())); |
67e2efca | 62 | |
1cc8c8b7 | 63 | SaveBg(area, flags); |
67e2efca RL |
64 | } |
65 | ||
66 | void wxBufferedDC::UnMask() | |
67 | { | |
1cc8c8b7 VZ |
68 | wxASSERT_MSG( m_dc != 0, |
69 | _T("No underlying DC associated with wxBufferedDC (anymore)") ); | |
67e2efca RL |
70 | |
71 | m_dc->Blit( 0, 0, m_buffer.GetWidth(), m_buffer.GetHeight(), this, 0, 0 ); | |
1cc8c8b7 | 72 | m_dc = NULL; |
67e2efca RL |
73 | } |
74 |