]> git.saurik.com Git - wxWidgets.git/blob - src/dfb/overlay.cpp
Always use FVIRTKEY for the accelerators under MSW.
[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 // RCS-ID: $Id$
7 // Copyright: (c) wxWidgets team
8 // Licence: wxWindows licence
9 /////////////////////////////////////////////////////////////////////////////
10
11 // ============================================================================
12 // declarations
13 // ============================================================================
14
15 // ----------------------------------------------------------------------------
16 // headers
17 // ----------------------------------------------------------------------------
18
19 // For compilers that support precompilation, includes "wx.h".
20 #include "wx/wxprec.h"
21
22 #ifdef __BORLANDC__
23 #pragma hdrstop
24 #endif
25
26 #ifndef WX_PRECOMP
27 #include "wx/window.h"
28 #include "wx/dcclient.h"
29 #endif
30
31 #include "wx/private/overlay.h"
32 #include "wx/dfb/dcclient.h"
33 #include "wx/dfb/private.h"
34
35 // ============================================================================
36 // implementation
37 // ============================================================================
38
39 // ----------------------------------------------------------------------------
40 // wxOverlay
41 // ----------------------------------------------------------------------------
42
43 wxOverlayImpl::wxOverlayImpl()
44 {
45 m_window = NULL;
46 m_isEmpty = true;
47 }
48
49 wxOverlayImpl::~wxOverlayImpl()
50 {
51 Reset();
52 }
53
54 bool wxOverlayImpl::IsOk()
55 {
56 return m_window != NULL;
57 }
58
59 void wxOverlayImpl::Init(wxDC *dc, int x, int y, int width, int height)
60 {
61 wxCHECK_RET( dc, "NULL dc pointer" );
62 wxASSERT_MSG( !IsOk() , _("You cannot Init an overlay twice") );
63
64 wxDFBDCImpl * const dcimpl = wxDynamicCast(dc->GetImpl(), wxDFBDCImpl);
65 wxCHECK_RET( dcimpl, "must have a DFB wxDC" );
66
67 m_window = dc->GetWindow();
68
69 m_rect = wxRect(x, y, width, height);
70 if ( wxDynamicCast(dc, wxClientDC) )
71 m_rect.Offset(m_window->GetClientAreaOrigin());
72
73 // FIXME: create surface with transparency or key color (?)
74 m_surface = dcimpl->GetDirectFBSurface()->CreateCompatible
75 (
76 m_rect.GetSize(),
77 wxIDirectFBSurface::CreateCompatible_NoBackBuffer
78 );
79
80 m_window->AddOverlay(this);
81 }
82
83 void wxOverlayImpl::BeginDrawing(wxDC *dc)
84 {
85 wxCHECK_RET( dc, "NULL dc pointer" );
86
87 wxWindowDCImpl * const
88 dcimpl = static_cast<wxWindowDCImpl *>(dc->GetImpl());
89
90 wxPoint origin(m_rect.GetPosition());
91 if ( wxDynamicCast(dc, wxClientDC) )
92 origin -= m_window->GetClientAreaOrigin();
93
94 // drawing on overlay "hijacks" existing wxWindowDC rather then using
95 // another DC, so we have to change the DC to draw on the overlay's surface.
96 // Setting m_shouldFlip is done to avoid flipping and drawing of overlays
97 // in ~wxWindowDC (we do it EndDrawing).
98 dcimpl->DFBInit(m_surface);
99 dcimpl->m_shouldFlip = false;
100 dc->SetDeviceOrigin(-origin.x, -origin.y);
101
102 m_isEmpty = false;
103 }
104
105 void wxOverlayImpl::EndDrawing(wxDC *WXUNUSED(dc))
106 {
107 m_window->RefreshWindowRect(m_rect);
108 }
109
110 void wxOverlayImpl::Clear(wxDC *WXUNUSED(dc))
111 {
112 wxASSERT_MSG( IsOk(),
113 "You cannot Clear an overlay that is not initialized" );
114
115 m_isEmpty = true;
116 }
117
118 void wxOverlayImpl::Reset()
119 {
120 if ( m_window )
121 {
122 m_window->RemoveOverlay(this);
123 m_window = NULL;
124 m_surface.Reset();
125 }
126 }