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_
19 #include "wx/dfb/ifacehelpers.h"
21 wxDFB_DECLARE_INTERFACE(IDirectFB
);
22 wxDFB_DECLARE_INTERFACE(IDirectFBDisplayLayer
);
23 wxDFB_DECLARE_INTERFACE(IDirectFBSurface
);
24 wxDFB_DECLARE_INTERFACE(IDirectFBPalette
);
26 //-----------------------------------------------------------------------------
28 //-----------------------------------------------------------------------------
30 // convert string from wxString to UTF-8 encoded const char*
32 #define wxSTR_TO_DFB(s) (s).mb_str(wxConvUTF8)
34 #define wxSTR_TO_DFB(s) wxConvUTF8.cWC2MB((s).wc_str(*wxConvUI))
37 //-----------------------------------------------------------------------------
39 //-----------------------------------------------------------------------------
41 inline bool wxDfbCheckReturn(DFBResult code
)
48 // these are programming errors, assert:
49 #define DFB_ASSERT(code) \
51 wxFAIL_MSG( _T("DirectFB error: ") _T(#code) ); \
55 DFB_ASSERT(DFB_UNSUPPORTED
);
56 DFB_ASSERT(DFB_UNIMPLEMENTED
);
57 DFB_ASSERT(DFB_INVARG
);
58 DFB_ASSERT(DFB_NOIMPL
);
59 DFB_ASSERT(DFB_MISSINGFONT
);
60 DFB_ASSERT(DFB_THIZNULL
);
61 DFB_ASSERT(DFB_INVAREA
);
62 DFB_ASSERT(DFB_DESTROYED
);
63 DFB_ASSERT(DFB_NOSUCHMETHOD
);
64 DFB_ASSERT(DFB_NOSUCHINSTANCE
);
65 DFB_ASSERT(DFB_VERSIONMISMATCH
);
69 // these are not errors, but valid return codes:
75 // FIXME: should handle the errors individually
76 wxLogError(_("DirectFB error %d occured."), (int)code
);
82 Wrap all calls to DirectFB in this macro so that the return value is
83 checked and errors reported as appropriate.
85 Returns true if the call succeeded, false otherwise.
87 #define DFB_CALL(call) (wxDfbCheckReturn(call))
90 //-----------------------------------------------------------------------------
91 // surface manipulation helpers
92 //-----------------------------------------------------------------------------
94 /// Mode of wxDfbCloneSurface() call
95 enum wxDfbCloneSurfaceMode
97 /// Don't copy surface pixels, just clone surface size and attributes
98 wxDfbCloneSurface_NoPixels
= 0,
99 /// Make exact copy, including the pixels
100 wxDfbCloneSurface_CopyPixels
104 Creates a new surface by cloning existing one. Depending on @a mode,
105 either makes exact copy (wxDfbCloneSurface_CopyPixels) or only creates a
106 new surface with the same size and attributes (wxDfbCloneSurface_NoPixels).
108 IDirectFBSurfacePtr
wxDfbCloneSurface(const IDirectFBSurfacePtr
& s
,
109 wxDfbCloneSurfaceMode mode
);
111 /// Returns bit depth used by the surface
112 int wxDfbGetSurfaceDepth(const IDirectFBSurfacePtr
& s
);
114 /// Returns interface to the primary display layer:
115 IDirectFBDisplayLayerPtr
wxDfbGetDisplayLayer();
117 /// Returns interface to the primary surface:
118 IDirectFBSurfacePtr
wxDfbGetPrimarySurface();
121 //-----------------------------------------------------------------------------
123 //-----------------------------------------------------------------------------
126 The struct defined by this macro is a thin wrapper around DFB*Event type.
127 It is needed because DFB*Event are typedefs and so we can't forward declare
128 them, but we need to pass them to methods declared in public headers where
129 <directfb.h> cannot be included. So this struct just holds the event value,
130 it's sole purpose is that it can be forward declared.
132 #define WXDFB_DEFINE_EVENT_WRAPPER(T) \
136 wx##T(const T& event) : m_event(event) {} \
138 operator T&() { return m_event; } \
139 operator const T&() const { return m_event; } \
140 T* operator&() { return &m_event; } \
142 DFBEventClass GetClass() const { return m_event.clazz; } \
148 WXDFB_DEFINE_EVENT_WRAPPER(DFBEvent
)
149 WXDFB_DEFINE_EVENT_WRAPPER(DFBWindowEvent
)
151 /// Convert DirectFB timestamp to wxEvent one:
152 #define wxDFB_EVENT_TIMESTAMP(event) \
153 ((event).timestamp.tv_sec * 1000 + (event).timestamp.tv_usec / 1000)
156 #endif // _WX_DFB_PRIVATE_H_