1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/dfb/overlay.cpp
3 // Purpose: wxOverlay implementation for wxDFB
4 // Author: Vaclav Slavik
6 // Copyright: (c) wxWidgets team
7 // Licence: wxWindows licence
8 /////////////////////////////////////////////////////////////////////////////
10 // ============================================================================
12 // ============================================================================
14 // ----------------------------------------------------------------------------
16 // ----------------------------------------------------------------------------
18 // For compilers that support precompilation, includes "wx.h".
19 #include "wx/wxprec.h"
26 #include "wx/window.h"
27 #include "wx/dcclient.h"
30 #include "wx/private/overlay.h"
31 #include "wx/dfb/dcclient.h"
32 #include "wx/dfb/private.h"
34 // ============================================================================
36 // ============================================================================
38 // ----------------------------------------------------------------------------
40 // ----------------------------------------------------------------------------
42 wxOverlayImpl::wxOverlayImpl()
48 wxOverlayImpl::~wxOverlayImpl()
53 bool wxOverlayImpl::IsOk()
55 return m_window
!= NULL
;
58 void wxOverlayImpl::Init(wxDC
*dc
, int x
, int y
, int width
, int height
)
60 wxCHECK_RET( dc
, "NULL dc pointer" );
61 wxASSERT_MSG( !IsOk() , _("You cannot Init an overlay twice") );
63 wxDFBDCImpl
* const dcimpl
= wxDynamicCast(dc
->GetImpl(), wxDFBDCImpl
);
64 wxCHECK_RET( dcimpl
, "must have a DFB wxDC" );
66 m_window
= dc
->GetWindow();
68 m_rect
= wxRect(x
, y
, width
, height
);
69 if ( wxDynamicCast(dc
, wxClientDC
) )
70 m_rect
.Offset(m_window
->GetClientAreaOrigin());
72 // FIXME: create surface with transparency or key color (?)
73 m_surface
= dcimpl
->GetDirectFBSurface()->CreateCompatible
76 wxIDirectFBSurface::CreateCompatible_NoBackBuffer
79 m_window
->AddOverlay(this);
82 void wxOverlayImpl::BeginDrawing(wxDC
*dc
)
84 wxCHECK_RET( dc
, "NULL dc pointer" );
86 wxWindowDCImpl
* const
87 dcimpl
= static_cast<wxWindowDCImpl
*>(dc
->GetImpl());
89 wxPoint
origin(m_rect
.GetPosition());
90 if ( wxDynamicCast(dc
, wxClientDC
) )
91 origin
-= m_window
->GetClientAreaOrigin();
93 // drawing on overlay "hijacks" existing wxWindowDC rather then using
94 // another DC, so we have to change the DC to draw on the overlay's surface.
95 // Setting m_shouldFlip is done to avoid flipping and drawing of overlays
96 // in ~wxWindowDC (we do it EndDrawing).
97 dcimpl
->DFBInit(m_surface
);
98 dcimpl
->m_shouldFlip
= false;
99 dc
->SetDeviceOrigin(-origin
.x
, -origin
.y
);
104 void wxOverlayImpl::EndDrawing(wxDC
*WXUNUSED(dc
))
106 m_window
->RefreshWindowRect(m_rect
);
109 void wxOverlayImpl::Clear(wxDC
*WXUNUSED(dc
))
111 wxASSERT_MSG( IsOk(),
112 "You cannot Clear an overlay that is not initialized" );
117 void wxOverlayImpl::Reset()
121 m_window
->RemoveOverlay(this);