1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/dfb/utils.cpp
3 // Purpose: Miscellaneous utility functions and classes
4 // Author: Vaclav Slavik
7 // Copyright: (c) 2006 REA Elektronik GmbH
8 // Licence: wxWindows licence
9 /////////////////////////////////////////////////////////////////////////////
11 // For compilers that support precompilation, includes "wx.h".
12 #include "wx/wxprec.h"
19 #include "wx/apptrait.h"
20 #include "wx/unix/execute.h"
26 #include "wx/dfb/private.h"
27 #include <directfb_version.h>
29 // ----------------------------------------------------------------------------
31 // ----------------------------------------------------------------------------
33 wxPortId
wxGUIAppTraits::GetToolkitVersion(int *verMaj
, int *verMin
) const
35 if ( verMaj
) *verMaj
= DIRECTFB_MAJOR_VERSION
;
36 if ( verMin
) *verMaj
= DIRECTFB_MINOR_VERSION
;
41 // ----------------------------------------------------------------------------
42 // display characteristics
43 // ----------------------------------------------------------------------------
45 bool wxColourDisplay()
47 #warning "FIXME: wxColourDisplay"
53 return wxTheApp
->GetDisplayMode().bpp
;
56 void wxDisplaySize(int *width
, int *height
)
58 wxVideoMode
mode(wxTheApp
->GetDisplayMode());
59 if ( width
) *width
= mode
.w
;
60 if ( height
) *height
= mode
.h
;
63 void wxDisplaySizeMM(int *width
, int *height
)
65 // FIXME: there's no way to get physical resolution using the DirectDB
66 // API, we hardcode a commonly used value of 72dpi
68 #define PX_TO_MM(x) (int(((x) / DPI) * inches2mm))
70 wxDisplaySize(width
, height
);
71 if ( width
) *width
= PX_TO_MM(*width
);
72 if ( height
) *height
= PX_TO_MM(*height
);
78 void wxClientDisplayRect(int *x
, int *y
, int *width
, int *height
)
80 // return desktop dimensions minus any panels, menus, trays:
83 wxDisplaySize(width
, height
);
86 //-----------------------------------------------------------------------------
87 // surface manipulation helpers
88 //-----------------------------------------------------------------------------
90 wxIDirectFBSurfacePtr
wxDfbCloneSurface(const wxIDirectFBSurfacePtr
& s
,
91 wxDfbCloneSurfaceMode mode
)
96 DFBSurfaceDescription desc
;
97 desc
.flags
= (DFBSurfaceDescriptionFlags
)(
98 DSDESC_CAPS
| DSDESC_WIDTH
| DSDESC_HEIGHT
| DSDESC_PIXELFORMAT
);
99 s
->GetCapabilities(&desc
.caps
);
100 s
->GetSize(&desc
.width
, &desc
.height
);
101 s
->GetPixelFormat(&desc
.pixelformat
);
103 wxIDirectFBSurfacePtr
snew(wxIDirectFB::Get()->CreateSurface(&desc
));
107 if ( desc
.pixelformat
== DSPF_LUT8
)
109 wxIDirectFBPalettePtr
pal(s
->GetPalette());
112 if ( !snew
->SetPalette(pal
) )
117 if ( mode
== wxDfbCloneSurface_CopyPixels
)
119 if ( !snew
->SetBlittingFlags(DSBLIT_NOFX
) )
121 if ( !snew
->Blit(s
, NULL
, 0, 0) )
128 int wxDfbGetSurfaceDepth(const wxIDirectFBSurfacePtr
& s
)
130 wxCHECK_MSG( s
, -1, _T("invalid surface") );
132 DFBSurfacePixelFormat format
= DSPF_UNKNOWN
;
134 if ( !s
->GetPixelFormat(&format
) )
137 return DFB_BITS_PER_PIXEL(format
);
140 wxIDirectFBDisplayLayerPtr
wxDfbGetDisplayLayer()
142 return wxIDirectFB::Get()->GetDisplayLayer(DLID_PRIMARY
);
145 wxIDirectFBSurfacePtr
wxDfbGetPrimarySurface()
147 wxIDirectFBDisplayLayerPtr
layer(wxDfbGetDisplayLayer());
148 return layer
? layer
->GetSurface() : NULL
;
152 //-----------------------------------------------------------------------------
154 //-----------------------------------------------------------------------------
156 void wxGetMousePosition(int *x
, int *y
)
158 wxIDirectFBDisplayLayerPtr
layer(wxDfbGetDisplayLayer());
160 layer
->GetCursorPosition(x
, y
);
163 wxPoint
wxGetMousePosition()
166 wxGetMousePosition(&pt
.x
, &pt
.y
);
170 //-----------------------------------------------------------------------------
172 //-----------------------------------------------------------------------------
174 bool wxGetKeyState(wxKeyCode key
)
176 wxASSERT_MSG(key
!= WXK_LBUTTON
&& key
!= WXK_RBUTTON
&& key
!= WXK_MBUTTON
,
177 _T("can't use wxGetKeyState() for mouse buttons"));
179 return false; // FIXME
182 //----------------------------------------------------------------------------
184 //----------------------------------------------------------------------------
190 int wxAddProcessCallback(wxEndProcessData
*proc_data
, int fd
)
192 wxFAIL_MSG( _T("wxAddProcessCallback not implemented") );