]> git.saurik.com Git - wxWidgets.git/blob - src/common/overlaycmn.cpp
fix parameter name
[wxWidgets.git] / src / common / overlaycmn.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/common/overlaycmn.cpp
3 // Purpose: common wxOverlay code
4 // Author: Stefan Csomor
5 // Modified by:
6 // Created: 2006-10-20
7 // RCS-ID: $Id$
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/overlay.h"
28 #include "wx/private/overlay.h"
29 #include "wx/dcclient.h"
30 #include "wx/dcmemory.h"
31
32 // ============================================================================
33 // implementation
34 // ============================================================================
35
36 // ----------------------------------------------------------------------------
37 // wxOverlay
38 // ----------------------------------------------------------------------------
39
40 wxOverlay::wxOverlay()
41 {
42 m_impl = new wxOverlayImpl();
43 m_inDrawing = false;
44 }
45
46 wxOverlay::~wxOverlay()
47 {
48 delete m_impl;
49 }
50
51 bool wxOverlay::IsOk()
52 {
53 return m_impl->IsOk();
54 }
55
56 void wxOverlay::Init( wxDC* dc, int x , int y , int width , int height )
57 {
58 m_impl->Init(dc, x, y, width, height);
59 }
60
61 void wxOverlay::BeginDrawing( wxDC* dc)
62 {
63 m_impl->BeginDrawing(dc);
64 m_inDrawing = true ;
65 }
66
67 void wxOverlay::EndDrawing( wxDC* dc)
68 {
69 m_impl->EndDrawing(dc);
70 m_inDrawing = false ;
71 }
72
73 void wxOverlay::Clear( wxDC* dc)
74 {
75 m_impl->Clear(dc);
76 }
77
78 void wxOverlay::Reset()
79 {
80 wxASSERT_MSG(m_inDrawing==false,wxT("cannot reset overlay during drawing"));
81 m_impl->Reset();
82 }
83
84
85 // ----------------------------------------------------------------------------
86 // wxDCOverlay
87 // ----------------------------------------------------------------------------
88
89 wxDCOverlay::wxDCOverlay(wxOverlay &overlay, wxDC *dc, int x , int y , int width , int height) :
90 m_overlay(overlay)
91 {
92 Init(dc, x, y, width, height);
93 }
94
95 wxDCOverlay::wxDCOverlay(wxOverlay &overlay, wxDC *dc) :
96 m_overlay(overlay)
97 {
98 int width;
99 int height;
100 dc->GetSize(&width,&height);
101 Init(dc, 0, 0, width, height);
102 }
103
104 wxDCOverlay::~wxDCOverlay()
105 {
106 m_overlay.EndDrawing(m_dc);
107 }
108
109 void wxDCOverlay::Init(wxDC *dc, int x , int y , int width , int height )
110 {
111 m_dc = dc ;
112 if ( !m_overlay.IsOk() )
113 {
114 m_overlay.Init(dc,x,y,width,height);
115 }
116 m_overlay.BeginDrawing(dc);
117 }
118
119 void wxDCOverlay::Clear()
120 {
121 m_overlay.Clear(m_dc);
122 }
123
124 // ----------------------------------------------------------------------------
125 // generic implementation of wxOverlayImpl
126 // ----------------------------------------------------------------------------
127
128 #ifndef wxHAS_NATIVE_OVERLAY
129
130 wxOverlayImpl::wxOverlayImpl()
131 {
132 m_window = NULL ;
133 m_x = m_y = m_width = m_height = 0 ;
134 }
135
136 wxOverlayImpl::~wxOverlayImpl()
137 {
138 }
139
140 bool wxOverlayImpl::IsOk()
141 {
142 return m_bmpSaved.Ok() ;
143 }
144
145 void wxOverlayImpl::Init( wxDC* dc, int x , int y , int width , int height )
146 {
147 m_window = dc->GetWindow();
148 wxMemoryDC dcMem ;
149 m_bmpSaved.Create( width, height );
150 dcMem.SelectObject( m_bmpSaved );
151 m_x = x ;
152 m_y = y ;
153 m_width = width ;
154 m_height = height ;
155 #if defined(__WXGTK__) && !defined(__WX_DC_BLIT_FIXED__)
156 wxPoint pt = dc->GetDeviceOrigin();
157 x += pt.x;
158 y += pt.y;
159 #endif // broken wxGTK wxDC::Blit
160 dcMem.Blit(0, 0, m_width, m_height,
161 dc, x, y);
162 dcMem.SelectObject( wxNullBitmap );
163 }
164
165 void wxOverlayImpl::Clear(wxDC* dc)
166 {
167 wxMemoryDC dcMem ;
168 dcMem.SelectObject( m_bmpSaved );
169 dc->Blit( m_x, m_y, m_width, m_height , &dcMem , 0 , 0 );
170 dcMem.SelectObject( wxNullBitmap );
171 }
172
173 void wxOverlayImpl::Reset()
174 {
175 m_bmpSaved = wxBitmap();
176 }
177
178 void wxOverlayImpl::BeginDrawing(wxDC* WXUNUSED(dc))
179 {
180 }
181
182 void wxOverlayImpl::EndDrawing(wxDC* WXUNUSED(dc))
183 {
184 }
185
186 #endif // !wxHAS_NATIVE_OVERLAY
187
188