PageRenderTime 64ms CodeModel.GetById 48ms app.highlight 12ms RepoModel.GetById 1ms 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
  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
 27#ifndef LL_LLWINDOWWIN32_H
 28#define LL_LLWINDOWWIN32_H
 29
 30// Limit Windows API to small and manageable set.
 31#define WIN32_LEAN_AND_MEAN
 32#include <winsock2.h>
 33#include <windows.h>
 34
 35#include "llwindow.h"
 36#include "llwindowcallbacks.h"
 37#include "lldragdropwin32.h"
 38
 39// Hack for async host by name
 40#define LL_WM_HOST_RESOLVED      (WM_APP + 1)
 41typedef void (*LLW32MsgCallback)(const MSG &msg);
 42
 43class LLWindowWin32 : public LLWindow
 44{
 45public:
 46	/*virtual*/ void show();
 47	/*virtual*/ void hide();
 48	/*virtual*/ void close();
 49	/*virtual*/ BOOL getVisible();
 50	/*virtual*/ BOOL getMinimized();
 51	/*virtual*/ BOOL getMaximized();
 52	/*virtual*/ BOOL maximize();
 53	/*virtual*/ void minimize();
 54	/*virtual*/ void restore();
 55	/*virtual*/ BOOL getFullscreen();
 56	/*virtual*/ BOOL getPosition(LLCoordScreen *position);
 57	/*virtual*/ BOOL getSize(LLCoordScreen *size);
 58	/*virtual*/ BOOL getSize(LLCoordWindow *size);
 59	/*virtual*/ BOOL setPosition(LLCoordScreen position);
 60	/*virtual*/ BOOL setSizeImpl(LLCoordScreen size);
 61	/*virtual*/ BOOL switchContext(BOOL fullscreen, const LLCoordScreen &size, BOOL disable_vsync, const LLCoordScreen * const posp = NULL);
 62	/*virtual*/ BOOL setCursorPosition(LLCoordWindow position);
 63	/*virtual*/ BOOL getCursorPosition(LLCoordWindow *position);
 64	/*virtual*/ void showCursor();
 65	/*virtual*/ void hideCursor();
 66	/*virtual*/ void showCursorFromMouseMove();
 67	/*virtual*/ void hideCursorUntilMouseMove();
 68	/*virtual*/ BOOL isCursorHidden();
 69	/*virtual*/ void updateCursor();
 70	/*virtual*/ ECursorType getCursor() const;
 71	/*virtual*/ void captureMouse();
 72	/*virtual*/ void releaseMouse();
 73	/*virtual*/ void setMouseClipping( BOOL b );
 74	/*virtual*/ BOOL isClipboardTextAvailable();
 75	/*virtual*/ BOOL pasteTextFromClipboard(LLWString &dst);
 76	/*virtual*/ BOOL copyTextToClipboard(const LLWString &src);
 77	/*virtual*/ void flashIcon(F32 seconds);
 78	/*virtual*/ F32 getGamma();
 79	/*virtual*/ BOOL setGamma(const F32 gamma); // Set the gamma
 80	/*virtual*/ void setFSAASamples(const U32 fsaa_samples);
 81	/*virtual*/ U32 getFSAASamples();
 82	/*virtual*/ BOOL restoreGamma();			// Restore original gamma table (before updating gamma)
 83	/*virtual*/ ESwapMethod getSwapMethod() { return mSwapMethod; }
 84	/*virtual*/ void gatherInput();
 85	/*virtual*/ void delayInputProcessing();
 86	/*virtual*/ void swapBuffers();
 87
 88	// handy coordinate space conversion routines
 89	/*virtual*/ BOOL convertCoords(LLCoordScreen from, LLCoordWindow *to);
 90	/*virtual*/ BOOL convertCoords(LLCoordWindow from, LLCoordScreen *to);
 91	/*virtual*/ BOOL convertCoords(LLCoordWindow from, LLCoordGL *to);
 92	/*virtual*/ BOOL convertCoords(LLCoordGL from, LLCoordWindow *to);
 93	/*virtual*/ BOOL convertCoords(LLCoordScreen from, LLCoordGL *to);
 94	/*virtual*/ BOOL convertCoords(LLCoordGL from, LLCoordScreen *to);
 95
 96	/*virtual*/ LLWindowResolution* getSupportedResolutions(S32 &num_resolutions);
 97	/*virtual*/ F32	getNativeAspectRatio();
 98	/*virtual*/ F32 getPixelAspectRatio();
 99	/*virtual*/ void setNativeAspectRatio(F32 ratio) { mOverrideAspectRatio = ratio; }
100
101	/*virtual*/	BOOL dialogColorPicker(F32 *r, F32 *g, F32 *b );
102
103	/*virtual*/ void *getPlatformWindow();
104	/*virtual*/ void bringToFront();
105	/*virtual*/ void focusClient();
106
107	/*virtual*/ void allowLanguageTextInput(LLPreeditor *preeditor, BOOL b);
108	/*virtual*/ void setLanguageTextInput( const LLCoordGL & pos );
109	/*virtual*/ void updateLanguageTextInputArea();
110	/*virtual*/ void interruptLanguageTextInput();
111	/*virtual*/ void spawnWebBrowser(const std::string& escaped_url, bool async);
112
113	LLWindowCallbacks::DragNDropResult completeDragNDropRequest( const LLCoordGL gl_coord, const MASK mask, LLWindowCallbacks::DragNDropAction action, const std::string url );
114
115	static std::vector<std::string> getDynamicFallbackFontList();
116
117protected:
118	LLWindowWin32(LLWindowCallbacks* callbacks,
119		const std::string& title, const std::string& name, int x, int y, int width, int height, U32 flags, 
120		BOOL fullscreen, BOOL clearBg, BOOL disable_vsync, BOOL use_gl,
121		BOOL ignore_pixel_depth, U32 fsaa_samples);
122	~LLWindowWin32();
123
124	void	initCursors();
125	void	initInputDevices();
126	HCURSOR loadColorCursor(LPCTSTR name);
127	BOOL	isValid();
128	void	moveWindow(const LLCoordScreen& position,const LLCoordScreen& size);
129	LLSD	getNativeKeyData();
130
131	// Changes display resolution. Returns true if successful
132	BOOL	setDisplayResolution(S32 width, S32 height, S32 bits, S32 refresh);
133
134	// Go back to last fullscreen display resolution.
135	BOOL	setFullscreenResolution();
136
137	// Restore the display resolution to its value before we ran the app.
138	BOOL	resetDisplayResolution();
139
140	BOOL	shouldPostQuit() { return mPostQuit; }
141
142	void	fillCompositionForm(const LLRect& bounds, COMPOSITIONFORM *form);
143	void	fillCandidateForm(const LLCoordGL& caret, const LLRect& bounds, CANDIDATEFORM *form);
144	void	fillCharPosition(const LLCoordGL& caret, const LLRect& bounds, const LLRect& control, IMECHARPOSITION *char_position);
145	void	fillCompositionLogfont(LOGFONT *logfont);
146	U32		fillReconvertString(const LLWString &text, S32 focus, S32 focus_length, RECONVERTSTRING *reconvert_string);
147	void	handleStartCompositionMessage();
148	void	handleCompositionMessage(U32 indexes);
149	BOOL	handleImeRequests(U32 request, U32 param, LRESULT *result);
150
151protected:
152	//
153	// Platform specific methods
154	//
155
156	BOOL	getClientRectInScreenSpace(RECT* rectp);
157	void 	updateJoystick( );
158
159	static LRESULT CALLBACK mainWindowProc(HWND h_wnd, UINT u_msg, WPARAM w_param, LPARAM l_param);
160	static BOOL CALLBACK enumChildWindows(HWND h_wnd, LPARAM l_param);
161
162
163	//
164	// Platform specific variables
165	//
166	WCHAR		*mWindowTitle;
167	WCHAR		*mWindowClassName;
168
169	HWND		mWindowHandle;	// window handle
170	HGLRC		mhRC;			// OpenGL rendering context
171	HDC			mhDC;			// Windows Device context handle
172	HINSTANCE	mhInstance;		// handle to application instance
173	WNDPROC		mWndProc;		// user-installable window proc
174	RECT		mOldMouseClip;  // Screen rect to which the mouse cursor was globally constrained before we changed it in clipMouse()
175	WPARAM		mLastSizeWParam;
176	F32			mOverrideAspectRatio;
177	F32			mNativeAspectRatio;
178
179	HCURSOR		mCursor[ UI_CURSOR_COUNT ];  // Array of all mouse cursors
180
181	static BOOL sIsClassRegistered; // has the window class been registered?
182
183	F32			mCurrentGamma;
184	U32			mFSAASamples;
185	WORD		mPrevGammaRamp[256*3];
186	WORD		mCurrentGammaRamp[256*3];
187
188	LPWSTR		mIconResource;
189	BOOL		mMousePositionModified;
190	BOOL		mInputProcessingPaused;
191
192	// The following variables are for Language Text Input control.
193	// They are all static, since one context is shared by all LLWindowWin32
194	// instances.
195	static BOOL		sLanguageTextInputAllowed;
196	static BOOL		sWinIMEOpened;
197	static HKL		sWinInputLocale;
198	static DWORD	sWinIMEConversionMode;
199	static DWORD	sWinIMESentenceMode;
200	static LLCoordWindow sWinIMEWindowPosition;
201	LLCoordGL		mLanguageTextInputPointGL;
202	LLRect			mLanguageTextInputAreaGL;
203
204	LLPreeditor		*mPreeditor;
205
206	LLDragDropWin32* mDragDrop;
207
208	U32				mKeyCharCode;
209	U32				mKeyScanCode;
210	U32				mKeyVirtualKey;
211
212	friend class LLWindowManager;
213};
214
215class LLSplashScreenWin32 : public LLSplashScreen
216{
217public:
218	LLSplashScreenWin32();
219	virtual ~LLSplashScreenWin32();
220
221	/*virtual*/ void showImpl();
222	/*virtual*/ void updateImpl(const std::string& mesg);
223	/*virtual*/ void hideImpl();
224
225#if LL_WINDOWS
226	static LRESULT CALLBACK windowProc(HWND h_wnd, UINT u_msg, 
227		WPARAM w_param, LPARAM l_param);
228#endif
229
230private:
231#if LL_WINDOWS
232	HWND mWindow;
233#endif
234};
235
236extern LLW32MsgCallback gAsyncMsgCallback;
237extern LPWSTR gIconResource;
238
239static void	handleMessage( const MSG& msg );
240
241S32 OSMessageBoxWin32(const std::string& text, const std::string& caption, U32 type);
242
243#endif //LL_LLWINDOWWIN32_H