diff options
Diffstat (limited to '')
-rw-r--r-- | libraries/irrlicht-1.8/source/Irrlicht/CIrrDeviceWin32.h | 812 |
1 files changed, 406 insertions, 406 deletions
diff --git a/libraries/irrlicht-1.8/source/Irrlicht/CIrrDeviceWin32.h b/libraries/irrlicht-1.8/source/Irrlicht/CIrrDeviceWin32.h index 16c5d54..9442e30 100644 --- a/libraries/irrlicht-1.8/source/Irrlicht/CIrrDeviceWin32.h +++ b/libraries/irrlicht-1.8/source/Irrlicht/CIrrDeviceWin32.h | |||
@@ -1,406 +1,406 @@ | |||
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_WIN32_H_INCLUDED__ | 5 | #ifndef __C_IRR_DEVICE_WIN32_H_INCLUDED__ |
6 | #define __C_IRR_DEVICE_WIN32_H_INCLUDED__ | 6 | #define __C_IRR_DEVICE_WIN32_H_INCLUDED__ |
7 | 7 | ||
8 | #include "IrrCompileConfig.h" | 8 | #include "IrrCompileConfig.h" |
9 | #ifdef _IRR_COMPILE_WITH_WINDOWS_DEVICE_ | 9 | #ifdef _IRR_COMPILE_WITH_WINDOWS_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 | #define WIN32_LEAN_AND_MEAN | 15 | #define WIN32_LEAN_AND_MEAN |
16 | #if !defined(_IRR_XBOX_PLATFORM_) | 16 | #if !defined(_IRR_XBOX_PLATFORM_) |
17 | #include <windows.h> | 17 | #include <windows.h> |
18 | #include <mmsystem.h> // For JOYCAPS | 18 | #include <mmsystem.h> // For JOYCAPS |
19 | #include <windowsx.h> | 19 | #include <windowsx.h> |
20 | #endif | 20 | #endif |
21 | #if !defined(GET_X_LPARAM) | 21 | #if !defined(GET_X_LPARAM) |
22 | #define GET_X_LPARAM(lp) ((int)(short)LOWORD(lp)) | 22 | #define GET_X_LPARAM(lp) ((int)(short)LOWORD(lp)) |
23 | #define GET_Y_LPARAM(lp) ((int)(short)HIWORD(lp)) | 23 | #define GET_Y_LPARAM(lp) ((int)(short)HIWORD(lp)) |
24 | #endif | 24 | #endif |
25 | 25 | ||
26 | namespace irr | 26 | namespace irr |
27 | { | 27 | { |
28 | struct SJoystickWin32Control; | 28 | struct SJoystickWin32Control; |
29 | 29 | ||
30 | class CIrrDeviceWin32 : public CIrrDeviceStub, video::IImagePresenter | 30 | class CIrrDeviceWin32 : public CIrrDeviceStub, video::IImagePresenter |
31 | { | 31 | { |
32 | friend struct SJoystickWin32Control; | 32 | friend struct SJoystickWin32Control; |
33 | public: | 33 | public: |
34 | 34 | ||
35 | //! constructor | 35 | //! constructor |
36 | CIrrDeviceWin32(const SIrrlichtCreationParameters& params); | 36 | CIrrDeviceWin32(const SIrrlichtCreationParameters& params); |
37 | 37 | ||
38 | //! destructor | 38 | //! destructor |
39 | virtual ~CIrrDeviceWin32(); | 39 | virtual ~CIrrDeviceWin32(); |
40 | 40 | ||
41 | //! runs the device. Returns false if device wants to be deleted | 41 | //! runs the device. Returns false if device wants to be deleted |
42 | virtual bool run(); | 42 | virtual bool run(); |
43 | 43 | ||
44 | //! Cause the device to temporarily pause execution and let other processes to run | 44 | //! Cause the device to temporarily pause execution and let other processes to run |
45 | // This should bring down processor usage without major performance loss for Irrlicht | 45 | // This should bring down processor usage without major performance loss for Irrlicht |
46 | virtual void yield(); | 46 | virtual void yield(); |
47 | 47 | ||
48 | //! Pause execution and let other processes to run for a specified amount of time. | 48 | //! Pause execution and let other processes to run for a specified amount of time. |
49 | virtual void sleep(u32 timeMs, bool pauseTimer); | 49 | virtual void sleep(u32 timeMs, bool pauseTimer); |
50 | 50 | ||
51 | //! sets the caption of the window | 51 | //! sets the caption of the window |
52 | virtual void setWindowCaption(const wchar_t* text); | 52 | virtual void setWindowCaption(const wchar_t* text); |
53 | 53 | ||
54 | //! returns if window is active. if not, nothing need to be drawn | 54 | //! returns if window is active. if not, nothing need to be drawn |
55 | virtual bool isWindowActive() const; | 55 | virtual bool isWindowActive() const; |
56 | 56 | ||
57 | //! returns if window has focus | 57 | //! returns if window has focus |
58 | virtual bool isWindowFocused() const; | 58 | virtual bool isWindowFocused() const; |
59 | 59 | ||
60 | //! returns if window is minimized | 60 | //! returns if window is minimized |
61 | virtual bool isWindowMinimized() const; | 61 | virtual bool isWindowMinimized() const; |
62 | 62 | ||
63 | //! presents a surface in the client area | 63 | //! presents a surface in the client area |
64 | virtual bool present(video::IImage* surface, void* windowId=0, core::rect<s32>* src=0); | 64 | virtual bool present(video::IImage* surface, void* windowId=0, core::rect<s32>* src=0); |
65 | 65 | ||
66 | //! notifies the device that it should close itself | 66 | //! notifies the device that it should close itself |
67 | virtual void closeDevice(); | 67 | virtual void closeDevice(); |
68 | 68 | ||
69 | //! \return Returns a pointer to a list with all video modes | 69 | //! \return Returns a pointer to a list with all video modes |
70 | //! supported by the gfx adapter. | 70 | //! supported by the gfx adapter. |
71 | video::IVideoModeList* getVideoModeList(); | 71 | video::IVideoModeList* getVideoModeList(); |
72 | 72 | ||
73 | //! Notifies the device, that it has been resized | 73 | //! Notifies the device, that it has been resized |
74 | void OnResized(); | 74 | void OnResized(); |
75 | 75 | ||
76 | //! Sets if the window should be resizable in windowed mode. | 76 | //! Sets if the window should be resizable in windowed mode. |
77 | virtual void setResizable(bool resize=false); | 77 | virtual void setResizable(bool resize=false); |
78 | 78 | ||
79 | //! Minimizes the window. | 79 | //! Minimizes the window. |
80 | virtual void minimizeWindow(); | 80 | virtual void minimizeWindow(); |
81 | 81 | ||
82 | //! Maximizes the window. | 82 | //! Maximizes the window. |
83 | virtual void maximizeWindow(); | 83 | virtual void maximizeWindow(); |
84 | 84 | ||
85 | //! Restores the window size. | 85 | //! Restores the window size. |
86 | virtual void restoreWindow(); | 86 | virtual void restoreWindow(); |
87 | 87 | ||
88 | //! Activate any joysticks, and generate events for them. | 88 | //! Activate any joysticks, and generate events for them. |
89 | virtual bool activateJoysticks(core::array<SJoystickInfo> & joystickInfo); | 89 | virtual bool activateJoysticks(core::array<SJoystickInfo> & joystickInfo); |
90 | 90 | ||
91 | //! Set the current Gamma Value for the Display | 91 | //! Set the current Gamma Value for the Display |
92 | virtual bool setGammaRamp( f32 red, f32 green, f32 blue, f32 brightness, f32 contrast ); | 92 | virtual bool setGammaRamp( f32 red, f32 green, f32 blue, f32 brightness, f32 contrast ); |
93 | 93 | ||
94 | //! Get the current Gamma Value for the Display | 94 | //! Get the current Gamma Value for the Display |
95 | virtual bool getGammaRamp( f32 &red, f32 &green, f32 &blue, f32 &brightness, f32 &contrast ); | 95 | virtual bool getGammaRamp( f32 &red, f32 &green, f32 &blue, f32 &brightness, f32 &contrast ); |
96 | 96 | ||
97 | //! Remove all messages pending in the system message loop | 97 | //! Remove all messages pending in the system message loop |
98 | virtual void clearSystemMessages(); | 98 | virtual void clearSystemMessages(); |
99 | 99 | ||
100 | //! Get the device type | 100 | //! Get the device type |
101 | virtual E_DEVICE_TYPE getType() const | 101 | virtual E_DEVICE_TYPE getType() const |
102 | { | 102 | { |
103 | return EIDT_WIN32; | 103 | return EIDT_WIN32; |
104 | } | 104 | } |
105 | 105 | ||
106 | //! Compares to the last call of this function to return double and triple clicks. | 106 | //! Compares to the last call of this function to return double and triple clicks. |
107 | //! \return Returns only 1,2 or 3. A 4th click will start with 1 again. | 107 | //! \return Returns only 1,2 or 3. A 4th click will start with 1 again. |
108 | virtual u32 checkSuccessiveClicks(s32 mouseX, s32 mouseY, EMOUSE_INPUT_EVENT inputEvent ) | 108 | virtual u32 checkSuccessiveClicks(s32 mouseX, s32 mouseY, EMOUSE_INPUT_EVENT inputEvent ) |
109 | { | 109 | { |
110 | // we just have to make it public | 110 | // we just have to make it public |
111 | return CIrrDeviceStub::checkSuccessiveClicks(mouseX, mouseY, inputEvent ); | 111 | return CIrrDeviceStub::checkSuccessiveClicks(mouseX, mouseY, inputEvent ); |
112 | } | 112 | } |
113 | 113 | ||
114 | //! switchs to fullscreen | 114 | //! switchs to fullscreen |
115 | bool switchToFullScreen(bool reset=false); | 115 | bool switchToFullScreen(bool reset=false); |
116 | 116 | ||
117 | //! Check for and show last Windows API error to help internal debugging. | 117 | //! Check for and show last Windows API error to help internal debugging. |
118 | //! Does call GetLastError and on errors formats the errortext and displays it in a messagebox. | 118 | //! Does call GetLastError and on errors formats the errortext and displays it in a messagebox. |
119 | static void ReportLastWinApiError(); | 119 | static void ReportLastWinApiError(); |
120 | 120 | ||
121 | // convert an Irrlicht texture to a windows cursor | 121 | // convert an Irrlicht texture to a windows cursor |
122 | HCURSOR TextureToCursor(HWND hwnd, irr::video::ITexture * tex, const core::rect<s32>& sourceRect, const core::position2d<s32> &hotspot); | 122 | HCURSOR TextureToCursor(HWND hwnd, irr::video::ITexture * tex, const core::rect<s32>& sourceRect, const core::position2d<s32> &hotspot); |
123 | 123 | ||
124 | //! Implementation of the win32 cursor control | 124 | //! Implementation of the win32 cursor control |
125 | class CCursorControl : public gui::ICursorControl | 125 | class CCursorControl : public gui::ICursorControl |
126 | { | 126 | { |
127 | public: | 127 | public: |
128 | 128 | ||
129 | CCursorControl(CIrrDeviceWin32* device, const core::dimension2d<u32>& wsize, HWND hwnd, bool fullscreen); | 129 | CCursorControl(CIrrDeviceWin32* device, const core::dimension2d<u32>& wsize, HWND hwnd, bool fullscreen); |
130 | ~CCursorControl(); | 130 | ~CCursorControl(); |
131 | 131 | ||
132 | //! Changes the visible state of the mouse cursor. | 132 | //! Changes the visible state of the mouse cursor. |
133 | virtual void setVisible(bool visible) | 133 | virtual void setVisible(bool visible) |
134 | { | 134 | { |
135 | CURSORINFO info; | 135 | CURSORINFO info; |
136 | info.cbSize = sizeof(CURSORINFO); | 136 | info.cbSize = sizeof(CURSORINFO); |
137 | BOOL gotCursorInfo = GetCursorInfo(&info); | 137 | BOOL gotCursorInfo = GetCursorInfo(&info); |
138 | while ( gotCursorInfo ) | 138 | while ( gotCursorInfo ) |
139 | { | 139 | { |
140 | if ( (visible && info.flags == CURSOR_SHOWING) // visible | 140 | if ( (visible && info.flags == CURSOR_SHOWING) // visible |
141 | || (!visible && info.flags == 0 ) ) // hidden | 141 | || (!visible && info.flags == 0 ) ) // hidden |
142 | { | 142 | { |
143 | break; | 143 | break; |
144 | } | 144 | } |
145 | int showResult = ShowCursor(visible); // this only increases an internal display counter in windows, so it might have to be called some more | 145 | int showResult = ShowCursor(visible); // this only increases an internal display counter in windows, so it might have to be called some more |
146 | if ( showResult < 0 ) | 146 | if ( showResult < 0 ) |
147 | { | 147 | { |
148 | break; | 148 | break; |
149 | } | 149 | } |
150 | info.cbSize = sizeof(CURSORINFO); // yes, it really must be set each time | 150 | info.cbSize = sizeof(CURSORINFO); // yes, it really must be set each time |
151 | gotCursorInfo = GetCursorInfo(&info); | 151 | gotCursorInfo = GetCursorInfo(&info); |
152 | } | 152 | } |
153 | IsVisible = visible; | 153 | IsVisible = visible; |
154 | } | 154 | } |
155 | 155 | ||
156 | //! Returns if the cursor is currently visible. | 156 | //! Returns if the cursor is currently visible. |
157 | virtual bool isVisible() const | 157 | virtual bool isVisible() const |
158 | { | 158 | { |
159 | _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX; | 159 | _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX; |
160 | return IsVisible; | 160 | return IsVisible; |
161 | } | 161 | } |
162 | 162 | ||
163 | //! Sets the new position of the cursor. | 163 | //! Sets the new position of the cursor. |
164 | virtual void setPosition(const core::position2d<f32> &pos) | 164 | virtual void setPosition(const core::position2d<f32> &pos) |
165 | { | 165 | { |
166 | setPosition(pos.X, pos.Y); | 166 | setPosition(pos.X, pos.Y); |
167 | } | 167 | } |
168 | 168 | ||
169 | //! Sets the new position of the cursor. | 169 | //! Sets the new position of the cursor. |
170 | virtual void setPosition(f32 x, f32 y) | 170 | virtual void setPosition(f32 x, f32 y) |
171 | { | 171 | { |
172 | if (!UseReferenceRect) | 172 | if (!UseReferenceRect) |
173 | setPosition(core::round32(x*WindowSize.Width), core::round32(y*WindowSize.Height)); | 173 | setPosition(core::round32(x*WindowSize.Width), core::round32(y*WindowSize.Height)); |
174 | else | 174 | else |
175 | setPosition(core::round32(x*ReferenceRect.getWidth()), core::round32(y*ReferenceRect.getHeight())); | 175 | setPosition(core::round32(x*ReferenceRect.getWidth()), core::round32(y*ReferenceRect.getHeight())); |
176 | } | 176 | } |
177 | 177 | ||
178 | //! Sets the new position of the cursor. | 178 | //! Sets the new position of the cursor. |
179 | virtual void setPosition(const core::position2d<s32> &pos) | 179 | virtual void setPosition(const core::position2d<s32> &pos) |
180 | { | 180 | { |
181 | setPosition(pos.X, pos.Y); | 181 | setPosition(pos.X, pos.Y); |
182 | } | 182 | } |
183 | 183 | ||
184 | //! Sets the new position of the cursor. | 184 | //! Sets the new position of the cursor. |
185 | virtual void setPosition(s32 x, s32 y) | 185 | virtual void setPosition(s32 x, s32 y) |
186 | { | 186 | { |
187 | if (UseReferenceRect) | 187 | if (UseReferenceRect) |
188 | { | 188 | { |
189 | SetCursorPos(ReferenceRect.UpperLeftCorner.X + x, | 189 | SetCursorPos(ReferenceRect.UpperLeftCorner.X + x, |
190 | ReferenceRect.UpperLeftCorner.Y + y); | 190 | ReferenceRect.UpperLeftCorner.Y + y); |
191 | } | 191 | } |
192 | else | 192 | else |
193 | { | 193 | { |
194 | RECT rect; | 194 | RECT rect; |
195 | if (GetWindowRect(HWnd, &rect)) | 195 | if (GetWindowRect(HWnd, &rect)) |
196 | SetCursorPos(x + rect.left + BorderX, y + rect.top + BorderY); | 196 | SetCursorPos(x + rect.left + BorderX, y + rect.top + BorderY); |
197 | } | 197 | } |
198 | 198 | ||
199 | CursorPos.X = x; | 199 | CursorPos.X = x; |
200 | CursorPos.Y = y; | 200 | CursorPos.Y = y; |
201 | } | 201 | } |
202 | 202 | ||
203 | //! Returns the current position of the mouse cursor. | 203 | //! Returns the current position of the mouse cursor. |
204 | virtual const core::position2d<s32>& getPosition() | 204 | virtual const core::position2d<s32>& getPosition() |
205 | { | 205 | { |
206 | updateInternalCursorPosition(); | 206 | updateInternalCursorPosition(); |
207 | return CursorPos; | 207 | return CursorPos; |
208 | } | 208 | } |
209 | 209 | ||
210 | //! Returns the current position of the mouse cursor. | 210 | //! Returns the current position of the mouse cursor. |
211 | virtual core::position2d<f32> getRelativePosition() | 211 | virtual core::position2d<f32> getRelativePosition() |
212 | { | 212 | { |
213 | updateInternalCursorPosition(); | 213 | updateInternalCursorPosition(); |
214 | 214 | ||
215 | if (!UseReferenceRect) | 215 | if (!UseReferenceRect) |
216 | { | 216 | { |
217 | return core::position2d<f32>(CursorPos.X * InvWindowSize.Width, | 217 | return core::position2d<f32>(CursorPos.X * InvWindowSize.Width, |
218 | CursorPos.Y * InvWindowSize.Height); | 218 | CursorPos.Y * InvWindowSize.Height); |
219 | } | 219 | } |
220 | 220 | ||
221 | return core::position2d<f32>(CursorPos.X / (f32)ReferenceRect.getWidth(), | 221 | return core::position2d<f32>(CursorPos.X / (f32)ReferenceRect.getWidth(), |
222 | CursorPos.Y / (f32)ReferenceRect.getHeight()); | 222 | CursorPos.Y / (f32)ReferenceRect.getHeight()); |
223 | } | 223 | } |
224 | 224 | ||
225 | //! Sets an absolute reference rect for calculating the cursor position. | 225 | //! Sets an absolute reference rect for calculating the cursor position. |
226 | virtual void setReferenceRect(core::rect<s32>* rect=0) | 226 | virtual void setReferenceRect(core::rect<s32>* rect=0) |
227 | { | 227 | { |
228 | if (rect) | 228 | if (rect) |
229 | { | 229 | { |
230 | ReferenceRect = *rect; | 230 | ReferenceRect = *rect; |
231 | UseReferenceRect = true; | 231 | UseReferenceRect = true; |
232 | 232 | ||
233 | // prevent division through zero and uneven sizes | 233 | // prevent division through zero and uneven sizes |
234 | 234 | ||
235 | if (!ReferenceRect.getHeight() || ReferenceRect.getHeight()%2) | 235 | if (!ReferenceRect.getHeight() || ReferenceRect.getHeight()%2) |
236 | ReferenceRect.LowerRightCorner.Y += 1; | 236 | ReferenceRect.LowerRightCorner.Y += 1; |
237 | 237 | ||
238 | if (!ReferenceRect.getWidth() || ReferenceRect.getWidth()%2) | 238 | if (!ReferenceRect.getWidth() || ReferenceRect.getWidth()%2) |
239 | ReferenceRect.LowerRightCorner.X += 1; | 239 | ReferenceRect.LowerRightCorner.X += 1; |
240 | } | 240 | } |
241 | else | 241 | else |
242 | UseReferenceRect = false; | 242 | UseReferenceRect = false; |
243 | } | 243 | } |
244 | 244 | ||
245 | /** Used to notify the cursor that the window was resized. */ | 245 | /** Used to notify the cursor that the window was resized. */ |
246 | virtual void OnResize(const core::dimension2d<u32>& size) | 246 | virtual void OnResize(const core::dimension2d<u32>& size) |
247 | { | 247 | { |
248 | WindowSize = size; | 248 | WindowSize = size; |
249 | if (size.Width!=0) | 249 | if (size.Width!=0) |
250 | InvWindowSize.Width = 1.0f / size.Width; | 250 | InvWindowSize.Width = 1.0f / size.Width; |
251 | else | 251 | else |
252 | InvWindowSize.Width = 0.f; | 252 | InvWindowSize.Width = 0.f; |
253 | 253 | ||
254 | if (size.Height!=0) | 254 | if (size.Height!=0) |
255 | InvWindowSize.Height = 1.0f / size.Height; | 255 | InvWindowSize.Height = 1.0f / size.Height; |
256 | else | 256 | else |
257 | InvWindowSize.Height = 0.f; | 257 | InvWindowSize.Height = 0.f; |
258 | } | 258 | } |
259 | 259 | ||
260 | /** Used to notify the cursor that the window resizable settings changed. */ | 260 | /** Used to notify the cursor that the window resizable settings changed. */ |
261 | void updateBorderSize(bool fullscreen, bool resizable) | 261 | void updateBorderSize(bool fullscreen, bool resizable) |
262 | { | 262 | { |
263 | if (!fullscreen) | 263 | if (!fullscreen) |
264 | { | 264 | { |
265 | if (resizable) | 265 | if (resizable) |
266 | { | 266 | { |
267 | BorderX = GetSystemMetrics(SM_CXSIZEFRAME); | 267 | BorderX = GetSystemMetrics(SM_CXSIZEFRAME); |
268 | BorderY = GetSystemMetrics(SM_CYCAPTION) + GetSystemMetrics(SM_CYSIZEFRAME); | 268 | BorderY = GetSystemMetrics(SM_CYCAPTION) + GetSystemMetrics(SM_CYSIZEFRAME); |
269 | } | 269 | } |
270 | else | 270 | else |
271 | { | 271 | { |
272 | BorderX = GetSystemMetrics(SM_CXDLGFRAME); | 272 | BorderX = GetSystemMetrics(SM_CXDLGFRAME); |
273 | BorderY = GetSystemMetrics(SM_CYCAPTION) + GetSystemMetrics(SM_CYDLGFRAME); | 273 | BorderY = GetSystemMetrics(SM_CYCAPTION) + GetSystemMetrics(SM_CYDLGFRAME); |
274 | } | 274 | } |
275 | } | 275 | } |
276 | else | 276 | else |
277 | { | 277 | { |
278 | BorderX = BorderY = 0; | 278 | BorderX = BorderY = 0; |
279 | } | 279 | } |
280 | } | 280 | } |
281 | 281 | ||
282 | 282 | ||
283 | //! Sets the active cursor icon | 283 | //! Sets the active cursor icon |
284 | virtual void setActiveIcon(gui::ECURSOR_ICON iconId); | 284 | virtual void setActiveIcon(gui::ECURSOR_ICON iconId); |
285 | 285 | ||
286 | //! Gets the currently active icon | 286 | //! Gets the currently active icon |
287 | virtual gui::ECURSOR_ICON getActiveIcon() const | 287 | virtual gui::ECURSOR_ICON getActiveIcon() const |
288 | { | 288 | { |
289 | return ActiveIcon; | 289 | return ActiveIcon; |
290 | } | 290 | } |
291 | 291 | ||
292 | //! Add a custom sprite as cursor icon. | 292 | //! Add a custom sprite as cursor icon. |
293 | virtual gui::ECURSOR_ICON addIcon(const gui::SCursorSprite& icon); | 293 | virtual gui::ECURSOR_ICON addIcon(const gui::SCursorSprite& icon); |
294 | 294 | ||
295 | //! replace the given cursor icon. | 295 | //! replace the given cursor icon. |
296 | virtual void changeIcon(gui::ECURSOR_ICON iconId, const gui::SCursorSprite& icon); | 296 | virtual void changeIcon(gui::ECURSOR_ICON iconId, const gui::SCursorSprite& icon); |
297 | 297 | ||
298 | //! Return a system-specific size which is supported for cursors. Larger icons will fail, smaller icons might work. | 298 | //! Return a system-specific size which is supported for cursors. Larger icons will fail, smaller icons might work. |
299 | virtual core::dimension2di getSupportedIconSize() const; | 299 | virtual core::dimension2di getSupportedIconSize() const; |
300 | 300 | ||
301 | void update(); | 301 | void update(); |
302 | 302 | ||
303 | private: | 303 | private: |
304 | 304 | ||
305 | //! Updates the internal cursor position | 305 | //! Updates the internal cursor position |
306 | void updateInternalCursorPosition() | 306 | void updateInternalCursorPosition() |
307 | { | 307 | { |
308 | POINT p; | 308 | POINT p; |
309 | if (!GetCursorPos(&p)) | 309 | if (!GetCursorPos(&p)) |
310 | { | 310 | { |
311 | DWORD xy = GetMessagePos(); | 311 | DWORD xy = GetMessagePos(); |
312 | p.x = GET_X_LPARAM(xy); | 312 | p.x = GET_X_LPARAM(xy); |
313 | p.y = GET_Y_LPARAM(xy); | 313 | p.y = GET_Y_LPARAM(xy); |
314 | } | 314 | } |
315 | 315 | ||
316 | if (UseReferenceRect) | 316 | if (UseReferenceRect) |
317 | { | 317 | { |
318 | CursorPos.X = p.x - ReferenceRect.UpperLeftCorner.X; | 318 | CursorPos.X = p.x - ReferenceRect.UpperLeftCorner.X; |
319 | CursorPos.Y = p.y - ReferenceRect.UpperLeftCorner.Y; | 319 | CursorPos.Y = p.y - ReferenceRect.UpperLeftCorner.Y; |
320 | } | 320 | } |
321 | else | 321 | else |
322 | { | 322 | { |
323 | RECT rect; | 323 | RECT rect; |
324 | if (GetWindowRect(HWnd, &rect)) | 324 | if (GetWindowRect(HWnd, &rect)) |
325 | { | 325 | { |
326 | CursorPos.X = p.x-rect.left-BorderX; | 326 | CursorPos.X = p.x-rect.left-BorderX; |
327 | CursorPos.Y = p.y-rect.top-BorderY; | 327 | CursorPos.Y = p.y-rect.top-BorderY; |
328 | } | 328 | } |
329 | else | 329 | else |
330 | { | 330 | { |
331 | // window seems not to be existent, so set cursor to | 331 | // window seems not to be existent, so set cursor to |
332 | // a negative value | 332 | // a negative value |
333 | CursorPos.X = -1; | 333 | CursorPos.X = -1; |
334 | CursorPos.Y = -1; | 334 | CursorPos.Y = -1; |
335 | } | 335 | } |
336 | } | 336 | } |
337 | } | 337 | } |
338 | 338 | ||
339 | CIrrDeviceWin32* Device; | 339 | CIrrDeviceWin32* Device; |
340 | core::position2d<s32> CursorPos; | 340 | core::position2d<s32> CursorPos; |
341 | core::dimension2d<u32> WindowSize; | 341 | core::dimension2d<u32> WindowSize; |
342 | core::dimension2d<f32> InvWindowSize; | 342 | core::dimension2d<f32> InvWindowSize; |
343 | HWND HWnd; | 343 | HWND HWnd; |
344 | 344 | ||
345 | s32 BorderX, BorderY; | 345 | s32 BorderX, BorderY; |
346 | core::rect<s32> ReferenceRect; | 346 | core::rect<s32> ReferenceRect; |
347 | bool UseReferenceRect; | 347 | bool UseReferenceRect; |
348 | bool IsVisible; | 348 | bool IsVisible; |
349 | 349 | ||
350 | 350 | ||
351 | struct CursorFrameW32 | 351 | struct CursorFrameW32 |
352 | { | 352 | { |
353 | CursorFrameW32() : IconHW(0) {} | 353 | CursorFrameW32() : IconHW(0) {} |
354 | CursorFrameW32(HCURSOR icon) : IconHW(icon) {} | 354 | CursorFrameW32(HCURSOR icon) : IconHW(icon) {} |
355 | 355 | ||
356 | HCURSOR IconHW; // hardware cursor | 356 | HCURSOR IconHW; // hardware cursor |
357 | }; | 357 | }; |
358 | 358 | ||
359 | struct CursorW32 | 359 | struct CursorW32 |
360 | { | 360 | { |
361 | CursorW32() {} | 361 | CursorW32() {} |
362 | explicit CursorW32(HCURSOR iconHw, u32 frameTime=0) : FrameTime(frameTime) | 362 | explicit CursorW32(HCURSOR iconHw, u32 frameTime=0) : FrameTime(frameTime) |
363 | { | 363 | { |
364 | Frames.push_back( CursorFrameW32(iconHw) ); | 364 | Frames.push_back( CursorFrameW32(iconHw) ); |
365 | } | 365 | } |
366 | core::array<CursorFrameW32> Frames; | 366 | core::array<CursorFrameW32> Frames; |
367 | u32 FrameTime; | 367 | u32 FrameTime; |
368 | }; | 368 | }; |
369 | 369 | ||
370 | core::array<CursorW32> Cursors; | 370 | core::array<CursorW32> Cursors; |
371 | gui::ECURSOR_ICON ActiveIcon; | 371 | gui::ECURSOR_ICON ActiveIcon; |
372 | u32 ActiveIconStartTime; | 372 | u32 ActiveIconStartTime; |
373 | 373 | ||
374 | void initCursors(); | 374 | void initCursors(); |
375 | }; | 375 | }; |
376 | 376 | ||
377 | //! returns the win32 cursor control | 377 | //! returns the win32 cursor control |
378 | CCursorControl* getWin32CursorControl(); | 378 | CCursorControl* getWin32CursorControl(); |
379 | 379 | ||
380 | private: | 380 | private: |
381 | 381 | ||
382 | //! create the driver | 382 | //! create the driver |
383 | void createDriver(); | 383 | void createDriver(); |
384 | 384 | ||
385 | //! Process system events | 385 | //! Process system events |
386 | void handleSystemMessages(); | 386 | void handleSystemMessages(); |
387 | 387 | ||
388 | void getWindowsVersion(core::stringc& version); | 388 | void getWindowsVersion(core::stringc& version); |
389 | 389 | ||
390 | void resizeIfNecessary(); | 390 | void resizeIfNecessary(); |
391 | 391 | ||
392 | HWND HWnd; | 392 | HWND HWnd; |
393 | 393 | ||
394 | bool ChangedToFullScreen; | 394 | bool ChangedToFullScreen; |
395 | bool Resized; | 395 | bool Resized; |
396 | bool ExternalWindow; | 396 | bool ExternalWindow; |
397 | CCursorControl* Win32CursorControl; | 397 | CCursorControl* Win32CursorControl; |
398 | DEVMODE DesktopMode; | 398 | DEVMODE DesktopMode; |
399 | 399 | ||
400 | SJoystickWin32Control* JoyControl; | 400 | SJoystickWin32Control* JoyControl; |
401 | }; | 401 | }; |
402 | 402 | ||
403 | } // end namespace irr | 403 | } // end namespace irr |
404 | 404 | ||
405 | #endif // _IRR_COMPILE_WITH_WINDOWS_DEVICE_ | 405 | #endif // _IRR_COMPILE_WITH_WINDOWS_DEVICE_ |
406 | #endif // __C_IRR_DEVICE_WIN32_H_INCLUDED__ | 406 | #endif // __C_IRR_DEVICE_WIN32_H_INCLUDED__ |