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