]> git.saurik.com Git - wxWidgets.git/blob - src/dfb/utils.cpp
fixing osx_cocoa
[wxWidgets.git] / src / dfb / utils.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/dfb/utils.cpp
3 // Purpose: Miscellaneous utility functions and classes
4 // Author: Vaclav Slavik
5 // Created: 2006-08-08
6 // RCS-ID: $Id$
7 // Copyright: (c) 2006 REA Elektronik GmbH
8 // Licence: wxWindows licence
9 /////////////////////////////////////////////////////////////////////////////
10
11 // For compilers that support precompilation, includes "wx.h".
12 #include "wx/wxprec.h"
13
14 #ifdef __BORLANDC__
15 #pragma hdrstop
16 #endif
17
18 #include "wx/utils.h"
19 #include "wx/evtloop.h"
20 #include "wx/apptrait.h"
21 #include "wx/unix/execute.h"
22 #include "wx/unix/private/timer.h"
23
24 #ifndef WX_PRECOMP
25 #include "wx/app.h"
26 #endif
27
28 #include "wx/dfb/private.h"
29 #include <directfb_version.h>
30
31 // ----------------------------------------------------------------------------
32 // toolkit info
33 // ----------------------------------------------------------------------------
34
35 wxPortId wxGUIAppTraits::GetToolkitVersion(int *verMaj, int *verMin) const
36 {
37 if ( verMaj ) *verMaj = DIRECTFB_MAJOR_VERSION;
38 if ( verMin ) *verMaj = DIRECTFB_MINOR_VERSION;
39
40 return wxPORT_DFB;
41 }
42
43
44 wxEventLoopBase* wxGUIAppTraits::CreateEventLoop()
45 {
46 return new wxEventLoop;
47 }
48
49 wxTimerImpl *wxGUIAppTraits::CreateTimerImpl(wxTimer *timer)
50 {
51 return new wxUnixTimerImpl(timer);
52 }
53
54 // ----------------------------------------------------------------------------
55 // display characteristics
56 // ----------------------------------------------------------------------------
57
58 bool wxColourDisplay()
59 {
60 #warning "FIXME: wxColourDisplay"
61 return true;
62 }
63
64 int wxDisplayDepth()
65 {
66 return wxTheApp->GetDisplayMode().bpp;
67 }
68
69 void wxDisplaySize(int *width, int *height)
70 {
71 wxVideoMode mode(wxTheApp->GetDisplayMode());
72 if ( width ) *width = mode.w;
73 if ( height ) *height = mode.h;
74 }
75
76 void wxDisplaySizeMM(int *width, int *height)
77 {
78 // FIXME: there's no way to get physical resolution using the DirectDB
79 // API, we hardcode a commonly used value of 72dpi
80 #define DPI 72.0
81 #define PX_TO_MM(x) (int(((x) / DPI) * inches2mm))
82
83 wxDisplaySize(width, height);
84 if ( width ) *width = PX_TO_MM(*width);
85 if ( height ) *height = PX_TO_MM(*height);
86
87 #undef DPI
88 #undef PX_TO_MM
89 }
90
91 void wxClientDisplayRect(int *x, int *y, int *width, int *height)
92 {
93 // return desktop dimensions minus any panels, menus, trays:
94 if (x) *x = 0;
95 if (y) *y = 0;
96 wxDisplaySize(width, height);
97 }
98
99
100 //-----------------------------------------------------------------------------
101 // mouse
102 //-----------------------------------------------------------------------------
103
104 void wxGetMousePosition(int *x, int *y)
105 {
106 wxIDirectFBDisplayLayerPtr layer(wxIDirectFB::Get()->GetDisplayLayer());
107 if ( layer )
108 layer->GetCursorPosition(x, y);
109 }
110
111 wxPoint wxGetMousePosition()
112 {
113 wxPoint pt;
114 wxGetMousePosition(&pt.x, &pt.y);
115 return pt;
116 }
117
118 //-----------------------------------------------------------------------------
119 // keyboard
120 //-----------------------------------------------------------------------------
121
122 bool wxGetKeyState(wxKeyCode key)
123 {
124 wxASSERT_MSG(key != WXK_LBUTTON && key != WXK_RBUTTON && key != WXK_MBUTTON,
125 "can't use wxGetKeyState() for mouse buttons");
126
127 return false; // FIXME
128 }
129
130 //----------------------------------------------------------------------------
131 // misc.
132 //----------------------------------------------------------------------------
133
134 void wxBell()
135 {
136 }