]> git.saurik.com Git - wxWidgets.git/blob - src/dfb/overlay.cpp
Work around missing mode_t definition with ICC.
[wxWidgets.git] / src / dfb / overlay.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/dfb/overlay.cpp
3 // Purpose: wxOverlay implementation for wxDFB
4 // Author: Vaclav Slavik
5 // Created: 2006-10-20
6 // Copyright: (c) wxWidgets team
7 // Licence: wxWindows licence
8 /////////////////////////////////////////////////////////////////////////////
9
10 // ============================================================================
11 // declarations
12 // ============================================================================
13
14 // ----------------------------------------------------------------------------
15 // headers
16 // ----------------------------------------------------------------------------
17
18 // For compilers that support precompilation, includes "wx.h".
19 #include "wx/wxprec.h"
20
21 #ifdef __BORLANDC__
22 #pragma hdrstop
23 #endif
24
25 #ifndef WX_PRECOMP
26 #include "wx/window.h"
27 #include "wx/dcclient.h"
28 #endif
29
30 #include "wx/private/overlay.h"
31 #include "wx/dfb/dcclient.h"
32 #include "wx/dfb/private.h"
33
34 // ============================================================================
35 // implementation
36 // ============================================================================
37
38 // ----------------------------------------------------------------------------
39 // wxOverlay
40 // ----------------------------------------------------------------------------
41
42 wxOverlayImpl::wxOverlayImpl()
43 {
44 m_window = NULL;
45 m_isEmpty = true;
46 }
47
48 wxOverlayImpl::~wxOverlayImpl()
49 {
50 Reset();
51 }
52
53 bool wxOverlayImpl::IsOk()
54 {
55 return m_window != NULL;
56 }
57
58 void wxOverlayImpl::Init(wxDC *dc, int x, int y, int width, int height)
59 {
60 wxCHECK_RET( dc, "NULL dc pointer" );
61 wxASSERT_MSG( !IsOk() , _("You cannot Init an overlay twice") );
62
63 wxDFBDCImpl * const dcimpl = wxDynamicCast(dc->GetImpl(), wxDFBDCImpl);
64 wxCHECK_RET( dcimpl, "must have a DFB wxDC" );
65
66 m_window = dc->GetWindow();
67
68 m_rect = wxRect(x, y, width, height);
69 if ( wxDynamicCast(dc, wxClientDC) )
70 m_rect.Offset(m_window->GetClientAreaOrigin());
71
72 // FIXME: create surface with transparency or key color (?)
73 m_surface = dcimpl->GetDirectFBSurface()->CreateCompatible
74 (
75 m_rect.GetSize(),
76 wxIDirectFBSurface::CreateCompatible_NoBackBuffer
77 );
78
79 m_window->AddOverlay(this);
80 }
81
82 void wxOverlayImpl::BeginDrawing(wxDC *dc)
83 {
84 wxCHECK_RET( dc, "NULL dc pointer" );
85
86 wxWindowDCImpl * const
87 dcimpl = static_cast<wxWindowDCImpl *>(dc->GetImpl());
88
89 wxPoint origin(m_rect.GetPosition());
90 if ( wxDynamicCast(dc, wxClientDC) )
91 origin -= m_window->GetClientAreaOrigin();
92
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);
100
101 m_isEmpty = false;
102 }
103
104 void wxOverlayImpl::EndDrawing(wxDC *WXUNUSED(dc))
105 {
106 m_window->RefreshWindowRect(m_rect);
107 }
108
109 void wxOverlayImpl::Clear(wxDC *WXUNUSED(dc))
110 {
111 wxASSERT_MSG( IsOk(),
112 "You cannot Clear an overlay that is not initialized" );
113
114 m_isEmpty = true;
115 }
116
117 void wxOverlayImpl::Reset()
118 {
119 if ( m_window )
120 {
121 m_window->RemoveOverlay(this);
122 m_window = NULL;
123 m_surface.Reset();
124 }
125 }