1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/dfb/utils.cpp
3 // Purpose: Miscellaneous utility functions and classes
4 // Author: Vaclav Slavik
6 // Copyright: (c) 2006 REA Elektronik GmbH
7 // Licence: wxWindows licence
8 /////////////////////////////////////////////////////////////////////////////
10 // For compilers that support precompilation, includes "wx.h".
11 #include "wx/wxprec.h"
18 #include "wx/evtloop.h"
19 #include "wx/apptrait.h"
20 #include "wx/unix/private/timer.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
;
42 wxEventLoopBase
* wxGUIAppTraits::CreateEventLoop()
44 return new wxEventLoop
;
47 wxTimerImpl
*wxGUIAppTraits::CreateTimerImpl(wxTimer
*timer
)
49 return new wxUnixTimerImpl(timer
);
52 // ----------------------------------------------------------------------------
53 // display characteristics
54 // ----------------------------------------------------------------------------
56 bool wxColourDisplay()
58 #warning "FIXME: wxColourDisplay"
64 return wxTheApp
->GetDisplayMode().bpp
;
67 void wxDisplaySize(int *width
, int *height
)
69 wxVideoMode
mode(wxTheApp
->GetDisplayMode());
70 if ( width
) *width
= mode
.w
;
71 if ( height
) *height
= mode
.h
;
74 void wxDisplaySizeMM(int *width
, int *height
)
76 // FIXME: there's no way to get physical resolution using the DirectDB
77 // API, we hardcode a commonly used value of 72dpi
79 #define PX_TO_MM(x) (int(((x) / DPI) * inches2mm))
81 wxDisplaySize(width
, height
);
82 if ( width
) *width
= PX_TO_MM(*width
);
83 if ( height
) *height
= PX_TO_MM(*height
);
89 void wxClientDisplayRect(int *x
, int *y
, int *width
, int *height
)
91 // return desktop dimensions minus any panels, menus, trays:
94 wxDisplaySize(width
, height
);
98 //-----------------------------------------------------------------------------
100 //-----------------------------------------------------------------------------
102 void wxGetMousePosition(int *x
, int *y
)
104 wxIDirectFBDisplayLayerPtr
layer(wxIDirectFB::Get()->GetDisplayLayer());
106 layer
->GetCursorPosition(x
, y
);
109 wxPoint
wxGetMousePosition()
112 wxGetMousePosition(&pt
.x
, &pt
.y
);
116 //-----------------------------------------------------------------------------
118 //-----------------------------------------------------------------------------
120 bool wxGetKeyState(wxKeyCode key
)
122 wxASSERT_MSG(key
!= WXK_LBUTTON
&& key
!= WXK_RBUTTON
&& key
!= WXK_MBUTTON
,
123 "can't use wxGetKeyState() for mouse buttons");
125 return false; // FIXME
128 //----------------------------------------------------------------------------
130 //----------------------------------------------------------------------------