1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/dfb/dcclient.cpp
3 // Purpose: wxWindowDC, wxClientDC and wxPaintDC
4 // Author: Vaclav Slavik
7 // Copyright: (c) 2006 REA Elektronik GmbH
8 // Licence: wxWindows licence
9 /////////////////////////////////////////////////////////////////////////////
11 // ===========================================================================
13 // ===========================================================================
15 // ---------------------------------------------------------------------------
17 // ---------------------------------------------------------------------------
19 // For compilers that support precompilation, includes "wx.h".
20 #include "wx/wxprec.h"
26 #include "wx/dcclient.h"
29 #include "wx/window.h"
32 #include "wx/dfb/private.h"
34 // ===========================================================================
36 // ===========================================================================
38 //-----------------------------------------------------------------------------
40 //-----------------------------------------------------------------------------
42 IMPLEMENT_DYNAMIC_CLASS(wxWindowDC
, wxDC
)
44 wxWindowDC::wxWindowDC(wxWindow
*win
)
46 InitForWin(win
, NULL
);
49 void wxWindowDC::InitForWin(wxWindow
*win
, const wxRect
*rect
)
51 wxCHECK_RET( win
, _T("invalid window") );
53 // FIXME: this should be made to work: we need to detect that the window
54 // is not visible and in that case, a) ignore any drawing actions
55 // and b) provide dummy surface that can still be used to get
56 // information (e.g. text extents):
57 for ( wxWindow
*w
= win
; w
; w
= w
->GetParent() )
59 // painting on hidden TLW when non-TLW windows are shown is OK,
60 // DirectFB manages that:
61 if ( w
->IsTopLevel() )
64 wxASSERT_MSG( w
->IsShown(),
65 _T("painting on hidden window not implemented yet") );
68 // check if the rectangle covers full window and so is not needed:
69 if ( rect
&& *rect
== wxRect(win
->GetSize()) )
72 // obtain the surface used for painting:
73 wxIDirectFBSurfacePtr surface
;
76 wxCHECK_RET( win
->GetSize().x
> 0 && win
->GetSize().y
> 0,
77 _T("window has invalid size") );
79 surface
= win
->GetDfbSurface();
83 wxCHECK_RET( !rect
|| !rect
->IsEmpty(), _T("invalid rectangle") );
85 DFBRectangle dfbrect
= { rect
->x
, rect
->y
, rect
->width
, rect
->height
};
86 surface
= win
->GetDfbSurface()->GetSubSurface(&dfbrect
);
93 SetFont(win
->GetFont());
95 // offset coordinates to account for subsurface's origin coordinates:
97 SetDeviceOrigin(rect
->x
, rect
->y
);
100 //-----------------------------------------------------------------------------
101 // base class for wxClientDC and wxPaintDC
102 //-----------------------------------------------------------------------------
104 wxClientDCBase::wxClientDCBase(wxWindow
*win
)
106 wxCHECK_RET( win
, _T("invalid window") );
108 wxRect rect
= win
->GetClientRect();
109 InitForWin(win
, &rect
);
112 //-----------------------------------------------------------------------------
114 //-----------------------------------------------------------------------------
116 IMPLEMENT_DYNAMIC_CLASS(wxClientDC
, wxWindowDC
)
118 wxClientDC::~wxClientDC()
120 // flip to surface so that the changes become visible
121 wxIDirectFBSurfacePtr
surface(GetDirectFBSurface());
123 // FIXME: do this only if the surface was modified (as opposed to e.g.
124 // used only to obtain text metrics)
126 surface
->Flip(NULL
, DSFLIP_NONE
);
129 //-----------------------------------------------------------------------------
131 //-----------------------------------------------------------------------------
133 IMPLEMENT_DYNAMIC_CLASS(wxPaintDC
, wxWindowDC
)
135 #warning "wxPaintDC ctor must respect m_updateRegion"
137 wxPaintDC::~wxPaintDC()
139 // NB: do *not* flip the surface: wxPaintDC is used with EVT_PAINT and the
140 // surface will be flipped for the entire TLW once all children are