]> git.saurik.com Git - wxWidgets.git/blame - src/common/overlaycmn.cpp
Applied #15375 to stop event-sending in generic wxSpinCtrl ctor (eco)
[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
30c841c8
VS
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
39wxOverlay::wxOverlay()
40{
41 m_impl = new wxOverlayImpl();
42 m_inDrawing = false;
43}
44
45wxOverlay::~wxOverlay()
46{
78ce938e 47 delete m_impl;
30c841c8
VS
48}
49
50bool wxOverlay::IsOk()
51{
52 return m_impl->IsOk();
53}
54
156310e2 55void wxOverlay::Init( wxDC* dc, int x , int y , int width , int height )
30c841c8
VS
56{
57 m_impl->Init(dc, x, y, width, height);
58}
59
156310e2 60void wxOverlay::BeginDrawing( wxDC* dc)
30c841c8
VS
61{
62 m_impl->BeginDrawing(dc);
63 m_inDrawing = true ;
64}
65
156310e2 66void wxOverlay::EndDrawing( wxDC* dc)
30c841c8
VS
67{
68 m_impl->EndDrawing(dc);
69 m_inDrawing = false ;
70}
71
156310e2 72void wxOverlay::Clear( wxDC* dc)
30c841c8
VS
73{
74 m_impl->Clear(dc);
75}
76
77void 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
156310e2 88wxDCOverlay::wxDCOverlay(wxOverlay &overlay, wxDC *dc, int x , int y , int width , int height) :
30c841c8
VS
89 m_overlay(overlay)
90{
91 Init(dc, x, y, width, height);
92}
93
156310e2 94wxDCOverlay::wxDCOverlay(wxOverlay &overlay, wxDC *dc) :
30c841c8
VS
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
103wxDCOverlay::~wxDCOverlay()
104{
105 m_overlay.EndDrawing(m_dc);
106}
107
156310e2 108void wxDCOverlay::Init(wxDC *dc, int x , int y , int width , int height )
30c841c8
VS
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
5abbb704 118void wxDCOverlay::Clear()
30c841c8
VS
119{
120 m_overlay.Clear(m_dc);
121}
122
123// ----------------------------------------------------------------------------
124// generic implementation of wxOverlayImpl
125// ----------------------------------------------------------------------------
126
69a5bc23 127#ifndef wxHAS_NATIVE_OVERLAY
30c841c8
VS
128
129wxOverlayImpl::wxOverlayImpl()
130{
30c841c8 131 m_window = NULL ;
30c841c8
VS
132 m_x = m_y = m_width = m_height = 0 ;
133}
134
135wxOverlayImpl::~wxOverlayImpl()
136{
137}
138
5abbb704 139bool wxOverlayImpl::IsOk()
30c841c8 140{
a1b806b9 141 return m_bmpSaved.IsOk() ;
30c841c8
VS
142}
143
156310e2 144void wxOverlayImpl::Init( wxDC* dc, int x , int y , int width , int height )
30c841c8 145{
30c841c8 146 m_window = dc->GetWindow();
30c841c8
VS
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 ;
30c841c8
VS
154 dcMem.Blit(0, 0, m_width, m_height,
155 dc, x, y);
156 dcMem.SelectObject( wxNullBitmap );
157}
158
156310e2 159void wxOverlayImpl::Clear(wxDC* dc)
30c841c8
VS
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
167void wxOverlayImpl::Reset()
168{
169 m_bmpSaved = wxBitmap();
170}
171
156310e2 172void wxOverlayImpl::BeginDrawing(wxDC* WXUNUSED(dc))
30c841c8
VS
173{
174}
175
156310e2 176void wxOverlayImpl::EndDrawing(wxDC* WXUNUSED(dc))
30c841c8
VS
177{
178}
179
180#endif // !wxHAS_NATIVE_OVERLAY
181
182