diff options
Diffstat (limited to 'libraries/irrlicht-1.8/source/Irrlicht/CIrrDeviceWinCE.h')
-rw-r--r-- | libraries/irrlicht-1.8/source/Irrlicht/CIrrDeviceWinCE.h | 592 |
1 files changed, 296 insertions, 296 deletions
diff --git a/libraries/irrlicht-1.8/source/Irrlicht/CIrrDeviceWinCE.h b/libraries/irrlicht-1.8/source/Irrlicht/CIrrDeviceWinCE.h index 7fe1063..8688c0a 100644 --- a/libraries/irrlicht-1.8/source/Irrlicht/CIrrDeviceWinCE.h +++ b/libraries/irrlicht-1.8/source/Irrlicht/CIrrDeviceWinCE.h | |||
@@ -1,296 +1,296 @@ | |||
1 | // Copyright (C) 2002-2012 Nikolaus Gebhardt | 1 | // Copyright (C) 2002-2012 Nikolaus Gebhardt |
2 | // This file is part of the "Irrlicht Engine". | 2 | // This file is part of the "Irrlicht Engine". |
3 | // For conditions of distribution and use, see copyright notice in irrlicht.h | 3 | // For conditions of distribution and use, see copyright notice in irrlicht.h |
4 | 4 | ||
5 | #ifndef __C_IRR_DEVICE_WINCE_H_INCLUDED__ | 5 | #ifndef __C_IRR_DEVICE_WINCE_H_INCLUDED__ |
6 | #define __C_IRR_DEVICE_WINCE_H_INCLUDED__ | 6 | #define __C_IRR_DEVICE_WINCE_H_INCLUDED__ |
7 | 7 | ||
8 | #include "IrrCompileConfig.h" | 8 | #include "IrrCompileConfig.h" |
9 | #ifdef _IRR_COMPILE_WITH_WINDOWS_CE_DEVICE_ | 9 | #ifdef _IRR_COMPILE_WITH_WINDOWS_CE_DEVICE_ |
10 | 10 | ||
11 | #include "CIrrDeviceStub.h" | 11 | #include "CIrrDeviceStub.h" |
12 | #include "IrrlichtDevice.h" | 12 | #include "IrrlichtDevice.h" |
13 | #include "IImagePresenter.h" | 13 | #include "IImagePresenter.h" |
14 | 14 | ||
15 | #include <windows.h> | 15 | #include <windows.h> |
16 | #include <windowsx.h> | 16 | #include <windowsx.h> |
17 | #include <commctrl.h> | 17 | #include <commctrl.h> |
18 | #include <aygshell.h> | 18 | #include <aygshell.h> |
19 | #include <sipapi.h> | 19 | #include <sipapi.h> |
20 | #include <gx.h> | 20 | #include <gx.h> |
21 | 21 | ||
22 | namespace irr | 22 | namespace irr |
23 | { | 23 | { |
24 | class CIrrDeviceWinCE : public CIrrDeviceStub, video::IImagePresenter | 24 | class CIrrDeviceWinCE : public CIrrDeviceStub, video::IImagePresenter |
25 | { | 25 | { |
26 | public: | 26 | public: |
27 | 27 | ||
28 | //! constructor | 28 | //! constructor |
29 | CIrrDeviceWinCE( const SIrrlichtCreationParameters& params); | 29 | CIrrDeviceWinCE( const SIrrlichtCreationParameters& params); |
30 | 30 | ||
31 | //! destructor | 31 | //! destructor |
32 | virtual ~CIrrDeviceWinCE(); | 32 | virtual ~CIrrDeviceWinCE(); |
33 | 33 | ||
34 | //! runs the device. Returns false if device wants to be deleted | 34 | //! runs the device. Returns false if device wants to be deleted |
35 | virtual bool run(); | 35 | virtual bool run(); |
36 | 36 | ||
37 | //! Cause the device to temporarily pause execution and let other processes to run | 37 | //! Cause the device to temporarily pause execution and let other processes to run |
38 | // This should bring down processor usage without major performance loss for Irrlicht | 38 | // This should bring down processor usage without major performance loss for Irrlicht |
39 | virtual void yield(); | 39 | virtual void yield(); |
40 | 40 | ||
41 | //! Pause execution and let other processes to run for a specified amount of time. | 41 | //! Pause execution and let other processes to run for a specified amount of time. |
42 | virtual void sleep(u32 timeMs, bool pauseTimer); | 42 | virtual void sleep(u32 timeMs, bool pauseTimer); |
43 | 43 | ||
44 | //! sets the caption of the window | 44 | //! sets the caption of the window |
45 | virtual void setWindowCaption(const wchar_t* text); | 45 | virtual void setWindowCaption(const wchar_t* text); |
46 | 46 | ||
47 | //! returns if window is active. if not, nothing need to be drawn | 47 | //! returns if window is active. if not, nothing need to be drawn |
48 | virtual bool isWindowActive() const; | 48 | virtual bool isWindowActive() const; |
49 | 49 | ||
50 | //! returns if window has focus | 50 | //! returns if window has focus |
51 | virtual bool isWindowFocused() const; | 51 | virtual bool isWindowFocused() const; |
52 | 52 | ||
53 | //! returns if window is minimized | 53 | //! returns if window is minimized |
54 | virtual bool isWindowMinimized() const; | 54 | virtual bool isWindowMinimized() const; |
55 | 55 | ||
56 | //! presents a surface in the client area | 56 | //! presents a surface in the client area |
57 | virtual bool present(video::IImage* surface, void* windowId = 0, core::rect<s32>* src=0 ); | 57 | virtual bool present(video::IImage* surface, void* windowId = 0, core::rect<s32>* src=0 ); |
58 | 58 | ||
59 | //! notifies the device that it should close itself | 59 | //! notifies the device that it should close itself |
60 | virtual void closeDevice(); | 60 | virtual void closeDevice(); |
61 | 61 | ||
62 | //! \return Returns a pointer to a list with all video modes | 62 | //! \return Returns a pointer to a list with all video modes |
63 | //! supported by the gfx adapter. | 63 | //! supported by the gfx adapter. |
64 | video::IVideoModeList* getVideoModeList(); | 64 | video::IVideoModeList* getVideoModeList(); |
65 | 65 | ||
66 | //! Notifies the device, that it has been resized | 66 | //! Notifies the device, that it has been resized |
67 | void OnResized(); | 67 | void OnResized(); |
68 | 68 | ||
69 | //! Sets if the window should be resizable in windowed mode. | 69 | //! Sets if the window should be resizable in windowed mode. |
70 | virtual void setResizable(bool resize=false); | 70 | virtual void setResizable(bool resize=false); |
71 | 71 | ||
72 | //! Minimizes the window. | 72 | //! Minimizes the window. |
73 | virtual void minimizeWindow(); | 73 | virtual void minimizeWindow(); |
74 | 74 | ||
75 | //! Maximizes the window. | 75 | //! Maximizes the window. |
76 | virtual void maximizeWindow(); | 76 | virtual void maximizeWindow(); |
77 | 77 | ||
78 | //! Restores the window size. | 78 | //! Restores the window size. |
79 | virtual void restoreWindow(); | 79 | virtual void restoreWindow(); |
80 | 80 | ||
81 | //! Get the device type | 81 | //! Get the device type |
82 | virtual E_DEVICE_TYPE getType() const | 82 | virtual E_DEVICE_TYPE getType() const |
83 | { | 83 | { |
84 | return EIDT_WINCE; | 84 | return EIDT_WINCE; |
85 | } | 85 | } |
86 | 86 | ||
87 | //! Implementation of the win32 cursor control | 87 | //! Implementation of the win32 cursor control |
88 | class CCursorControl : public gui::ICursorControl | 88 | class CCursorControl : public gui::ICursorControl |
89 | { | 89 | { |
90 | public: | 90 | public: |
91 | 91 | ||
92 | CCursorControl(const core::dimension2d<u32>& wsize, HWND hwnd, bool fullscreen) | 92 | CCursorControl(const core::dimension2d<u32>& wsize, HWND hwnd, bool fullscreen) |
93 | : WindowSize(wsize), InvWindowSize(0.0f, 0.0f), | 93 | : WindowSize(wsize), InvWindowSize(0.0f, 0.0f), |
94 | HWnd(hwnd), BorderX(0), BorderY(0), | 94 | HWnd(hwnd), BorderX(0), BorderY(0), |
95 | UseReferenceRect(false), IsVisible(true) | 95 | UseReferenceRect(false), IsVisible(true) |
96 | { | 96 | { |
97 | if (WindowSize.Width!=0) | 97 | if (WindowSize.Width!=0) |
98 | InvWindowSize.Width = 1.0f / WindowSize.Width; | 98 | InvWindowSize.Width = 1.0f / WindowSize.Width; |
99 | 99 | ||
100 | if (WindowSize.Height!=0) | 100 | if (WindowSize.Height!=0) |
101 | InvWindowSize.Height = 1.0f / WindowSize.Height; | 101 | InvWindowSize.Height = 1.0f / WindowSize.Height; |
102 | 102 | ||
103 | if (!fullscreen) | 103 | if (!fullscreen) |
104 | { | 104 | { |
105 | BorderX = GetSystemMetrics(SM_CXDLGFRAME); | 105 | BorderX = GetSystemMetrics(SM_CXDLGFRAME); |
106 | BorderY = GetSystemMetrics(SM_CYCAPTION) + GetSystemMetrics(SM_CYDLGFRAME); | 106 | BorderY = GetSystemMetrics(SM_CYCAPTION) + GetSystemMetrics(SM_CYDLGFRAME); |
107 | } | 107 | } |
108 | } | 108 | } |
109 | 109 | ||
110 | //! Changes the visible state of the mouse cursor. | 110 | //! Changes the visible state of the mouse cursor. |
111 | virtual void setVisible(bool visible) | 111 | virtual void setVisible(bool visible) |
112 | { | 112 | { |
113 | IsVisible = visible; | 113 | IsVisible = visible; |
114 | } | 114 | } |
115 | 115 | ||
116 | //! Returns if the cursor is currently visible. | 116 | //! Returns if the cursor is currently visible. |
117 | virtual bool isVisible() const | 117 | virtual bool isVisible() const |
118 | { | 118 | { |
119 | _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX; | 119 | _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX; |
120 | return IsVisible; | 120 | return IsVisible; |
121 | } | 121 | } |
122 | 122 | ||
123 | //! Sets the new position of the cursor. | 123 | //! Sets the new position of the cursor. |
124 | virtual void setPosition(const core::position2d<f32> &pos) | 124 | virtual void setPosition(const core::position2d<f32> &pos) |
125 | { | 125 | { |
126 | setPosition(pos.X, pos.Y); | 126 | setPosition(pos.X, pos.Y); |
127 | } | 127 | } |
128 | 128 | ||
129 | //! Sets the new position of the cursor. | 129 | //! Sets the new position of the cursor. |
130 | virtual void setPosition(f32 x, f32 y) | 130 | virtual void setPosition(f32 x, f32 y) |
131 | { | 131 | { |
132 | if (!UseReferenceRect) | 132 | if (!UseReferenceRect) |
133 | setPosition(core::round32(x*WindowSize.Width), core::round32(y*WindowSize.Height)); | 133 | setPosition(core::round32(x*WindowSize.Width), core::round32(y*WindowSize.Height)); |
134 | else | 134 | else |
135 | setPosition(core::round32(x*ReferenceRect.getWidth()), core::round32(y*ReferenceRect.getHeight())); | 135 | setPosition(core::round32(x*ReferenceRect.getWidth()), core::round32(y*ReferenceRect.getHeight())); |
136 | } | 136 | } |
137 | 137 | ||
138 | //! Sets the new position of the cursor. | 138 | //! Sets the new position of the cursor. |
139 | virtual void setPosition(const core::position2d<s32> &pos) | 139 | virtual void setPosition(const core::position2d<s32> &pos) |
140 | { | 140 | { |
141 | setPosition(pos.X, pos.Y); | 141 | setPosition(pos.X, pos.Y); |
142 | } | 142 | } |
143 | 143 | ||
144 | //! Sets the new position of the cursor. | 144 | //! Sets the new position of the cursor. |
145 | virtual void setPosition(s32 x, s32 y) | 145 | virtual void setPosition(s32 x, s32 y) |
146 | { | 146 | { |
147 | RECT rect; | 147 | RECT rect; |
148 | 148 | ||
149 | if (UseReferenceRect) | 149 | if (UseReferenceRect) |
150 | { | 150 | { |
151 | SetCursorPos(ReferenceRect.UpperLeftCorner.X + x, | 151 | SetCursorPos(ReferenceRect.UpperLeftCorner.X + x, |
152 | ReferenceRect.UpperLeftCorner.Y + y); | 152 | ReferenceRect.UpperLeftCorner.Y + y); |
153 | } | 153 | } |
154 | else | 154 | else |
155 | { | 155 | { |
156 | if (GetWindowRect(HWnd, &rect)) | 156 | if (GetWindowRect(HWnd, &rect)) |
157 | SetCursorPos(x + rect.left + BorderX, y + rect.top + BorderY); | 157 | SetCursorPos(x + rect.left + BorderX, y + rect.top + BorderY); |
158 | } | 158 | } |
159 | 159 | ||
160 | CursorPos.X = x; | 160 | CursorPos.X = x; |
161 | CursorPos.Y = y; | 161 | CursorPos.Y = y; |
162 | } | 162 | } |
163 | 163 | ||
164 | //! Returns the current position of the mouse cursor. | 164 | //! Returns the current position of the mouse cursor. |
165 | virtual const core::position2d<s32>& getPosition() | 165 | virtual const core::position2d<s32>& getPosition() |
166 | { | 166 | { |
167 | updateInternalCursorPosition(); | 167 | updateInternalCursorPosition(); |
168 | return CursorPos; | 168 | return CursorPos; |
169 | } | 169 | } |
170 | 170 | ||
171 | //! Returns the current position of the mouse cursor. | 171 | //! Returns the current position of the mouse cursor. |
172 | virtual core::position2d<f32> getRelativePosition() | 172 | virtual core::position2d<f32> getRelativePosition() |
173 | { | 173 | { |
174 | updateInternalCursorPosition(); | 174 | updateInternalCursorPosition(); |
175 | 175 | ||
176 | if (!UseReferenceRect) | 176 | if (!UseReferenceRect) |
177 | { | 177 | { |
178 | return core::position2d<f32>(CursorPos.X * InvWindowSize.Width, | 178 | return core::position2d<f32>(CursorPos.X * InvWindowSize.Width, |
179 | CursorPos.Y * InvWindowSize.Height); | 179 | CursorPos.Y * InvWindowSize.Height); |
180 | } | 180 | } |
181 | 181 | ||
182 | return core::position2d<f32>(CursorPos.X / (f32)ReferenceRect.getWidth(), | 182 | return core::position2d<f32>(CursorPos.X / (f32)ReferenceRect.getWidth(), |
183 | CursorPos.Y / (f32)ReferenceRect.getHeight()); | 183 | CursorPos.Y / (f32)ReferenceRect.getHeight()); |
184 | } | 184 | } |
185 | 185 | ||
186 | //! Sets an absolute reference rect for calculating the cursor position. | 186 | //! Sets an absolute reference rect for calculating the cursor position. |
187 | virtual void setReferenceRect(core::rect<s32>* rect=0) | 187 | virtual void setReferenceRect(core::rect<s32>* rect=0) |
188 | { | 188 | { |
189 | if (rect) | 189 | if (rect) |
190 | { | 190 | { |
191 | ReferenceRect = *rect; | 191 | ReferenceRect = *rect; |
192 | UseReferenceRect = true; | 192 | UseReferenceRect = true; |
193 | 193 | ||
194 | // prevent division through zero and uneven sizes | 194 | // prevent division through zero and uneven sizes |
195 | 195 | ||
196 | if (!ReferenceRect.getHeight() || ReferenceRect.getHeight()%2) | 196 | if (!ReferenceRect.getHeight() || ReferenceRect.getHeight()%2) |
197 | ReferenceRect.LowerRightCorner.Y += 1; | 197 | ReferenceRect.LowerRightCorner.Y += 1; |
198 | 198 | ||
199 | if (!ReferenceRect.getWidth() || ReferenceRect.getWidth()%2) | 199 | if (!ReferenceRect.getWidth() || ReferenceRect.getWidth()%2) |
200 | ReferenceRect.LowerRightCorner.X += 1; | 200 | ReferenceRect.LowerRightCorner.X += 1; |
201 | } | 201 | } |
202 | else | 202 | else |
203 | UseReferenceRect = false; | 203 | UseReferenceRect = false; |
204 | } | 204 | } |
205 | 205 | ||
206 | /** Used to notify the cursor that the window was resized. */ | 206 | /** Used to notify the cursor that the window was resized. */ |
207 | virtual void OnResize(const core::dimension2d<u32>& size) | 207 | virtual void OnResize(const core::dimension2d<u32>& size) |
208 | { | 208 | { |
209 | WindowSize = size; | 209 | WindowSize = size; |
210 | if (size.Width!=0) | 210 | if (size.Width!=0) |
211 | InvWindowSize.Width = 1.0f / size.Width; | 211 | InvWindowSize.Width = 1.0f / size.Width; |
212 | else | 212 | else |
213 | InvWindowSize.Width = 0.f; | 213 | InvWindowSize.Width = 0.f; |
214 | 214 | ||
215 | if (size.Height!=0) | 215 | if (size.Height!=0) |
216 | InvWindowSize.Height = 1.0f / size.Height; | 216 | InvWindowSize.Height = 1.0f / size.Height; |
217 | else | 217 | else |
218 | InvWindowSize.Height = 0.f; | 218 | InvWindowSize.Height = 0.f; |
219 | } | 219 | } |
220 | 220 | ||
221 | private: | 221 | private: |
222 | 222 | ||
223 | //! Updates the internal cursor position | 223 | //! Updates the internal cursor position |
224 | void updateInternalCursorPosition() | 224 | void updateInternalCursorPosition() |
225 | { | 225 | { |
226 | POINT p; | 226 | POINT p; |
227 | if (!GetCursorPos(&p)) | 227 | if (!GetCursorPos(&p)) |
228 | { | 228 | { |
229 | DWORD xy = GetMessagePos(); | 229 | DWORD xy = GetMessagePos(); |
230 | p.x = GET_X_LPARAM(xy); | 230 | p.x = GET_X_LPARAM(xy); |
231 | p.y = GET_Y_LPARAM(xy); | 231 | p.y = GET_Y_LPARAM(xy); |
232 | } | 232 | } |
233 | 233 | ||
234 | if (UseReferenceRect) | 234 | if (UseReferenceRect) |
235 | { | 235 | { |
236 | CursorPos.X = p.x - ReferenceRect.UpperLeftCorner.X; | 236 | CursorPos.X = p.x - ReferenceRect.UpperLeftCorner.X; |
237 | CursorPos.Y = p.y - ReferenceRect.UpperLeftCorner.Y; | 237 | CursorPos.Y = p.y - ReferenceRect.UpperLeftCorner.Y; |
238 | } | 238 | } |
239 | else | 239 | else |
240 | { | 240 | { |
241 | RECT rect; | 241 | RECT rect; |
242 | if (GetWindowRect(HWnd, &rect)) | 242 | if (GetWindowRect(HWnd, &rect)) |
243 | { | 243 | { |
244 | CursorPos.X = p.x-rect.left-BorderX; | 244 | CursorPos.X = p.x-rect.left-BorderX; |
245 | CursorPos.Y = p.y-rect.top-BorderY; | 245 | CursorPos.Y = p.y-rect.top-BorderY; |
246 | } | 246 | } |
247 | else | 247 | else |
248 | { | 248 | { |
249 | // window seems not to be existent, so set cursor to | 249 | // window seems not to be existent, so set cursor to |
250 | // a negative value | 250 | // a negative value |
251 | CursorPos.X = -1; | 251 | CursorPos.X = -1; |
252 | CursorPos.Y = -1; | 252 | CursorPos.Y = -1; |
253 | } | 253 | } |
254 | } | 254 | } |
255 | } | 255 | } |
256 | 256 | ||
257 | core::position2d<s32> CursorPos; | 257 | core::position2d<s32> CursorPos; |
258 | core::dimension2d<s32> WindowSize; | 258 | core::dimension2d<s32> WindowSize; |
259 | core::dimension2d<f32> InvWindowSize; | 259 | core::dimension2d<f32> InvWindowSize; |
260 | HWND HWnd; | 260 | HWND HWnd; |
261 | 261 | ||
262 | s32 BorderX, BorderY; | 262 | s32 BorderX, BorderY; |
263 | core::rect<s32> ReferenceRect; | 263 | core::rect<s32> ReferenceRect; |
264 | bool UseReferenceRect; | 264 | bool UseReferenceRect; |
265 | bool IsVisible; | 265 | bool IsVisible; |
266 | }; | 266 | }; |
267 | 267 | ||
268 | 268 | ||
269 | //! returns the win32 cursor control | 269 | //! returns the win32 cursor control |
270 | CCursorControl* getWin32CursorControl(); | 270 | CCursorControl* getWin32CursorControl(); |
271 | 271 | ||
272 | private: | 272 | private: |
273 | 273 | ||
274 | //! create the driver | 274 | //! create the driver |
275 | void createDriver(); | 275 | void createDriver(); |
276 | 276 | ||
277 | //! switchs to fullscreen | 277 | //! switchs to fullscreen |
278 | bool switchToFullScreen(); | 278 | bool switchToFullScreen(); |
279 | 279 | ||
280 | void getWindowsVersion(core::stringc& version); | 280 | void getWindowsVersion(core::stringc& version); |
281 | 281 | ||
282 | void resizeIfNecessary(); | 282 | void resizeIfNecessary(); |
283 | 283 | ||
284 | HWND HWnd; | 284 | HWND HWnd; |
285 | CCursorControl* Win32CursorControl; | 285 | CCursorControl* Win32CursorControl; |
286 | 286 | ||
287 | bool ChangedToFullScreen; | 287 | bool ChangedToFullScreen; |
288 | bool Resized; | 288 | bool Resized; |
289 | bool ExternalWindow; | 289 | bool ExternalWindow; |
290 | }; | 290 | }; |
291 | 291 | ||
292 | 292 | ||
293 | } // end namespace irr | 293 | } // end namespace irr |
294 | 294 | ||
295 | #endif // _IRR_COMPILE_WITH_WINDOWS_CE_DEVICE_ | 295 | #endif // _IRR_COMPILE_WITH_WINDOWS_CE_DEVICE_ |
296 | #endif // __C_IRR_DEVICE_WINCE_H_INCLUDED__ | 296 | #endif // __C_IRR_DEVICE_WINCE_H_INCLUDED__ |