]> git.saurik.com Git - wxWidgets.git/blob - src/dfb/utils.cpp
Check for buffer being big enough in wxPathOnly().
[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/private/timer.h"
22
23 #ifndef WX_PRECOMP
24 #include "wx/app.h"
25 #endif
26
27 #include "wx/dfb/private.h"
28 #include <directfb_version.h>
29
30 // ----------------------------------------------------------------------------
31 // toolkit info
32 // ----------------------------------------------------------------------------
33
34 wxPortId wxGUIAppTraits::GetToolkitVersion(int *verMaj, int *verMin) const
35 {
36 if ( verMaj ) *verMaj = DIRECTFB_MAJOR_VERSION;
37 if ( verMin ) *verMaj = DIRECTFB_MINOR_VERSION;
38
39 return wxPORT_DFB;
40 }
41
42
43 wxEventLoopBase* wxGUIAppTraits::CreateEventLoop()
44 {
45 return new wxEventLoop;
46 }
47
48 wxTimerImpl *wxGUIAppTraits::CreateTimerImpl(wxTimer *timer)
49 {
50 return new wxUnixTimerImpl(timer);
51 }
52
53 // ----------------------------------------------------------------------------
54 // display characteristics
55 // ----------------------------------------------------------------------------
56
57 bool wxColourDisplay()
58 {
59 #warning "FIXME: wxColourDisplay"
60 return true;
61 }
62
63 int wxDisplayDepth()
64 {
65 return wxTheApp->GetDisplayMode().bpp;
66 }
67
68 void wxDisplaySize(int *width, int *height)
69 {
70 wxVideoMode mode(wxTheApp->GetDisplayMode());
71 if ( width ) *width = mode.w;
72 if ( height ) *height = mode.h;
73 }
74
75 void wxDisplaySizeMM(int *width, int *height)
76 {
77 // FIXME: there's no way to get physical resolution using the DirectDB
78 // API, we hardcode a commonly used value of 72dpi
79 #define DPI 72.0
80 #define PX_TO_MM(x) (int(((x) / DPI) * inches2mm))
81
82 wxDisplaySize(width, height);
83 if ( width ) *width = PX_TO_MM(*width);
84 if ( height ) *height = PX_TO_MM(*height);
85
86 #undef DPI
87 #undef PX_TO_MM
88 }
89
90 void wxClientDisplayRect(int *x, int *y, int *width, int *height)
91 {
92 // return desktop dimensions minus any panels, menus, trays:
93 if (x) *x = 0;
94 if (y) *y = 0;
95 wxDisplaySize(width, height);
96 }
97
98
99 //-----------------------------------------------------------------------------
100 // mouse
101 //-----------------------------------------------------------------------------
102
103 void wxGetMousePosition(int *x, int *y)
104 {
105 wxIDirectFBDisplayLayerPtr layer(wxIDirectFB::Get()->GetDisplayLayer());
106 if ( layer )
107 layer->GetCursorPosition(x, y);
108 }
109
110 wxPoint wxGetMousePosition()
111 {
112 wxPoint pt;
113 wxGetMousePosition(&pt.x, &pt.y);
114 return pt;
115 }
116
117 //-----------------------------------------------------------------------------
118 // keyboard
119 //-----------------------------------------------------------------------------
120
121 bool wxGetKeyState(wxKeyCode key)
122 {
123 wxASSERT_MSG(key != WXK_LBUTTON && key != WXK_RBUTTON && key != WXK_MBUTTON,
124 "can't use wxGetKeyState() for mouse buttons");
125
126 return false; // FIXME
127 }
128
129 //----------------------------------------------------------------------------
130 // misc.
131 //----------------------------------------------------------------------------
132
133 void wxBell()
134 {
135 }