]>
git.saurik.com Git - wxWidgets.git/blob - src/common/overlaycmn.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/common/overlaycmn.cpp
3 // Purpose: common wxOverlay code
4 // Author: Stefan Csomor
8 // Copyright: (c) wxWidgets team
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 // ============================================================================
14 // ============================================================================
16 // ----------------------------------------------------------------------------
18 // ----------------------------------------------------------------------------
20 // For compilers that support precompilation, includes "wx.h".
21 #include "wx/wxprec.h"
27 #include "wx/overlay.h"
28 #include "wx/private/overlay.h"
29 #include "wx/dcclient.h"
30 #include "wx/dcmemory.h"
32 // ============================================================================
34 // ============================================================================
36 // ----------------------------------------------------------------------------
38 // ----------------------------------------------------------------------------
40 wxOverlay::wxOverlay()
42 m_impl
= new wxOverlayImpl();
46 wxOverlay::~wxOverlay()
51 bool wxOverlay::IsOk()
53 return m_impl
->IsOk();
56 void wxOverlay::Init( wxWindowDC
* dc
, int x
, int y
, int width
, int height
)
58 m_impl
->Init(dc
, x
, y
, width
, height
);
61 void wxOverlay::BeginDrawing( wxWindowDC
* dc
)
63 m_impl
->BeginDrawing(dc
);
67 void wxOverlay::EndDrawing( wxWindowDC
* dc
)
69 m_impl
->EndDrawing(dc
);
73 void wxOverlay::Clear( wxWindowDC
* dc
)
78 void wxOverlay::Reset()
80 wxASSERT_MSG(m_inDrawing
==false,wxT("cannot reset overlay during drawing"));
85 // ----------------------------------------------------------------------------
87 // ----------------------------------------------------------------------------
89 wxDCOverlay::wxDCOverlay(wxOverlay
&overlay
, wxWindowDC
*dc
, int x
, int y
, int width
, int height
) :
92 Init(dc
, x
, y
, width
, height
);
95 wxDCOverlay::wxDCOverlay(wxOverlay
&overlay
, wxWindowDC
*dc
) :
100 dc
->GetSize(&width
,&height
);
101 Init(dc
, 0, 0, width
, height
);
104 wxDCOverlay::~wxDCOverlay()
106 m_overlay
.EndDrawing(m_dc
);
109 void wxDCOverlay::Init(wxWindowDC
*dc
, int x
, int y
, int width
, int height
)
112 if ( !m_overlay
.IsOk() )
114 m_overlay
.Init(dc
,x
,y
,width
,height
);
116 m_overlay
.BeginDrawing(dc
);
119 void wxDCOverlay::Clear()
121 m_overlay
.Clear(m_dc
);
124 // ----------------------------------------------------------------------------
125 // generic implementation of wxOverlayImpl
126 // ----------------------------------------------------------------------------
128 #ifndef wxHAS_NATIVE_OVERLAY
130 wxOverlayImpl::wxOverlayImpl()
132 #if defined(__WXGTK__) || defined(__WXMSW__)
135 m_x
= m_y
= m_width
= m_height
= 0 ;
138 wxOverlayImpl::~wxOverlayImpl()
142 bool wxOverlayImpl::IsOk()
144 return m_bmpSaved
.Ok() ;
147 void wxOverlayImpl::Init( wxWindowDC
* dc
, int x
, int y
, int width
, int height
)
149 #if defined(__WXGTK20__)
151 wxImplDC
*impl
= dc
->GetImpl();
152 wxGTKWindowImplDC
*gtk_impl
= wxDynamicCast( impl
, wxGTKWindowImplDC
);
154 m_window
= gtk_impl
->m_owningWindow
;
156 m_window
= dc
->m_owningWindow
;
158 #elif defined(__WXGTK__)
159 m_window
= dc
->m_owner
;
160 #elif defined(__WXMSW__)
161 m_window
= dc
->GetWindow();
164 m_bmpSaved
.Create( width
, height
);
165 dcMem
.SelectObject( m_bmpSaved
);
170 #if defined(__WXGTK__) && !defined(__WX_DC_BLIT_FIXED__)
171 wxPoint pt
= dc
->GetDeviceOrigin();
174 #endif // broken wxGTK wxDC::Blit
175 dcMem
.Blit(0, 0, m_width
, m_height
,
177 dcMem
.SelectObject( wxNullBitmap
);
180 void wxOverlayImpl::Clear(wxWindowDC
* dc
)
183 dcMem
.SelectObject( m_bmpSaved
);
184 dc
->Blit( m_x
, m_y
, m_width
, m_height
, &dcMem
, 0 , 0 );
185 dcMem
.SelectObject( wxNullBitmap
);
188 void wxOverlayImpl::Reset()
190 m_bmpSaved
= wxBitmap();
193 void wxOverlayImpl::BeginDrawing(wxWindowDC
* WXUNUSED(dc
))
197 void wxOverlayImpl::EndDrawing(wxWindowDC
* WXUNUSED(dc
))
201 #endif // !wxHAS_NATIVE_OVERLAY