use C++ wrappers around DirectFB API for easier use
[wxWidgets.git] / src / dfb / dcclient.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/dfb/dcclient.cpp
3 // Purpose: wxWindowDC, wxClientDC and wxPaintDC
4 // Author: Vaclav Slavik
5 // Created: 2006-08-10
6 // RCS-ID: $Id$
7 // Copyright: (c) 2006 REA Elektronik GmbH
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/dcclient.h"
27
28 #ifndef WX_PRECOMP
29 #include "wx/window.h"
30 #endif
31
32 #include "wx/dfb/private.h"
33
34 // ===========================================================================
35 // implementation
36 // ===========================================================================
37
38 //-----------------------------------------------------------------------------
39 // wxWindowDC
40 //-----------------------------------------------------------------------------
41
42 IMPLEMENT_DYNAMIC_CLASS(wxWindowDC, wxDC)
43
44 wxWindowDC::wxWindowDC(wxWindow *win)
45 : wxDC(win ? win->GetDfbSurface() : NULL)
46 {
47 InitForWin(win);
48 }
49
50 void wxWindowDC::InitForWin(wxWindow *win)
51 {
52 wxCHECK_RET( win, _T("invalid window") );
53
54 SetFont(win->GetFont());
55 }
56
57 //-----------------------------------------------------------------------------
58 // base class for wxClientDC and wxPaintDC
59 //-----------------------------------------------------------------------------
60
61 wxClientDCBase::wxClientDCBase(wxWindow *win)
62 {
63 wxCHECK_RET( win, _T("invalid window") );
64
65 wxRect rect = win->GetClientRect();
66 DFBRectangle dfbrect = { rect.x, rect.y, rect.width, rect.height };
67
68 wxIDirectFBSurfacePtr subsurf(
69 win->GetDfbSurface()->GetSubSurface(&dfbrect));
70 if ( !subsurf )
71 return;
72
73 Init(subsurf);
74 InitForWin(win);
75
76 // offset coordinates to account for subsurface's origin coordinates:
77 SetDeviceOrigin(rect.x, rect.y);
78 }
79
80 //-----------------------------------------------------------------------------
81 // wxClientDC
82 //-----------------------------------------------------------------------------
83
84 IMPLEMENT_DYNAMIC_CLASS(wxClientDC, wxWindowDC)
85
86 wxClientDC::~wxClientDC()
87 {
88 // flip to surface so that the changes become visible
89 wxIDirectFBSurfacePtr surface(GetDirectFBSurface());
90 if ( surface )
91 surface->Flip(NULL, DSFLIP_NONE);
92 }
93
94 //-----------------------------------------------------------------------------
95 // wxPaintDC
96 //-----------------------------------------------------------------------------
97
98 IMPLEMENT_DYNAMIC_CLASS(wxPaintDC, wxWindowDC)
99
100 #warning "wxPaintDC ctor must respect m_updateRegion"
101
102 wxPaintDC::~wxPaintDC()
103 {
104 // NB: do *not* flip the surface: wxPaintDC is used with EVT_PAINT and the
105 // surface will be flipped for the entire TLW once all children are
106 // repainted
107 }