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/evtloop.h"
20 #include "wx/apptrait.h"
21 #include "wx/unix/execute.h"
22 #include "wx/unix/private/timer.h"
28 #include "wx/dfb/private.h"
29 #include <directfb_version.h>
31 // ----------------------------------------------------------------------------
33 // ----------------------------------------------------------------------------
35 wxPortId wxGUIAppTraits::GetToolkitVersion(int *verMaj, int *verMin) const
37 if ( verMaj ) *verMaj = DIRECTFB_MAJOR_VERSION;
38 if ( verMin ) *verMaj = DIRECTFB_MINOR_VERSION;
44 wxEventLoopBase* wxGUIAppTraits::CreateEventLoop()
46 return new wxEventLoop;
49 wxTimerImpl *wxGUIAppTraits::CreateTimerImpl(wxTimer *timer)
51 return new wxUnixTimerImpl(timer);
54 // ----------------------------------------------------------------------------
55 // display characteristics
56 // ----------------------------------------------------------------------------
58 bool wxColourDisplay()
60 #warning "FIXME: wxColourDisplay"
66 return wxTheApp->GetDisplayMode().bpp;
69 void wxDisplaySize(int *width, int *height)
71 wxVideoMode mode(wxTheApp->GetDisplayMode());
72 if ( width ) *width = mode.w;
73 if ( height ) *height = mode.h;
76 void wxDisplaySizeMM(int *width, int *height)
78 // FIXME: there's no way to get physical resolution using the DirectDB
79 // API, we hardcode a commonly used value of 72dpi
81 #define PX_TO_MM(x) (int(((x) / DPI) * inches2mm))
83 wxDisplaySize(width, height);
84 if ( width ) *width = PX_TO_MM(*width);
85 if ( height ) *height = PX_TO_MM(*height);
91 void wxClientDisplayRect(int *x, int *y, int *width, int *height)
93 // return desktop dimensions minus any panels, menus, trays:
96 wxDisplaySize(width, height);
100 //-----------------------------------------------------------------------------
102 //-----------------------------------------------------------------------------
104 void wxGetMousePosition(int *x, int *y)
106 wxIDirectFBDisplayLayerPtr layer(wxIDirectFB::Get()->GetDisplayLayer());
108 layer->GetCursorPosition(x, y);
111 wxPoint wxGetMousePosition()
114 wxGetMousePosition(&pt.x, &pt.y);
118 //-----------------------------------------------------------------------------
120 //-----------------------------------------------------------------------------
122 bool wxGetKeyState(wxKeyCode key)
124 wxASSERT_MSG(key != WXK_LBUTTON && key != WXK_RBUTTON && key != WXK_MBUTTON,
125 "can't use wxGetKeyState() for mouse buttons");
127 return false; // FIXME
130 //----------------------------------------------------------------------------
132 //----------------------------------------------------------------------------