Blender V2.61 - r43446
|
00001 /* 00002 * ***** BEGIN GPL LICENSE BLOCK ***** 00003 * 00004 * This program is free software; you can redistribute it and/or 00005 * modify it under the terms of the GNU General Public License 00006 * as published by the Free Software Foundation; either version 2 00007 * of the License, or (at your option) any later version. 00008 * 00009 * This program is distributed in the hope that it will be useful, 00010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 * GNU General Public License for more details. 00013 * 00014 * You should have received a copy of the GNU General Public License 00015 * along with this program; if not, write to the Free Software Foundation, 00016 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 00017 * 00018 * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. 00019 * All rights reserved. 00020 * 00021 * The Original Code is: all of this file. 00022 * 00023 * Contributor(s): none yet. 00024 * 00025 * ***** END GPL LICENSE BLOCK ***** 00026 */ 00027 00033 #ifndef _GHOST_SYSTEM_WIN32_H_ 00034 #define _GHOST_SYSTEM_WIN32_H_ 00035 00036 #ifndef WIN32 00037 #error WIN32 only! 00038 #endif // WIN32 00039 00040 #define _WIN32_WINNT 0x501 // require Windows XP or newer 00041 #define WIN32_LEAN_AND_MEAN 00042 #include <windows.h> 00043 #include <ole2.h> // for drag-n-drop 00044 00045 #include "GHOST_System.h" 00046 00047 #if defined(__CYGWIN32__) 00048 # define __int64 long long 00049 #endif 00050 00051 class GHOST_EventButton; 00052 class GHOST_EventCursor; 00053 class GHOST_EventKey; 00054 class GHOST_EventWheel; 00055 class GHOST_EventWindow; 00056 class GHOST_EventDragnDrop; 00057 00064 class GHOST_SystemWin32 : public GHOST_System { 00065 public: 00069 GHOST_SystemWin32(); 00070 00074 virtual ~GHOST_SystemWin32(); 00075 00076 /*************************************************************************************** 00077 ** Time(r) functionality 00078 ***************************************************************************************/ 00079 00086 virtual GHOST_TUns64 getMilliSeconds() const; 00087 00088 /*************************************************************************************** 00089 ** Display/window management functionality 00090 ***************************************************************************************/ 00091 00096 virtual GHOST_TUns8 getNumDisplays() const; 00097 00102 virtual void getMainDisplayDimensions(GHOST_TUns32& width, GHOST_TUns32& height) const; 00103 00120 virtual GHOST_IWindow* createWindow( 00121 const STR_String& title, 00122 GHOST_TInt32 left, GHOST_TInt32 top, GHOST_TUns32 width, GHOST_TUns32 height, 00123 GHOST_TWindowState state, GHOST_TDrawingContextType type, 00124 const bool stereoVisual = false, 00125 const GHOST_TUns16 numOfAASamples = 0, 00126 const GHOST_TEmbedderWindowID parentWindow = 0 ); 00127 00128 /*************************************************************************************** 00129 ** Event management functionality 00130 ***************************************************************************************/ 00131 00137 virtual bool processEvents(bool waitForEvent); 00138 00139 00140 /*************************************************************************************** 00141 ** Cursor management functionality 00142 ***************************************************************************************/ 00143 00150 virtual GHOST_TSuccess getCursorPosition(GHOST_TInt32& x, GHOST_TInt32& y) const; 00151 00158 virtual GHOST_TSuccess setCursorPosition(GHOST_TInt32 x, GHOST_TInt32 y); 00159 00160 /*************************************************************************************** 00161 ** Access to mouse button and keyboard states. 00162 ***************************************************************************************/ 00163 00169 virtual GHOST_TSuccess getModifierKeys(GHOST_ModifierKeys& keys) const; 00170 00176 virtual GHOST_TSuccess getButtons(GHOST_Buttons& buttons) const; 00177 00183 virtual GHOST_TUns8* getClipboard(bool selection) const; 00184 00190 virtual void putClipboard(GHOST_TInt8 *buffer, bool selection) const; 00191 00202 static GHOST_TSuccess pushDragDropEvent(GHOST_TEventType eventType, GHOST_TDragnDropTypes draggedObjectType,GHOST_IWindow* window, int mouseX, int mouseY, void* data); 00203 00204 protected: 00210 virtual GHOST_TSuccess init(); 00211 00216 virtual GHOST_TSuccess exit(); 00217 00226 virtual GHOST_TKey convertKey(GHOST_IWindow *window, short vKey, short ScanCode, short extend) const; 00227 00236 virtual GHOST_TKey hardKey(GHOST_IWindow *window, RAWINPUT const& raw, int * keyDown, char * vk); 00237 00245 GHOST_EventKey* processModifierKeys(GHOST_IWindow *window); 00246 00254 static GHOST_EventButton* processButtonEvent(GHOST_TEventType type, GHOST_IWindow *window, GHOST_TButtonMask mask); 00255 00262 static GHOST_EventCursor* processCursorEvent(GHOST_TEventType type, GHOST_IWindow *Iwindow); 00263 00270 static GHOST_EventWheel* processWheelEvent(GHOST_IWindow *window, WPARAM wParam, LPARAM lParam); 00271 00279 static GHOST_EventKey* processKeyEvent(GHOST_IWindow *window, RAWINPUT const& raw); 00280 00288 virtual GHOST_TKey processSpecialKey(GHOST_IWindow *window, short vKey, short scanCode) const; 00289 00296 static GHOST_Event* processWindowEvent(GHOST_TEventType type, GHOST_IWindow* window); 00297 00302 static void processMinMaxInfo(MINMAXINFO * minmax); 00303 00304 #ifdef WITH_INPUT_NDOF 00305 00312 bool processNDOF(RAWINPUT const& raw); 00313 #endif 00314 00319 inline virtual void retrieveModifierKeys(GHOST_ModifierKeys& keys) const; 00320 00326 inline virtual void storeModifierKeys(const GHOST_ModifierKeys& keys); 00327 00331 inline virtual void handleKeyboardChange(void); 00332 00336 static LRESULT WINAPI s_wndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam); 00337 00347 int toggleConsole(int action); 00348 00350 GHOST_ModifierKeys m_modifierKeys; 00352 bool m_hasPerformanceCounter; 00354 __int64 m_freq; 00356 __int64 m_start; 00358 bool m_hasAltGr; 00360 WORD m_langId; 00362 HKL m_keylayout; 00363 00365 int m_consoleStatus; 00366 }; 00367 00368 inline void GHOST_SystemWin32::retrieveModifierKeys(GHOST_ModifierKeys& keys) const 00369 { 00370 keys = m_modifierKeys; 00371 } 00372 00373 inline void GHOST_SystemWin32::storeModifierKeys(const GHOST_ModifierKeys& keys) 00374 { 00375 m_modifierKeys = keys; 00376 } 00377 00378 inline void GHOST_SystemWin32::handleKeyboardChange(void) 00379 { 00380 m_keylayout = GetKeyboardLayout(0); // get keylayout for current thread 00381 int i; 00382 SHORT s; 00383 00384 // save the language identifier. 00385 m_langId = LOWORD(m_keylayout); 00386 00387 for(m_hasAltGr = false, i = 32; i < 256; ++i) { 00388 s = VkKeyScanEx((char)i, m_keylayout); 00389 // s == -1 means no key that translates passed char code 00390 // high byte contains shift state. bit 2 ctrl pressed, bit 4 alt pressed 00391 // if both are pressed, we have AltGr keycombo on keylayout 00392 if(s!=-1 && (s & 0x600) == 0x600) { 00393 m_hasAltGr = true; 00394 break; 00395 } 00396 } 00397 } 00398 #endif // _GHOST_SYSTEM_WIN32_H_