1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/dfb/overlay.cpp
3 // Purpose: wxOverlay implementation for wxDFB
4 // Author: Vaclav Slavik
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/private/overlay.h"
27 #include "wx/dfb/private.h"
29 // ============================================================================
31 // ============================================================================
33 // ----------------------------------------------------------------------------
35 // ----------------------------------------------------------------------------
37 wxOverlayImpl::wxOverlayImpl()
43 wxOverlayImpl::~wxOverlayImpl()
48 bool wxOverlayImpl::IsOk()
50 return m_window
!= NULL
;
53 void wxOverlayImpl::Init(wxWindowDC
*dc
, int x
, int y
, int width
, int height
)
55 wxASSERT_MSG( !IsOk() , _("You cannot Init an overlay twice") );
57 m_window
= dc
->GetWindow();
59 m_rect
= wxRect(x
, y
, width
, height
);
60 m_rect
.Offset(m_window
->GetClientAreaOrigin());
62 // FIXME: create surface with transparency or key color (?)
64 dc
->GetDirectFBSurface()->CreateCompatible
67 wxIDirectFBSurface::CreateCompatible_NoBackBuffer
70 m_window
->AddOverlay(this);
73 void wxOverlayImpl::BeginDrawing(wxWindowDC
*dc
)
75 wxPoint
origin(m_rect
.GetPosition() - m_window
->GetClientAreaOrigin());
77 // drawing on overlay "hijacks" existing wxWindowDC rather then using
78 // another DC, so we have to change the DC to draw on the overlay's surface.
79 // Setting m_shouldFlip is done to avoid flipping and drawing of overlays
80 // in ~wxWindowDC (we do it EndDrawing).
82 dc
->SetDeviceOrigin(-origin
.x
, -origin
.y
);
83 dc
->m_shouldFlip
= false;
88 void wxOverlayImpl::EndDrawing(wxWindowDC
*dc
)
90 m_window
->RefreshWindowRect(m_rect
);
93 void wxOverlayImpl::Clear(wxWindowDC
*dc
)
96 _T("You cannot Clear an overlay that is not initialized") );
101 void wxOverlayImpl::Reset()
105 m_window
->RemoveOverlay(this);