]>
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
7 // Copyright: (c) wxWidgets team
8 // Licence: wxWindows licence
9 /////////////////////////////////////////////////////////////////////////////
11 // ============================================================================
13 // ============================================================================
15 // ----------------------------------------------------------------------------
17 // ----------------------------------------------------------------------------
19 // For compilers that support precompilation, includes "wx.h".
20 #include "wx/wxprec.h"
26 #include "wx/overlay.h"
27 #include "wx/private/overlay.h"
28 #include "wx/dcclient.h"
29 #include "wx/dcmemory.h"
31 // ============================================================================
33 // ============================================================================
35 // ----------------------------------------------------------------------------
37 // ----------------------------------------------------------------------------
39 wxOverlay::wxOverlay()
41 m_impl
= new wxOverlayImpl();
45 wxOverlay::~wxOverlay()
50 bool wxOverlay::IsOk()
52 return m_impl
->IsOk();
55 void wxOverlay::Init( wxDC
* dc
, int x
, int y
, int width
, int height
)
57 m_impl
->Init(dc
, x
, y
, width
, height
);
60 void wxOverlay::BeginDrawing( wxDC
* dc
)
62 m_impl
->BeginDrawing(dc
);
66 void wxOverlay::EndDrawing( wxDC
* dc
)
68 m_impl
->EndDrawing(dc
);
72 void wxOverlay::Clear( wxDC
* dc
)
77 void wxOverlay::Reset()
79 wxASSERT_MSG(m_inDrawing
==false,wxT("cannot reset overlay during drawing"));
84 // ----------------------------------------------------------------------------
86 // ----------------------------------------------------------------------------
88 wxDCOverlay::wxDCOverlay(wxOverlay
&overlay
, wxDC
*dc
, int x
, int y
, int width
, int height
) :
91 Init(dc
, x
, y
, width
, height
);
94 wxDCOverlay::wxDCOverlay(wxOverlay
&overlay
, wxDC
*dc
) :
99 dc
->GetSize(&width
,&height
);
100 Init(dc
, 0, 0, width
, height
);
103 wxDCOverlay::~wxDCOverlay()
105 m_overlay
.EndDrawing(m_dc
);
108 void wxDCOverlay::Init(wxDC
*dc
, int x
, int y
, int width
, int height
)
111 if ( !m_overlay
.IsOk() )
113 m_overlay
.Init(dc
,x
,y
,width
,height
);
115 m_overlay
.BeginDrawing(dc
);
118 void wxDCOverlay::Clear()
120 m_overlay
.Clear(m_dc
);
123 // ----------------------------------------------------------------------------
124 // generic implementation of wxOverlayImpl
125 // ----------------------------------------------------------------------------
127 #ifndef wxHAS_NATIVE_OVERLAY
129 wxOverlayImpl::wxOverlayImpl()
132 m_x
= m_y
= m_width
= m_height
= 0 ;
135 wxOverlayImpl::~wxOverlayImpl()
139 bool wxOverlayImpl::IsOk()
141 return m_bmpSaved
.IsOk() ;
144 void wxOverlayImpl::Init( wxDC
* dc
, int x
, int y
, int width
, int height
)
146 m_window
= dc
->GetWindow();
148 m_bmpSaved
.Create( width
, height
);
149 dcMem
.SelectObject( m_bmpSaved
);
154 dcMem
.Blit(0, 0, m_width
, m_height
,
156 dcMem
.SelectObject( wxNullBitmap
);
159 void wxOverlayImpl::Clear(wxDC
* dc
)
162 dcMem
.SelectObject( m_bmpSaved
);
163 dc
->Blit( m_x
, m_y
, m_width
, m_height
, &dcMem
, 0 , 0 );
164 dcMem
.SelectObject( wxNullBitmap
);
167 void wxOverlayImpl::Reset()
169 m_bmpSaved
= wxBitmap();
172 void wxOverlayImpl::BeginDrawing(wxDC
* WXUNUSED(dc
))
176 void wxOverlayImpl::EndDrawing(wxDC
* WXUNUSED(dc
))
180 #endif // !wxHAS_NATIVE_OVERLAY