]>
Commit | Line | Data |
---|---|---|
30c841c8 VS |
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 | #include "wx/private/overlay.h" | |
27 | #include "wx/dfb/private.h" | |
28 | ||
29 | // ============================================================================ | |
30 | // implementation | |
31 | // ============================================================================ | |
32 | ||
33 | // ---------------------------------------------------------------------------- | |
34 | // wxOverlay | |
35 | // ---------------------------------------------------------------------------- | |
36 | ||
37 | wxOverlayImpl::wxOverlayImpl() | |
38 | { | |
39 | m_window = NULL; | |
40 | m_isEmpty = true; | |
41 | } | |
42 | ||
43 | wxOverlayImpl::~wxOverlayImpl() | |
44 | { | |
45 | Reset(); | |
46 | } | |
47 | ||
48 | bool wxOverlayImpl::IsOk() | |
49 | { | |
50 | return m_window != NULL; | |
51 | } | |
52 | ||
53 | void wxOverlayImpl::Init(wxWindowDC *dc, int x, int y, int width, int height) | |
54 | { | |
55 | wxASSERT_MSG( !IsOk() , _("You cannot Init an overlay twice") ); | |
56 | ||
57 | m_window = dc->GetWindow(); | |
58 | ||
59 | m_rect = wxRect(x, y, width, height); | |
60 | m_rect.Offset(m_window->GetClientAreaOrigin()); | |
61 | ||
62 | // FIXME: create surface with transparency or key color (?) | |
63 | m_surface = | |
64 | dc->GetDirectFBSurface()->CreateCompatible | |
65 | ( | |
66 | m_rect.GetSize(), | |
67 | wxIDirectFBSurface::CreateCompatible_NoBackBuffer | |
68 | ); | |
69 | ||
70 | m_window->AddOverlay(this); | |
71 | } | |
72 | ||
73 | void wxOverlayImpl::BeginDrawing(wxWindowDC *dc) | |
74 | { | |
75 | wxPoint origin(m_rect.GetPosition() - m_window->GetClientAreaOrigin()); | |
76 | ||
77 | // drawing on overlay "hijacks" existing wxWindowDC rather then using | |
78 | // another DC, so we have to change the DC to draw on the overlay's surface. | |
79 | // Setting m_shouldFlip is done to avoid flipping and drawing of overlays | |
80 | // in ~wxWindowDC (we do it EndDrawing). | |
81 | dc->Init(m_surface); | |
82 | dc->SetDeviceOrigin(-origin.x, -origin.y); | |
83 | dc->m_shouldFlip = false; | |
84 | ||
85 | m_isEmpty = false; | |
86 | } | |
87 | ||
88 | void wxOverlayImpl::EndDrawing(wxWindowDC *dc) | |
89 | { | |
90 | m_window->RefreshWindowRect(m_rect); | |
91 | } | |
92 | ||
93 | void wxOverlayImpl::Clear(wxWindowDC *dc) | |
94 | { | |
95 | wxASSERT_MSG( IsOk(), | |
96 | _T("You cannot Clear an overlay that is not initialized") ); | |
97 | ||
98 | m_isEmpty = true; | |
99 | } | |
100 | ||
101 | void wxOverlayImpl::Reset() | |
102 | { | |
103 | if ( m_window ) | |
104 | { | |
105 | m_window->RemoveOverlay(this); | |
106 | m_window = NULL; | |
107 | m_surface.Reset(); | |
108 | } | |
109 | } |