]>
Commit | Line | Data |
---|---|---|
b3c86150 VS |
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/apptrait.h" | |
20 | #include "wx/unix/execute.h" | |
21 | ||
22 | #ifndef WX_PRECOMP | |
23 | #include "wx/app.h" | |
24 | #endif | |
25 | ||
26 | #include "wx/dfb/private.h" | |
27 | #include <directfb_version.h> | |
28 | ||
29 | // ---------------------------------------------------------------------------- | |
30 | // toolkit info | |
31 | // ---------------------------------------------------------------------------- | |
32 | ||
33 | wxPortId wxGUIAppTraits::GetToolkitVersion(int *verMaj, int *verMin) const | |
34 | { | |
35 | if ( verMaj ) *verMaj = DIRECTFB_MAJOR_VERSION; | |
36 | if ( verMin ) *verMaj = DIRECTFB_MINOR_VERSION; | |
37 | ||
38 | return wxPORT_DFB; | |
39 | } | |
40 | ||
41 | // ---------------------------------------------------------------------------- | |
42 | // display characteristics | |
43 | // ---------------------------------------------------------------------------- | |
44 | ||
45 | bool wxColourDisplay() | |
46 | { | |
47 | #warning "FIXME: wxColourDisplay" | |
48 | return true; | |
49 | } | |
50 | ||
51 | int wxDisplayDepth() | |
52 | { | |
53 | return wxTheApp->GetDisplayMode().bpp; | |
54 | } | |
55 | ||
56 | void wxDisplaySize(int *width, int *height) | |
57 | { | |
58 | wxVideoMode mode(wxTheApp->GetDisplayMode()); | |
59 | if ( width ) *width = mode.w; | |
60 | if ( height ) *height = mode.h; | |
61 | } | |
62 | ||
63 | void wxDisplaySizeMM(int *width, int *height) | |
64 | { | |
65 | // FIXME: there's no way to get physical resolution using the DirectDB | |
66 | // API, we hardcode a commonly used value of 72dpi | |
67 | #define DPI 72.0 | |
68 | #define PX_TO_MM(x) (int(((x) / DPI) * inches2mm)) | |
69 | ||
70 | wxDisplaySize(width, height); | |
71 | if ( width ) *width = PX_TO_MM(*width); | |
72 | if ( height ) *height = PX_TO_MM(*height); | |
73 | ||
74 | #undef DPI | |
75 | #undef PX_TO_MM | |
76 | } | |
77 | ||
78 | void wxClientDisplayRect(int *x, int *y, int *width, int *height) | |
79 | { | |
80 | // return desktop dimensions minus any panels, menus, trays: | |
81 | if (x) *x = 0; | |
82 | if (y) *y = 0; | |
83 | wxDisplaySize(width, height); | |
84 | } | |
85 | ||
86 | //----------------------------------------------------------------------------- | |
87 | // surface manipulation helpers | |
88 | //----------------------------------------------------------------------------- | |
89 | ||
52c8d32a VS |
90 | wxIDirectFBSurfacePtr wxDfbCloneSurface(const wxIDirectFBSurfacePtr& s, |
91 | wxDfbCloneSurfaceMode mode) | |
b3c86150 VS |
92 | { |
93 | if ( !s ) | |
94 | return NULL; | |
95 | ||
96 | DFBSurfaceDescription desc; | |
97 | desc.flags = (DFBSurfaceDescriptionFlags)( | |
98 | DSDESC_CAPS | DSDESC_WIDTH | DSDESC_HEIGHT | DSDESC_PIXELFORMAT); | |
52c8d32a VS |
99 | s->GetCapabilities(&desc.caps); |
100 | s->GetSize(&desc.width, &desc.height); | |
101 | s->GetPixelFormat(&desc.pixelformat); | |
b3c86150 | 102 | |
52c8d32a VS |
103 | wxIDirectFBSurfacePtr snew(wxIDirectFB::Get()->CreateSurface(&desc)); |
104 | if ( !snew ) | |
b3c86150 VS |
105 | return NULL; |
106 | ||
52c8d32a | 107 | if ( desc.pixelformat == DSPF_LUT8 ) |
b3c86150 | 108 | { |
52c8d32a VS |
109 | wxIDirectFBPalettePtr pal(s->GetPalette()); |
110 | if ( s ) | |
111 | { | |
112 | if ( !snew->SetPalette(pal) ) | |
113 | return NULL; | |
114 | } | |
b3c86150 VS |
115 | } |
116 | ||
117 | if ( mode == wxDfbCloneSurface_CopyPixels ) | |
118 | { | |
52c8d32a | 119 | if ( !snew->SetBlittingFlags(DSBLIT_NOFX) ) |
b3c86150 | 120 | return NULL; |
52c8d32a | 121 | if ( !snew->Blit(s, NULL, 0, 0) ) |
b3c86150 VS |
122 | return NULL; |
123 | } | |
124 | ||
125 | return snew; | |
126 | } | |
127 | ||
52c8d32a | 128 | int wxDfbGetSurfaceDepth(const wxIDirectFBSurfacePtr& s) |
b3c86150 VS |
129 | { |
130 | wxCHECK_MSG( s, -1, _T("invalid surface") ); | |
131 | ||
132 | DFBSurfacePixelFormat format = DSPF_UNKNOWN; | |
133 | ||
52c8d32a | 134 | if ( !s->GetPixelFormat(&format) ) |
b3c86150 VS |
135 | return -1; |
136 | ||
137 | return DFB_BITS_PER_PIXEL(format); | |
138 | } | |
139 | ||
52c8d32a | 140 | wxIDirectFBDisplayLayerPtr wxDfbGetDisplayLayer() |
b3c86150 | 141 | { |
52c8d32a | 142 | return wxIDirectFB::Get()->GetDisplayLayer(DLID_PRIMARY); |
b3c86150 VS |
143 | } |
144 | ||
52c8d32a | 145 | wxIDirectFBSurfacePtr wxDfbGetPrimarySurface() |
b3c86150 | 146 | { |
52c8d32a VS |
147 | wxIDirectFBDisplayLayerPtr layer(wxDfbGetDisplayLayer()); |
148 | return layer ? layer->GetSurface() : NULL; | |
b3c86150 VS |
149 | } |
150 | ||
151 | ||
152 | //----------------------------------------------------------------------------- | |
153 | // mouse | |
154 | //----------------------------------------------------------------------------- | |
155 | ||
156 | void wxGetMousePosition(int *x, int *y) | |
157 | { | |
52c8d32a VS |
158 | wxIDirectFBDisplayLayerPtr layer(wxDfbGetDisplayLayer()); |
159 | if ( layer ) | |
160 | layer->GetCursorPosition(x, y); | |
b3c86150 VS |
161 | } |
162 | ||
163 | wxPoint wxGetMousePosition() | |
164 | { | |
165 | wxPoint pt; | |
166 | wxGetMousePosition(&pt.x, &pt.y); | |
167 | return pt; | |
168 | } | |
169 | ||
170 | //----------------------------------------------------------------------------- | |
171 | // keyboard | |
172 | //----------------------------------------------------------------------------- | |
173 | ||
174 | bool wxGetKeyState(wxKeyCode key) | |
175 | { | |
176 | wxASSERT_MSG(key != WXK_LBUTTON && key != WXK_RBUTTON && key != WXK_MBUTTON, | |
177 | _T("can't use wxGetKeyState() for mouse buttons")); | |
178 | ||
179 | return false; // FIXME | |
180 | } | |
181 | ||
182 | //---------------------------------------------------------------------------- | |
183 | // misc. | |
184 | //---------------------------------------------------------------------------- | |
185 | ||
186 | void wxBell() | |
187 | { | |
188 | } | |
189 | ||
190 | int wxAddProcessCallback(wxEndProcessData *proc_data, int fd) | |
191 | { | |
192 | wxFAIL_MSG( _T("wxAddProcessCallback not implemented") ); | |
193 | return 0; | |
194 | } |