]> git.saurik.com Git - wxWidgets.git/blob - src/common/overlaycmn.cpp
Fix wxHtmlHelpData::SetTempDir() to behave correctly without trailing slash.
[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 // Copyright: (c) wxWidgets team
8 // Licence: wxWindows licence
9 /////////////////////////////////////////////////////////////////////////////
10
11 // ============================================================================
12 // declarations
13 // ============================================================================
14
15 // ----------------------------------------------------------------------------
16 // headers
17 // ----------------------------------------------------------------------------
18
19 // For compilers that support precompilation, includes "wx.h".
20 #include "wx/wxprec.h"
21
22 #ifdef __BORLANDC__
23 #pragma hdrstop
24 #endif
25
26 #include "wx/overlay.h"
27 #include "wx/private/overlay.h"
28 #include "wx/dcclient.h"
29 #include "wx/dcmemory.h"
30
31 // ============================================================================
32 // implementation
33 // ============================================================================
34
35 // ----------------------------------------------------------------------------
36 // wxOverlay
37 // ----------------------------------------------------------------------------
38
39 wxOverlay::wxOverlay()
40 {
41 m_impl = new wxOverlayImpl();
42 m_inDrawing = false;
43 }
44
45 wxOverlay::~wxOverlay()
46 {
47 delete m_impl;
48 }
49
50 bool wxOverlay::IsOk()
51 {
52 return m_impl->IsOk();
53 }
54
55 void wxOverlay::Init( wxDC* dc, int x , int y , int width , int height )
56 {
57 m_impl->Init(dc, x, y, width, height);
58 }
59
60 void wxOverlay::BeginDrawing( wxDC* dc)
61 {
62 m_impl->BeginDrawing(dc);
63 m_inDrawing = true ;
64 }
65
66 void wxOverlay::EndDrawing( wxDC* dc)
67 {
68 m_impl->EndDrawing(dc);
69 m_inDrawing = false ;
70 }
71
72 void wxOverlay::Clear( wxDC* dc)
73 {
74 m_impl->Clear(dc);
75 }
76
77 void wxOverlay::Reset()
78 {
79 wxASSERT_MSG(m_inDrawing==false,wxT("cannot reset overlay during drawing"));
80 m_impl->Reset();
81 }
82
83
84 // ----------------------------------------------------------------------------
85 // wxDCOverlay
86 // ----------------------------------------------------------------------------
87
88 wxDCOverlay::wxDCOverlay(wxOverlay &overlay, wxDC *dc, int x , int y , int width , int height) :
89 m_overlay(overlay)
90 {
91 Init(dc, x, y, width, height);
92 }
93
94 wxDCOverlay::wxDCOverlay(wxOverlay &overlay, wxDC *dc) :
95 m_overlay(overlay)
96 {
97 int width;
98 int height;
99 dc->GetSize(&width,&height);
100 Init(dc, 0, 0, width, height);
101 }
102
103 wxDCOverlay::~wxDCOverlay()
104 {
105 m_overlay.EndDrawing(m_dc);
106 }
107
108 void wxDCOverlay::Init(wxDC *dc, int x , int y , int width , int height )
109 {
110 m_dc = dc ;
111 if ( !m_overlay.IsOk() )
112 {
113 m_overlay.Init(dc,x,y,width,height);
114 }
115 m_overlay.BeginDrawing(dc);
116 }
117
118 void wxDCOverlay::Clear()
119 {
120 m_overlay.Clear(m_dc);
121 }
122
123 // ----------------------------------------------------------------------------
124 // generic implementation of wxOverlayImpl
125 // ----------------------------------------------------------------------------
126
127 #ifndef wxHAS_NATIVE_OVERLAY
128
129 wxOverlayImpl::wxOverlayImpl()
130 {
131 m_window = NULL ;
132 m_x = m_y = m_width = m_height = 0 ;
133 }
134
135 wxOverlayImpl::~wxOverlayImpl()
136 {
137 }
138
139 bool wxOverlayImpl::IsOk()
140 {
141 return m_bmpSaved.IsOk() ;
142 }
143
144 void wxOverlayImpl::Init( wxDC* dc, int x , int y , int width , int height )
145 {
146 m_window = dc->GetWindow();
147 wxMemoryDC dcMem ;
148 m_bmpSaved.Create( width, height );
149 dcMem.SelectObject( m_bmpSaved );
150 m_x = x ;
151 m_y = y ;
152 m_width = width ;
153 m_height = height ;
154 dcMem.Blit(0, 0, m_width, m_height,
155 dc, x, y);
156 dcMem.SelectObject( wxNullBitmap );
157 }
158
159 void wxOverlayImpl::Clear(wxDC* dc)
160 {
161 wxMemoryDC dcMem ;
162 dcMem.SelectObject( m_bmpSaved );
163 dc->Blit( m_x, m_y, m_width, m_height , &dcMem , 0 , 0 );
164 dcMem.SelectObject( wxNullBitmap );
165 }
166
167 void wxOverlayImpl::Reset()
168 {
169 m_bmpSaved = wxBitmap();
170 }
171
172 void wxOverlayImpl::BeginDrawing(wxDC* WXUNUSED(dc))
173 {
174 }
175
176 void wxOverlayImpl::EndDrawing(wxDC* WXUNUSED(dc))
177 {
178 }
179
180 #endif // !wxHAS_NATIVE_OVERLAY
181
182