PageRenderTime 175ms CodeModel.GetById 0ms RepoModel.GetById 0ms app.codeStats 0ms

/indra/llwindow/llwindowwin32.h

https://bitbucket.org/lindenlab/viewer-beta/
C Header | 243 lines | 161 code | 42 blank | 40 comment | 0 complexity | 8b9db1c7874eaf5b6c710ee313617ba8 MD5 | raw file
Possible License(s): LGPL-2.1
  1. /**
  2. * @file llwindowwin32.h
  3. * @brief Windows implementation of LLWindow class
  4. *
  5. * $LicenseInfo:firstyear=2001&license=viewerlgpl$
  6. * Second Life Viewer Source Code
  7. * Copyright (C) 2010, Linden Research, Inc.
  8. *
  9. * This library is free software; you can redistribute it and/or
  10. * modify it under the terms of the GNU Lesser General Public
  11. * License as published by the Free Software Foundation;
  12. * version 2.1 of the License only.
  13. *
  14. * This library is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  17. * Lesser General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU Lesser General Public
  20. * License along with this library; if not, write to the Free Software
  21. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  22. *
  23. * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
  24. * $/LicenseInfo$
  25. */
  26. #ifndef LL_LLWINDOWWIN32_H
  27. #define LL_LLWINDOWWIN32_H
  28. // Limit Windows API to small and manageable set.
  29. #define WIN32_LEAN_AND_MEAN
  30. #include <winsock2.h>
  31. #include <windows.h>
  32. #include "llwindow.h"
  33. #include "llwindowcallbacks.h"
  34. #include "lldragdropwin32.h"
  35. // Hack for async host by name
  36. #define LL_WM_HOST_RESOLVED (WM_APP + 1)
  37. typedef void (*LLW32MsgCallback)(const MSG &msg);
  38. class LLWindowWin32 : public LLWindow
  39. {
  40. public:
  41. /*virtual*/ void show();
  42. /*virtual*/ void hide();
  43. /*virtual*/ void close();
  44. /*virtual*/ BOOL getVisible();
  45. /*virtual*/ BOOL getMinimized();
  46. /*virtual*/ BOOL getMaximized();
  47. /*virtual*/ BOOL maximize();
  48. /*virtual*/ void minimize();
  49. /*virtual*/ void restore();
  50. /*virtual*/ BOOL getFullscreen();
  51. /*virtual*/ BOOL getPosition(LLCoordScreen *position);
  52. /*virtual*/ BOOL getSize(LLCoordScreen *size);
  53. /*virtual*/ BOOL getSize(LLCoordWindow *size);
  54. /*virtual*/ BOOL setPosition(LLCoordScreen position);
  55. /*virtual*/ BOOL setSizeImpl(LLCoordScreen size);
  56. /*virtual*/ BOOL switchContext(BOOL fullscreen, const LLCoordScreen &size, BOOL disable_vsync, const LLCoordScreen * const posp = NULL);
  57. /*virtual*/ BOOL setCursorPosition(LLCoordWindow position);
  58. /*virtual*/ BOOL getCursorPosition(LLCoordWindow *position);
  59. /*virtual*/ void showCursor();
  60. /*virtual*/ void hideCursor();
  61. /*virtual*/ void showCursorFromMouseMove();
  62. /*virtual*/ void hideCursorUntilMouseMove();
  63. /*virtual*/ BOOL isCursorHidden();
  64. /*virtual*/ void updateCursor();
  65. /*virtual*/ ECursorType getCursor() const;
  66. /*virtual*/ void captureMouse();
  67. /*virtual*/ void releaseMouse();
  68. /*virtual*/ void setMouseClipping( BOOL b );
  69. /*virtual*/ BOOL isClipboardTextAvailable();
  70. /*virtual*/ BOOL pasteTextFromClipboard(LLWString &dst);
  71. /*virtual*/ BOOL copyTextToClipboard(const LLWString &src);
  72. /*virtual*/ void flashIcon(F32 seconds);
  73. /*virtual*/ F32 getGamma();
  74. /*virtual*/ BOOL setGamma(const F32 gamma); // Set the gamma
  75. /*virtual*/ void setFSAASamples(const U32 fsaa_samples);
  76. /*virtual*/ U32 getFSAASamples();
  77. /*virtual*/ BOOL restoreGamma(); // Restore original gamma table (before updating gamma)
  78. /*virtual*/ ESwapMethod getSwapMethod() { return mSwapMethod; }
  79. /*virtual*/ void gatherInput();
  80. /*virtual*/ void delayInputProcessing();
  81. /*virtual*/ void swapBuffers();
  82. // handy coordinate space conversion routines
  83. /*virtual*/ BOOL convertCoords(LLCoordScreen from, LLCoordWindow *to);
  84. /*virtual*/ BOOL convertCoords(LLCoordWindow from, LLCoordScreen *to);
  85. /*virtual*/ BOOL convertCoords(LLCoordWindow from, LLCoordGL *to);
  86. /*virtual*/ BOOL convertCoords(LLCoordGL from, LLCoordWindow *to);
  87. /*virtual*/ BOOL convertCoords(LLCoordScreen from, LLCoordGL *to);
  88. /*virtual*/ BOOL convertCoords(LLCoordGL from, LLCoordScreen *to);
  89. /*virtual*/ LLWindowResolution* getSupportedResolutions(S32 &num_resolutions);
  90. /*virtual*/ F32 getNativeAspectRatio();
  91. /*virtual*/ F32 getPixelAspectRatio();
  92. /*virtual*/ void setNativeAspectRatio(F32 ratio) { mOverrideAspectRatio = ratio; }
  93. /*virtual*/ BOOL dialogColorPicker(F32 *r, F32 *g, F32 *b );
  94. /*virtual*/ void *getPlatformWindow();
  95. /*virtual*/ void bringToFront();
  96. /*virtual*/ void focusClient();
  97. /*virtual*/ void allowLanguageTextInput(LLPreeditor *preeditor, BOOL b);
  98. /*virtual*/ void setLanguageTextInput( const LLCoordGL & pos );
  99. /*virtual*/ void updateLanguageTextInputArea();
  100. /*virtual*/ void interruptLanguageTextInput();
  101. /*virtual*/ void spawnWebBrowser(const std::string& escaped_url, bool async);
  102. LLWindowCallbacks::DragNDropResult completeDragNDropRequest( const LLCoordGL gl_coord, const MASK mask, LLWindowCallbacks::DragNDropAction action, const std::string url );
  103. static std::vector<std::string> getDynamicFallbackFontList();
  104. protected:
  105. LLWindowWin32(LLWindowCallbacks* callbacks,
  106. const std::string& title, const std::string& name, int x, int y, int width, int height, U32 flags,
  107. BOOL fullscreen, BOOL clearBg, BOOL disable_vsync, BOOL use_gl,
  108. BOOL ignore_pixel_depth, U32 fsaa_samples);
  109. ~LLWindowWin32();
  110. void initCursors();
  111. void initInputDevices();
  112. HCURSOR loadColorCursor(LPCTSTR name);
  113. BOOL isValid();
  114. void moveWindow(const LLCoordScreen& position,const LLCoordScreen& size);
  115. LLSD getNativeKeyData();
  116. // Changes display resolution. Returns true if successful
  117. BOOL setDisplayResolution(S32 width, S32 height, S32 bits, S32 refresh);
  118. // Go back to last fullscreen display resolution.
  119. BOOL setFullscreenResolution();
  120. // Restore the display resolution to its value before we ran the app.
  121. BOOL resetDisplayResolution();
  122. BOOL shouldPostQuit() { return mPostQuit; }
  123. void fillCompositionForm(const LLRect& bounds, COMPOSITIONFORM *form);
  124. void fillCandidateForm(const LLCoordGL& caret, const LLRect& bounds, CANDIDATEFORM *form);
  125. void fillCharPosition(const LLCoordGL& caret, const LLRect& bounds, const LLRect& control, IMECHARPOSITION *char_position);
  126. void fillCompositionLogfont(LOGFONT *logfont);
  127. U32 fillReconvertString(const LLWString &text, S32 focus, S32 focus_length, RECONVERTSTRING *reconvert_string);
  128. void handleStartCompositionMessage();
  129. void handleCompositionMessage(U32 indexes);
  130. BOOL handleImeRequests(U32 request, U32 param, LRESULT *result);
  131. protected:
  132. //
  133. // Platform specific methods
  134. //
  135. BOOL getClientRectInScreenSpace(RECT* rectp);
  136. void updateJoystick( );
  137. static LRESULT CALLBACK mainWindowProc(HWND h_wnd, UINT u_msg, WPARAM w_param, LPARAM l_param);
  138. static BOOL CALLBACK enumChildWindows(HWND h_wnd, LPARAM l_param);
  139. //
  140. // Platform specific variables
  141. //
  142. WCHAR *mWindowTitle;
  143. WCHAR *mWindowClassName;
  144. HWND mWindowHandle; // window handle
  145. HGLRC mhRC; // OpenGL rendering context
  146. HDC mhDC; // Windows Device context handle
  147. HINSTANCE mhInstance; // handle to application instance
  148. WNDPROC mWndProc; // user-installable window proc
  149. RECT mOldMouseClip; // Screen rect to which the mouse cursor was globally constrained before we changed it in clipMouse()
  150. WPARAM mLastSizeWParam;
  151. F32 mOverrideAspectRatio;
  152. F32 mNativeAspectRatio;
  153. HCURSOR mCursor[ UI_CURSOR_COUNT ]; // Array of all mouse cursors
  154. static BOOL sIsClassRegistered; // has the window class been registered?
  155. F32 mCurrentGamma;
  156. U32 mFSAASamples;
  157. WORD mPrevGammaRamp[256*3];
  158. WORD mCurrentGammaRamp[256*3];
  159. LPWSTR mIconResource;
  160. BOOL mMousePositionModified;
  161. BOOL mInputProcessingPaused;
  162. // The following variables are for Language Text Input control.
  163. // They are all static, since one context is shared by all LLWindowWin32
  164. // instances.
  165. static BOOL sLanguageTextInputAllowed;
  166. static BOOL sWinIMEOpened;
  167. static HKL sWinInputLocale;
  168. static DWORD sWinIMEConversionMode;
  169. static DWORD sWinIMESentenceMode;
  170. static LLCoordWindow sWinIMEWindowPosition;
  171. LLCoordGL mLanguageTextInputPointGL;
  172. LLRect mLanguageTextInputAreaGL;
  173. LLPreeditor *mPreeditor;
  174. LLDragDropWin32* mDragDrop;
  175. U32 mKeyCharCode;
  176. U32 mKeyScanCode;
  177. U32 mKeyVirtualKey;
  178. friend class LLWindowManager;
  179. };
  180. class LLSplashScreenWin32 : public LLSplashScreen
  181. {
  182. public:
  183. LLSplashScreenWin32();
  184. virtual ~LLSplashScreenWin32();
  185. /*virtual*/ void showImpl();
  186. /*virtual*/ void updateImpl(const std::string& mesg);
  187. /*virtual*/ void hideImpl();
  188. #if LL_WINDOWS
  189. static LRESULT CALLBACK windowProc(HWND h_wnd, UINT u_msg,
  190. WPARAM w_param, LPARAM l_param);
  191. #endif
  192. private:
  193. #if LL_WINDOWS
  194. HWND mWindow;
  195. #endif
  196. };
  197. extern LLW32MsgCallback gAsyncMsgCallback;
  198. extern LPWSTR gIconResource;
  199. static void handleMessage( const MSG& msg );
  200. S32 OSMessageBoxWin32(const std::string& text, const std::string& caption, U32 type);
  201. #endif //LL_LLWINDOWWIN32_H