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