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