]> git.saurik.com Git - wxWidgets.git/blame - src/dfb/overlay.cpp
avoid duplicate move events
[wxWidgets.git] / src / dfb / overlay.cpp
CommitLineData
30c841c8
VS
1/////////////////////////////////////////////////////////////////////////////
2// Name: src/dfb/overlay.cpp
3// Purpose: wxOverlay implementation for wxDFB
4// Author: Vaclav Slavik
5// Created: 2006-10-20
30c841c8
VS
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
23205be8
VS
25#ifndef WX_PRECOMP
26 #include "wx/window.h"
27 #include "wx/dcclient.h"
28#endif
29
30c841c8 30#include "wx/private/overlay.h"
4a624f6e 31#include "wx/dfb/dcclient.h"
30c841c8
VS
32#include "wx/dfb/private.h"
33
34// ============================================================================
35// implementation
36// ============================================================================
37
38// ----------------------------------------------------------------------------
39// wxOverlay
40// ----------------------------------------------------------------------------
41
42wxOverlayImpl::wxOverlayImpl()
43{
44 m_window = NULL;
45 m_isEmpty = true;
46}
47
48wxOverlayImpl::~wxOverlayImpl()
49{
50 Reset();
51}
52
53bool wxOverlayImpl::IsOk()
54{
55 return m_window != NULL;
56}
57
a1657b63 58void wxOverlayImpl::Init(wxDC *dc, int x, int y, int width, int height)
30c841c8 59{
4a624f6e 60 wxCHECK_RET( dc, "NULL dc pointer" );
30c841c8
VS
61 wxASSERT_MSG( !IsOk() , _("You cannot Init an overlay twice") );
62
4a624f6e
VZ
63 wxDFBDCImpl * const dcimpl = wxDynamicCast(dc->GetImpl(), wxDFBDCImpl);
64 wxCHECK_RET( dcimpl, "must have a DFB wxDC" );
65
30c841c8
VS
66 m_window = dc->GetWindow();
67
68 m_rect = wxRect(x, y, width, height);
4ca64d41
VS
69 if ( wxDynamicCast(dc, wxClientDC) )
70 m_rect.Offset(m_window->GetClientAreaOrigin());
30c841c8
VS
71
72 // FIXME: create surface with transparency or key color (?)
4a624f6e
VZ
73 m_surface = dcimpl->GetDirectFBSurface()->CreateCompatible
74 (
75 m_rect.GetSize(),
76 wxIDirectFBSurface::CreateCompatible_NoBackBuffer
77 );
30c841c8
VS
78
79 m_window->AddOverlay(this);
80}
81
a1657b63 82void wxOverlayImpl::BeginDrawing(wxDC *dc)
30c841c8 83{
4a624f6e
VZ
84 wxCHECK_RET( dc, "NULL dc pointer" );
85
86 wxWindowDCImpl * const
87 dcimpl = static_cast<wxWindowDCImpl *>(dc->GetImpl());
88
4ca64d41
VS
89 wxPoint origin(m_rect.GetPosition());
90 if ( wxDynamicCast(dc, wxClientDC) )
91 origin -= m_window->GetClientAreaOrigin();
30c841c8
VS
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).
4a624f6e
VZ
97 dcimpl->DFBInit(m_surface);
98 dcimpl->m_shouldFlip = false;
30c841c8 99 dc->SetDeviceOrigin(-origin.x, -origin.y);
30c841c8
VS
100
101 m_isEmpty = false;
102}
103
a1657b63 104void wxOverlayImpl::EndDrawing(wxDC *WXUNUSED(dc))
30c841c8
VS
105{
106 m_window->RefreshWindowRect(m_rect);
107}
108
a1657b63 109void wxOverlayImpl::Clear(wxDC *WXUNUSED(dc))
30c841c8
VS
110{
111 wxASSERT_MSG( IsOk(),
a5001e93 112 "You cannot Clear an overlay that is not initialized" );
30c841c8
VS
113
114 m_isEmpty = true;
115}
116
117void wxOverlayImpl::Reset()
118{
119 if ( m_window )
120 {
121 m_window->RemoveOverlay(this);
122 m_window = NULL;
123 m_surface.Reset();
124 }
125}