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 if ( wxDynamicCast(dc
, wxClientDC
) )
61 m_rect
.Offset(m_window
->GetClientAreaOrigin());
63 // FIXME: create surface with transparency or key color (?)
65 dc
->GetDirectFBSurface()->CreateCompatible
68 wxIDirectFBSurface::CreateCompatible_NoBackBuffer
71 m_window
->AddOverlay(this);
74 void wxOverlayImpl::BeginDrawing(wxWindowDC
*dc
)
76 wxPoint
origin(m_rect
.GetPosition());
77 if ( wxDynamicCast(dc
, wxClientDC
) )
78 origin
-= m_window
->GetClientAreaOrigin();
80 // drawing on overlay "hijacks" existing wxWindowDC rather then using
81 // another DC, so we have to change the DC to draw on the overlay's surface.
82 // Setting m_shouldFlip is done to avoid flipping and drawing of overlays
83 // in ~wxWindowDC (we do it EndDrawing).
84 dc
->DFBInit(m_surface
);
85 dc
->SetDeviceOrigin(-origin
.x
, -origin
.y
);
86 dc
->m_shouldFlip
= false;
91 void wxOverlayImpl::EndDrawing(wxWindowDC
*dc
)
93 m_window
->RefreshWindowRect(m_rect
);
96 void wxOverlayImpl::Clear(wxWindowDC
*dc
)
99 _T("You cannot Clear an overlay that is not initialized") );
104 void wxOverlayImpl::Reset()
108 m_window
->RemoveOverlay(this);