]>
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()
133 m_x
= m_y
= m_width
= m_height
= 0 ;
136 wxOverlayImpl::~wxOverlayImpl()
140 bool wxOverlayImpl::IsOk()
142 return m_bmpSaved
.Ok() ;
145 void wxOverlayImpl::Init( wxWindowDC
* dc
, int x
, int y
, int width
, int height
)
147 m_window
= dc
->GetWindow();
149 m_bmpSaved
.Create( width
, height
);
150 dcMem
.SelectObject( m_bmpSaved
);
155 #if defined(__WXGTK__) && !defined(__WX_DC_BLIT_FIXED__)
156 wxPoint pt
= dc
->GetDeviceOrigin();
159 #endif // broken wxGTK wxDC::Blit
160 dcMem
.Blit(0, 0, m_width
, m_height
,
162 dcMem
.SelectObject( wxNullBitmap
);
165 void wxOverlayImpl::Clear(wxWindowDC
* dc
)
168 dcMem
.SelectObject( m_bmpSaved
);
169 dc
->Blit( m_x
, m_y
, m_width
, m_height
, &dcMem
, 0 , 0 );
170 dcMem
.SelectObject( wxNullBitmap
);
173 void wxOverlayImpl::Reset()
175 m_bmpSaved
= wxBitmap();
178 void wxOverlayImpl::BeginDrawing(wxWindowDC
* WXUNUSED(dc
))
182 void wxOverlayImpl::EndDrawing(wxWindowDC
* WXUNUSED(dc
))
186 #endif // !wxHAS_NATIVE_OVERLAY