]> git.saurik.com Git - wxWidgets.git/blob - src/dfb/overlay.cpp
Add Get/SetLogicalFunction
[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 #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 if ( wxDynamicCast(dc, wxClientDC) )
61 m_rect.Offset(m_window->GetClientAreaOrigin());
62
63 // FIXME: create surface with transparency or key color (?)
64 m_surface =
65 dc->GetDirectFBSurface()->CreateCompatible
66 (
67 m_rect.GetSize(),
68 wxIDirectFBSurface::CreateCompatible_NoBackBuffer
69 );
70
71 m_window->AddOverlay(this);
72 }
73
74 void wxOverlayImpl::BeginDrawing(wxWindowDC *dc)
75 {
76 wxPoint origin(m_rect.GetPosition());
77 if ( wxDynamicCast(dc, wxClientDC) )
78 origin -= m_window->GetClientAreaOrigin();
79
80 // drawing on overlay "hijacks" existing wxWindowDC rather then using
81 // another DC, so we have to change the DC to draw on the overlay's surface.
82 // Setting m_shouldFlip is done to avoid flipping and drawing of overlays
83 // in ~wxWindowDC (we do it EndDrawing).
84 dc->DFBInit(m_surface);
85 dc->SetDeviceOrigin(-origin.x, -origin.y);
86 dc->m_shouldFlip = false;
87
88 m_isEmpty = false;
89 }
90
91 void wxOverlayImpl::EndDrawing(wxWindowDC *dc)
92 {
93 m_window->RefreshWindowRect(m_rect);
94 }
95
96 void wxOverlayImpl::Clear(wxWindowDC *dc)
97 {
98 wxASSERT_MSG( IsOk(),
99 _T("You cannot Clear an overlay that is not initialized") );
100
101 m_isEmpty = true;
102 }
103
104 void wxOverlayImpl::Reset()
105 {
106 if ( m_window )
107 {
108 m_window->RemoveOverlay(this);
109 m_window = NULL;
110 m_surface.Reset();
111 }
112 }