1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/dfb/private.h
3 // Purpose: private helpers for wxDFB implementation
4 // Author: Vaclav Slavik
7 // Copyright: (c) 2006 REA Elektronik GmbH
8 // Licence: wxWindows licence
9 /////////////////////////////////////////////////////////////////////////////
11 #ifndef _WX_DFB_PRIVATE_H_
12 #define _WX_DFB_PRIVATE_H_
18 #include <directfb_version.h>
20 #include "wx/dfb/ifacehelpers.h"
22 wxDFB_DECLARE_INTERFACE(IDirectFB
);
23 wxDFB_DECLARE_INTERFACE(IDirectFBDisplayLayer
);
24 wxDFB_DECLARE_INTERFACE(IDirectFBSurface
);
25 wxDFB_DECLARE_INTERFACE(IDirectFBPalette
);
27 //-----------------------------------------------------------------------------
29 //-----------------------------------------------------------------------------
31 // convert string from wxString to UTF-8 encoded const char*
33 #define wxSTR_TO_DFB(s) (s).mb_str(wxConvUTF8)
35 #define wxSTR_TO_DFB(s) wxConvUTF8.cWC2MB((s).wc_str(*wxConvUI))
38 //-----------------------------------------------------------------------------
40 //-----------------------------------------------------------------------------
42 inline bool wxDfbCheckReturn(DFBResult code
)
49 // these are programming errors, assert:
50 #define DFB_ASSERT(code) \
52 wxFAIL_MSG( _T("DirectFB error: ") _T(#code) ); \
56 DFB_ASSERT(DFB_UNSUPPORTED
);
57 DFB_ASSERT(DFB_UNIMPLEMENTED
);
58 DFB_ASSERT(DFB_INVARG
);
59 DFB_ASSERT(DFB_NOIMPL
);
60 DFB_ASSERT(DFB_MISSINGFONT
);
61 DFB_ASSERT(DFB_THIZNULL
);
62 DFB_ASSERT(DFB_INVAREA
);
63 DFB_ASSERT(DFB_DESTROYED
);
64 DFB_ASSERT(DFB_NOSUCHMETHOD
);
65 DFB_ASSERT(DFB_NOSUCHINSTANCE
);
66 DFB_ASSERT(DFB_VERSIONMISMATCH
);
70 // these are not errors, but valid return codes:
76 // FIXME: should handle the errors individually
77 wxLogError(_("DirectFB error %d occured."), (int)code
);
83 Wrap all calls to DirectFB in this macro so that the return value is
84 checked and errors reported as appropriate.
86 Returns true if the call succeeded, false otherwise.
88 #define DFB_CALL(call) (wxDfbCheckReturn(call))
91 //-----------------------------------------------------------------------------
92 // surface manipulation helpers
93 //-----------------------------------------------------------------------------
95 /// Mode of wxDfbCloneSurface() call
96 enum wxDfbCloneSurfaceMode
98 /// Don't copy surface pixels, just clone surface size and attributes
99 wxDfbCloneSurface_NoPixels
= 0,
100 /// Make exact copy, including the pixels
101 wxDfbCloneSurface_CopyPixels
105 Creates a new surface by cloning existing one. Depending on @a mode,
106 either makes exact copy (wxDfbCloneSurface_CopyPixels) or only creates a
107 new surface with the same size and attributes (wxDfbCloneSurface_NoPixels).
109 IDirectFBSurfacePtr
wxDfbCloneSurface(const IDirectFBSurfacePtr
& s
,
110 wxDfbCloneSurfaceMode mode
);
112 /// Returns bit depth used by the surface
113 int wxDfbGetSurfaceDepth(const IDirectFBSurfacePtr
& s
);
115 /// Returns interface to the primary display layer:
116 IDirectFBDisplayLayerPtr
wxDfbGetDisplayLayer();
118 /// Returns interface to the primary surface:
119 IDirectFBSurfacePtr
wxDfbGetPrimarySurface();
122 //-----------------------------------------------------------------------------
124 //-----------------------------------------------------------------------------
127 The struct defined by this macro is a thin wrapper around DFB*Event type.
128 It is needed because DFB*Event are typedefs and so we can't forward declare
129 them, but we need to pass them to methods declared in public headers where
130 <directfb.h> cannot be included. So this struct just holds the event value,
131 it's sole purpose is that it can be forward declared.
133 #define WXDFB_DEFINE_EVENT_WRAPPER(T) \
137 wx##T(const T& event) : m_event(event) {} \
139 operator T&() { return m_event; } \
140 operator const T&() const { return m_event; } \
141 T* operator&() { return &m_event; } \
143 DFBEventClass GetClass() const { return m_event.clazz; } \
149 WXDFB_DEFINE_EVENT_WRAPPER(DFBEvent
)
150 WXDFB_DEFINE_EVENT_WRAPPER(DFBWindowEvent
)
152 /// Convert DirectFB timestamp to wxEvent one:
153 #define wxDFB_EVENT_TIMESTAMP(event) \
154 ((event).timestamp.tv_sec * 1000 + (event).timestamp.tv_usec / 1000)
157 Check if DirectFB library version is at least @a major.@a minor.@a release.
161 #define wxCHECK_DFB_VERSION(major,minor,release) \
162 (DIRECTFB_MAJOR_VERSION > (major) || \
163 (DIRECTFB_MAJOR_VERSION == (major) && \
164 DIRECTFB_MINOR_VERSION > (minor)) || \
165 (DIRECTFB_MAJOR_VERSION == (major) && \
166 DIRECTFB_MINOR_VERSION == (minor) && \
167 DIRECTFB_MICRO_VERSION >= (release)))
169 #endif // _WX_DFB_PRIVATE_H_