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"
27 #include "wx/window.h"
28 #include "wx/dcclient.h"
31 #include "wx/private/overlay.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(wxWindowDC
*dc
, int x
, int y
, int width
, int height
)
60 wxASSERT_MSG( !IsOk() , _("You cannot Init an overlay twice") );
62 m_window
= dc
->GetWindow();
64 m_rect
= wxRect(x
, y
, width
, height
);
65 if ( wxDynamicCast(dc
, wxClientDC
) )
66 m_rect
.Offset(m_window
->GetClientAreaOrigin());
68 // FIXME: create surface with transparency or key color (?)
70 dc
->GetDirectFBSurface()->CreateCompatible
73 wxIDirectFBSurface::CreateCompatible_NoBackBuffer
76 m_window
->AddOverlay(this);
79 void wxOverlayImpl::BeginDrawing(wxWindowDC
*dc
)
81 wxPoint
origin(m_rect
.GetPosition());
82 if ( wxDynamicCast(dc
, wxClientDC
) )
83 origin
-= m_window
->GetClientAreaOrigin();
85 // drawing on overlay "hijacks" existing wxWindowDC rather then using
86 // another DC, so we have to change the DC to draw on the overlay's surface.
87 // Setting m_shouldFlip is done to avoid flipping and drawing of overlays
88 // in ~wxWindowDC (we do it EndDrawing).
89 dc
->DFBInit(m_surface
);
90 dc
->SetDeviceOrigin(-origin
.x
, -origin
.y
);
91 dc
->m_shouldFlip
= false;
96 void wxOverlayImpl::EndDrawing(wxWindowDC
*dc
)
98 m_window
->RefreshWindowRect(m_rect
);
101 void wxOverlayImpl::Clear(wxWindowDC
*dc
)
103 wxASSERT_MSG( IsOk(),
104 _T("You cannot Clear an overlay that is not initialized") );
109 void wxOverlayImpl::Reset()
113 m_window
->RemoveOverlay(this);