]> git.saurik.com Git - wxWidgets.git/blob - src/dfb/wrapdfb.cpp
added wxWindow::IsVisible() method
[wxWidgets.git] / src / dfb / wrapdfb.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/dfb/wrapdfb.cpp
3 // Purpose: wx wrappers for DirectFB interfaces
4 // Author: Vaclav Slavik
5 // Created: 2006-09-04
6 // RCS-ID: $Id$
7 // Copyright: (c) 2006 REA Elektronik GmbH
8 // Licence: wxWindows licence
9 /////////////////////////////////////////////////////////////////////////////
10
11 // For compilers that support precompilation, includes "wx.h".
12 #include "wx/wxprec.h"
13
14 #ifdef __BORLANDC__
15 #pragma hdrstop
16 #endif
17
18 #include "wx/dfb/wrapdfb.h"
19
20 //-----------------------------------------------------------------------------
21 // wxDfbCheckReturn
22 //-----------------------------------------------------------------------------
23
24 bool wxDfbCheckReturn(DFBResult code)
25 {
26 switch ( code )
27 {
28 case DFB_OK:
29 return true;
30
31 // these are programming errors, assert:
32 #define DFB_ASSERT(code) \
33 case code: \
34 wxFAIL_MSG( _T("DirectFB error: ") _T(#code) ); \
35 return false \
36
37 DFB_ASSERT(DFB_DEAD);
38 DFB_ASSERT(DFB_UNSUPPORTED);
39 DFB_ASSERT(DFB_UNIMPLEMENTED);
40 DFB_ASSERT(DFB_INVARG);
41 DFB_ASSERT(DFB_NOIMPL);
42 DFB_ASSERT(DFB_MISSINGFONT);
43 DFB_ASSERT(DFB_THIZNULL);
44 DFB_ASSERT(DFB_INVAREA);
45 DFB_ASSERT(DFB_DESTROYED);
46 DFB_ASSERT(DFB_NOSUCHMETHOD);
47 DFB_ASSERT(DFB_NOSUCHINSTANCE);
48 DFB_ASSERT(DFB_VERSIONMISMATCH);
49
50 #undef DFB_ASSERT
51
52 // these are not errors, but valid return codes:
53 case DFB_INTERRUPTED:
54 case DFB_BUFFEREMPTY:
55 return true;
56
57 default:
58 // FIXME: should handle the errors individually
59 wxLogError(_("DirectFB error %d occured."), (int)code);
60 return false;
61 }
62 }
63
64 //-----------------------------------------------------------------------------
65 // wxDfbPtrBase
66 //-----------------------------------------------------------------------------
67
68 /* static */
69 void wxDfbPtrBase::DoAddRef(wxDfbWrapperBase *ptr)
70 {
71 ptr->AddRef();
72 }
73
74 void wxDfbPtrBase::DoRelease(wxDfbWrapperBase *ptr)
75 {
76 ptr->Release();
77 }
78
79 //-----------------------------------------------------------------------------
80 // wxIDirectFB
81 //-----------------------------------------------------------------------------
82
83 wxIDirectFBPtr wxIDirectFB::ms_ptr;
84
85 /* static */
86 void wxIDirectFB::CreateDirectFB()
87 {
88 IDirectFB *dfb;
89 if ( wxDfbCheckReturn(DirectFBCreate(&dfb)) )
90 ms_ptr = new wxIDirectFB(dfb);
91 }
92
93 /* static */
94 void wxIDirectFB::CleanUp()
95 {
96 ms_ptr.Reset();
97 }