]> git.saurik.com Git - wxWidgets.git/blame - src/common/overlaycmn.cpp
generate #line references to source .xrc files in wxrc --gettext (patch #1803492...
[wxWidgets.git] / src / common / overlaycmn.cpp
CommitLineData
30c841c8
VS
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
40wxOverlay::wxOverlay()
41{
42 m_impl = new wxOverlayImpl();
43 m_inDrawing = false;
44}
45
46wxOverlay::~wxOverlay()
47{
78ce938e 48 delete m_impl;
30c841c8
VS
49}
50
51bool wxOverlay::IsOk()
52{
53 return m_impl->IsOk();
54}
55
56void wxOverlay::Init( wxWindowDC* dc, int x , int y , int width , int height )
57{
58 m_impl->Init(dc, x, y, width, height);
59}
60
61void wxOverlay::BeginDrawing( wxWindowDC* dc)
62{
63 m_impl->BeginDrawing(dc);
64 m_inDrawing = true ;
65}
66
67void wxOverlay::EndDrawing( wxWindowDC* dc)
68{
69 m_impl->EndDrawing(dc);
70 m_inDrawing = false ;
71}
72
73void wxOverlay::Clear( wxWindowDC* dc)
74{
75 m_impl->Clear(dc);
76}
77
78void 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
89wxDCOverlay::wxDCOverlay(wxOverlay &overlay, wxWindowDC *dc, int x , int y , int width , int height) :
90 m_overlay(overlay)
91{
92 Init(dc, x, y, width, height);
93}
94
95wxDCOverlay::wxDCOverlay(wxOverlay &overlay, wxWindowDC *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
104wxDCOverlay::~wxDCOverlay()
105{
106 m_overlay.EndDrawing(m_dc);
107}
108
109void wxDCOverlay::Init(wxWindowDC *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
5abbb704 119void wxDCOverlay::Clear()
30c841c8
VS
120{
121 m_overlay.Clear(m_dc);
122}
123
124// ----------------------------------------------------------------------------
125// generic implementation of wxOverlayImpl
126// ----------------------------------------------------------------------------
127
69a5bc23 128#ifndef wxHAS_NATIVE_OVERLAY
30c841c8
VS
129
130wxOverlayImpl::wxOverlayImpl()
131{
132#if defined(__WXGTK__) || defined(__WXMSW__)
133 m_window = NULL ;
5abbb704 134#endif
30c841c8
VS
135 m_x = m_y = m_width = m_height = 0 ;
136}
137
138wxOverlayImpl::~wxOverlayImpl()
139{
140}
141
5abbb704 142bool wxOverlayImpl::IsOk()
30c841c8
VS
143{
144 return m_bmpSaved.Ok() ;
145}
146
147void wxOverlayImpl::Init( wxWindowDC* dc, int x , int y , int width , int height )
148{
5abbb704 149#if defined(__WXGTK20__)
ab3a1454
RR
150#if wxUSE_NEW_DC
151 wxImplDC *impl = dc->GetImpl();
152 wxGTKWindowImplDC *gtk_impl = wxDynamicCast( impl, wxGTKWindowImplDC );
153 if (gtk_impl)
154 m_window = gtk_impl->m_owningWindow;
155#else
ab171e95 156 m_window = dc->m_owningWindow;
ab3a1454 157#endif
5abbb704
VZ
158#elif defined(__WXGTK__)
159 m_window = dc->m_owner;
160#elif defined(__WXMSW__)
30c841c8 161 m_window = dc->GetWindow();
30c841c8
VS
162#endif
163 wxMemoryDC dcMem ;
164 m_bmpSaved.Create( width, height );
165 dcMem.SelectObject( m_bmpSaved );
166 m_x = x ;
167 m_y = y ;
168 m_width = width ;
169 m_height = height ;
170#if defined(__WXGTK__) && !defined(__WX_DC_BLIT_FIXED__)
171 wxPoint pt = dc->GetDeviceOrigin();
172 x += pt.x;
173 y += pt.y;
174#endif // broken wxGTK wxDC::Blit
175 dcMem.Blit(0, 0, m_width, m_height,
176 dc, x, y);
177 dcMem.SelectObject( wxNullBitmap );
178}
179
5abbb704 180void wxOverlayImpl::Clear(wxWindowDC* dc)
30c841c8
VS
181{
182 wxMemoryDC dcMem ;
183 dcMem.SelectObject( m_bmpSaved );
184 dc->Blit( m_x, m_y, m_width, m_height , &dcMem , 0 , 0 );
185 dcMem.SelectObject( wxNullBitmap );
186}
187
188void wxOverlayImpl::Reset()
189{
190 m_bmpSaved = wxBitmap();
191}
192
193void wxOverlayImpl::BeginDrawing(wxWindowDC* WXUNUSED(dc))
194{
195}
196
197void wxOverlayImpl::EndDrawing(wxWindowDC* WXUNUSED(dc))
198{
199}
200
201#endif // !wxHAS_NATIVE_OVERLAY
202
203