]>
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( wxDC
* dc
, int x
, int y
, int width
, int height
)
58 m_impl
->Init(dc
, x
, y
, width
, height
);
61 void wxOverlay::BeginDrawing( wxDC
* dc
)
63 m_impl
->BeginDrawing(dc
);
67 void wxOverlay::EndDrawing( wxDC
* dc
)
69 m_impl
->EndDrawing(dc
);
73 void wxOverlay::Clear( wxDC
* dc
)
78 void wxOverlay::Reset()
80 wxASSERT_MSG(m_inDrawing
==false,wxT("cannot reset overlay during drawing"));
85 // ----------------------------------------------------------------------------
87 // ----------------------------------------------------------------------------
89 wxDCOverlay::wxDCOverlay(wxOverlay
&overlay
, wxDC
*dc
, int x
, int y
, int width
, int height
) :
92 Init(dc
, x
, y
, width
, height
);
95 wxDCOverlay::wxDCOverlay(wxOverlay
&overlay
, wxDC
*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(wxDC
*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( wxDC
* 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 dcMem
.Blit(0, 0, m_width
, m_height
,
157 dcMem
.SelectObject( wxNullBitmap
);
160 void wxOverlayImpl::Clear(wxDC
* dc
)
163 dcMem
.SelectObject( m_bmpSaved
);
164 dc
->Blit( m_x
, m_y
, m_width
, m_height
, &dcMem
, 0 , 0 );
165 dcMem
.SelectObject( wxNullBitmap
);
168 void wxOverlayImpl::Reset()
170 m_bmpSaved
= wxBitmap();
173 void wxOverlayImpl::BeginDrawing(wxDC
* WXUNUSED(dc
))
177 void wxOverlayImpl::EndDrawing(wxDC
* WXUNUSED(dc
))
181 #endif // !wxHAS_NATIVE_OVERLAY