diff options
author | Jacek Antonelli | 2008-08-15 23:44:46 -0500 |
---|---|---|
committer | Jacek Antonelli | 2008-08-15 23:44:46 -0500 |
commit | 38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4 (patch) | |
tree | adca584755d22ca041a2dbfc35d4eca01f70b32c /linden/indra/llwindow/llwindow.h | |
parent | README.txt (diff) | |
download | meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.zip meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.tar.gz meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.tar.bz2 meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.tar.xz |
Second Life viewer sources 1.13.2.12
Diffstat (limited to 'linden/indra/llwindow/llwindow.h')
-rw-r--r-- | linden/indra/llwindow/llwindow.h | 334 |
1 files changed, 334 insertions, 0 deletions
diff --git a/linden/indra/llwindow/llwindow.h b/linden/indra/llwindow/llwindow.h new file mode 100644 index 0000000..ac427f1 --- /dev/null +++ b/linden/indra/llwindow/llwindow.h | |||
@@ -0,0 +1,334 @@ | |||
1 | /** | ||
2 | * @file llwindow.h | ||
3 | * @brief Basic graphical window class | ||
4 | * | ||
5 | * Copyright (c) 2001-2007, Linden Research, Inc. | ||
6 | * | ||
7 | * The source code in this file ("Source Code") is provided by Linden Lab | ||
8 | * to you under the terms of the GNU General Public License, version 2.0 | ||
9 | * ("GPL"), unless you have obtained a separate licensing agreement | ||
10 | * ("Other License"), formally executed by you and Linden Lab. Terms of | ||
11 | * the GPL can be found in doc/GPL-license.txt in this distribution, or | ||
12 | * online at http://secondlife.com/developers/opensource/gplv2 | ||
13 | * | ||
14 | * There are special exceptions to the terms and conditions of the GPL as | ||
15 | * it is applied to this Source Code. View the full text of the exception | ||
16 | * in the file doc/FLOSS-exception.txt in this software distribution, or | ||
17 | * online at http://secondlife.com/developers/opensource/flossexception | ||
18 | * | ||
19 | * By copying, modifying or distributing this software, you acknowledge | ||
20 | * that you have read and understood your obligations described above, | ||
21 | * and agree to abide by those obligations. | ||
22 | * | ||
23 | * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO | ||
24 | * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, | ||
25 | * COMPLETENESS OR PERFORMANCE. | ||
26 | */ | ||
27 | |||
28 | #ifndef LL_LLWINDOW_H | ||
29 | #define LL_LLWINDOW_H | ||
30 | |||
31 | #include <sys/stat.h> | ||
32 | |||
33 | #include "llrect.h" | ||
34 | #include "llcoord.h" | ||
35 | #include "llstring.h" | ||
36 | |||
37 | |||
38 | enum ECursorType { | ||
39 | UI_CURSOR_ARROW, | ||
40 | UI_CURSOR_WAIT, | ||
41 | UI_CURSOR_HAND, | ||
42 | UI_CURSOR_IBEAM, | ||
43 | UI_CURSOR_CROSS, | ||
44 | UI_CURSOR_SIZENWSE, | ||
45 | UI_CURSOR_SIZENESW, | ||
46 | UI_CURSOR_SIZEWE, | ||
47 | UI_CURSOR_SIZENS, | ||
48 | UI_CURSOR_NO, | ||
49 | UI_CURSOR_WORKING, | ||
50 | UI_CURSOR_TOOLGRAB, | ||
51 | UI_CURSOR_TOOLLAND, | ||
52 | UI_CURSOR_TOOLFOCUS, | ||
53 | UI_CURSOR_TOOLCREATE, | ||
54 | UI_CURSOR_ARROWDRAG, | ||
55 | UI_CURSOR_ARROWCOPY, // drag with copy | ||
56 | UI_CURSOR_ARROWDRAGMULTI, | ||
57 | UI_CURSOR_ARROWCOPYMULTI, // drag with copy | ||
58 | UI_CURSOR_NOLOCKED, | ||
59 | UI_CURSOR_ARROWLOCKED, | ||
60 | UI_CURSOR_GRABLOCKED, | ||
61 | UI_CURSOR_TOOLTRANSLATE, | ||
62 | UI_CURSOR_TOOLROTATE, | ||
63 | UI_CURSOR_TOOLSCALE, | ||
64 | UI_CURSOR_TOOLCAMERA, | ||
65 | UI_CURSOR_TOOLPAN, | ||
66 | UI_CURSOR_TOOLZOOMIN, | ||
67 | UI_CURSOR_TOOLPICKOBJECT3, | ||
68 | UI_CURSOR_TOOLSIT, | ||
69 | UI_CURSOR_TOOLBUY, | ||
70 | UI_CURSOR_TOOLPAY, | ||
71 | UI_CURSOR_TOOLOPEN, | ||
72 | UI_CURSOR_PIPETTE, | ||
73 | UI_CURSOR_COUNT // Number of elements in this enum (NOT a cursor) | ||
74 | }; | ||
75 | |||
76 | class LLSplashScreen; | ||
77 | |||
78 | class LLWindow; | ||
79 | |||
80 | class LLWindowCallbacks | ||
81 | { | ||
82 | public: | ||
83 | virtual ~LLWindowCallbacks() {} | ||
84 | virtual BOOL handleTranslatedKeyDown(KEY key, MASK mask, BOOL repeated); | ||
85 | virtual BOOL handleTranslatedKeyUp(KEY key, MASK mask); | ||
86 | virtual void handleScanKey(KEY key, BOOL key_down, BOOL key_up, BOOL key_level); | ||
87 | virtual BOOL handleUnicodeChar(llwchar uni_char, MASK mask); | ||
88 | |||
89 | virtual BOOL handleMouseDown(LLWindow *window, LLCoordGL pos, MASK mask); | ||
90 | virtual BOOL handleMouseUp(LLWindow *window, LLCoordGL pos, MASK mask); | ||
91 | virtual void handleMouseLeave(LLWindow *window); | ||
92 | // return TRUE to allow window to close, which will then cause handleQuit to be called | ||
93 | virtual BOOL handleCloseRequest(LLWindow *window); | ||
94 | // window is about to be destroyed, clean up your business | ||
95 | virtual void handleQuit(LLWindow *window); | ||
96 | virtual BOOL handleRightMouseDown(LLWindow *window, LLCoordGL pos, MASK mask); | ||
97 | virtual BOOL handleRightMouseUp(LLWindow *window, LLCoordGL pos, MASK mask); | ||
98 | virtual BOOL handleActivate(LLWindow *window, BOOL activated); | ||
99 | virtual void handleMouseMove(LLWindow *window, LLCoordGL pos, MASK mask); | ||
100 | virtual void handleScrollWheel(LLWindow *window, S32 clicks); | ||
101 | virtual void handleResize(LLWindow *window, S32 width, S32 height); | ||
102 | virtual void handleFocus(LLWindow *window); | ||
103 | virtual void handleFocusLost(LLWindow *window); | ||
104 | virtual void handleMenuSelect(LLWindow *window, S32 menu_item); | ||
105 | virtual BOOL handlePaint(LLWindow *window, S32 x, S32 y, S32 width, S32 height); | ||
106 | virtual BOOL handleDoubleClick(LLWindow *window, LLCoordGL pos, MASK mask); // double-click of left mouse button | ||
107 | virtual void handleWindowBlock(LLWindow *window); // window is taking over CPU for a while | ||
108 | virtual void handleWindowUnblock(LLWindow *window); // window coming back after taking over CPU for a while | ||
109 | virtual void handleDataCopy(LLWindow *window, S32 data_type, void *data); | ||
110 | }; | ||
111 | |||
112 | // Refer to llwindow_test in test/common/llwindow for usage example | ||
113 | |||
114 | class LLWindow | ||
115 | { | ||
116 | public: | ||
117 | struct LLWindowResolution | ||
118 | { | ||
119 | S32 mWidth; | ||
120 | S32 mHeight; | ||
121 | }; | ||
122 | enum ESwapMethod | ||
123 | { | ||
124 | SWAP_METHOD_UNDEFINED, | ||
125 | SWAP_METHOD_EXCHANGE, | ||
126 | SWAP_METHOD_COPY | ||
127 | }; | ||
128 | enum EFlags | ||
129 | { | ||
130 | // currently unused | ||
131 | }; | ||
132 | public: | ||
133 | virtual void show() = 0; | ||
134 | virtual void hide() = 0; | ||
135 | virtual void close() = 0; | ||
136 | virtual BOOL getVisible() = 0; | ||
137 | virtual BOOL getMinimized() = 0; | ||
138 | virtual BOOL getMaximized() = 0; | ||
139 | virtual BOOL maximize() = 0; | ||
140 | BOOL getFullscreen() { return mFullscreen; }; | ||
141 | virtual BOOL getPosition(LLCoordScreen *position) = 0; | ||
142 | virtual BOOL getSize(LLCoordScreen *size) = 0; | ||
143 | virtual BOOL getSize(LLCoordWindow *size) = 0; | ||
144 | virtual BOOL setPosition(LLCoordScreen position) = 0; | ||
145 | virtual BOOL setSize(LLCoordScreen size) = 0; | ||
146 | virtual BOOL switchContext(BOOL fullscreen, LLCoordScreen size, BOOL disable_vsync) = 0; | ||
147 | virtual BOOL setCursorPosition(LLCoordWindow position) = 0; | ||
148 | virtual BOOL getCursorPosition(LLCoordWindow *position) = 0; | ||
149 | virtual void showCursor() = 0; | ||
150 | virtual void hideCursor() = 0; | ||
151 | virtual BOOL isCursorHidden() = 0; | ||
152 | virtual void showCursorFromMouseMove() = 0; | ||
153 | virtual void hideCursorUntilMouseMove() = 0; | ||
154 | |||
155 | // These two functions create a way to make a busy cursor instead | ||
156 | // of an arrow when someone's busy doing something. Draw an | ||
157 | // arrow/hour if busycount > 0. | ||
158 | virtual void incBusyCount(); | ||
159 | virtual void decBusyCount(); | ||
160 | virtual void resetBusyCount() { mBusyCount = 0; } | ||
161 | virtual S32 getBusyCount() const { return mBusyCount; } | ||
162 | |||
163 | // Sets cursor, may set to arrow+hourglass | ||
164 | virtual void setCursor(ECursorType cursor) = 0; | ||
165 | virtual ECursorType getCursor() const { return mCurrentCursor; } | ||
166 | |||
167 | virtual void captureMouse() = 0; | ||
168 | virtual void releaseMouse() = 0; | ||
169 | virtual void setMouseClipping( BOOL b ) = 0; | ||
170 | virtual BOOL isClipboardTextAvailable() = 0; | ||
171 | virtual BOOL pasteTextFromClipboard(LLWString &dst) = 0; | ||
172 | virtual BOOL copyTextToClipboard(const LLWString &src) = 0; | ||
173 | virtual void flashIcon(F32 seconds) = 0; | ||
174 | virtual F32 getGamma() = 0; | ||
175 | virtual BOOL setGamma(const F32 gamma) = 0; // Set the gamma | ||
176 | virtual BOOL restoreGamma() = 0; // Restore original gamma table (before updating gamma) | ||
177 | virtual ESwapMethod getSwapMethod() { return mSwapMethod; } | ||
178 | virtual void gatherInput() = 0; | ||
179 | virtual void delayInputProcessing() = 0; | ||
180 | virtual void swapBuffers() = 0; | ||
181 | virtual void bringToFront() = 0; | ||
182 | virtual void focusClient() { }; // this may not have meaning or be required on other platforms, therefore, it's not abstract | ||
183 | |||
184 | virtual S32 stat( const char* file_name, struct stat* stat_info ) = 0; | ||
185 | virtual BOOL sendEmail(const char* address,const char* subject,const char* body_text, const char* attachment=NULL, const char* attachment_displayed_name=NULL ) = 0; | ||
186 | |||
187 | |||
188 | // handy coordinate space conversion routines | ||
189 | // NB: screen to window and vice verse won't work on width/height coordinate pairs, | ||
190 | // as the conversion must take into account left AND right border widths, etc. | ||
191 | virtual BOOL convertCoords( LLCoordScreen from, LLCoordWindow *to) = 0; | ||
192 | virtual BOOL convertCoords( LLCoordWindow from, LLCoordScreen *to) = 0; | ||
193 | virtual BOOL convertCoords( LLCoordWindow from, LLCoordGL *to) = 0; | ||
194 | virtual BOOL convertCoords( LLCoordGL from, LLCoordWindow *to) = 0; | ||
195 | virtual BOOL convertCoords( LLCoordScreen from, LLCoordGL *to) = 0; | ||
196 | virtual BOOL convertCoords( LLCoordGL from, LLCoordScreen *to) = 0; | ||
197 | |||
198 | // query supported resolutions | ||
199 | virtual LLWindowResolution* getSupportedResolutions(S32 &num_resolutions) = 0; | ||
200 | virtual F32 getNativeAspectRatio() = 0; | ||
201 | virtual F32 getPixelAspectRatio() = 0; | ||
202 | virtual void setNativeAspectRatio(F32 aspect) = 0; | ||
203 | |||
204 | void setCallbacks(LLWindowCallbacks *callbacks); | ||
205 | |||
206 | virtual void beforeDialog() {}; // prepare to put up an OS dialog (if special measures are required, such as in fullscreen mode) | ||
207 | virtual void afterDialog() {}; // undo whatever was done in beforeDialog() | ||
208 | |||
209 | // opens system default color picker | ||
210 | virtual BOOL dialog_color_picker (F32 *r, F32 *g, F32 *b) { return FALSE; }; | ||
211 | |||
212 | // return a platform-specific window reference (HWND on Windows, WindowRef on the Mac) | ||
213 | virtual void *getPlatformWindow() = 0; | ||
214 | |||
215 | protected: | ||
216 | LLWindow(BOOL fullscreen, U32 flags); | ||
217 | virtual ~LLWindow() {} | ||
218 | virtual BOOL isValid() {return TRUE;} | ||
219 | virtual BOOL canDelete() {return TRUE;} | ||
220 | protected: | ||
221 | static LLWindowCallbacks sDefaultCallbacks; | ||
222 | |||
223 | protected: | ||
224 | LLWindowCallbacks* mCallbacks; | ||
225 | |||
226 | BOOL mPostQuit; // should this window post a quit message when destroyed? | ||
227 | BOOL mFullscreen; | ||
228 | S32 mFullscreenWidth; | ||
229 | S32 mFullscreenHeight; | ||
230 | S32 mFullscreenBits; | ||
231 | S32 mFullscreenRefresh; | ||
232 | LLWindowResolution* mSupportedResolutions; | ||
233 | S32 mNumSupportedResolutions; | ||
234 | ECursorType mCurrentCursor; | ||
235 | BOOL mCursorHidden; | ||
236 | S32 mBusyCount; // how deep is the "cursor busy" stack? | ||
237 | BOOL mIsMouseClipping; // Is this window currently clipping the mouse | ||
238 | ESwapMethod mSwapMethod; | ||
239 | BOOL mHideCursorPermanent; | ||
240 | U32 mFlags; | ||
241 | |||
242 | friend class LLWindowManager; | ||
243 | }; | ||
244 | |||
245 | |||
246 | // LLSplashScreen | ||
247 | // A simple, OS-specific splash screen that we can display | ||
248 | // while initializing the application and before creating a GL | ||
249 | // window | ||
250 | |||
251 | |||
252 | class LLSplashScreen | ||
253 | { | ||
254 | public: | ||
255 | LLSplashScreen() { }; | ||
256 | virtual ~LLSplashScreen() { }; | ||
257 | |||
258 | |||
259 | // Call to display the window. | ||
260 | static LLSplashScreen * create(); | ||
261 | static void show(); | ||
262 | static void hide(); | ||
263 | static void update(const char* string); | ||
264 | |||
265 | static bool isVisible(); | ||
266 | protected: | ||
267 | // These are overridden by the platform implementation | ||
268 | virtual void showImpl() = 0; | ||
269 | virtual void updateImpl(const char* string) = 0; | ||
270 | virtual void hideImpl() = 0; | ||
271 | |||
272 | static BOOL sVisible; | ||
273 | |||
274 | }; | ||
275 | |||
276 | // Platform-neutral for accessing the platform specific message box | ||
277 | S32 OSMessageBox(const char* text, const char* caption, U32 type); | ||
278 | const U32 OSMB_OK = 0; | ||
279 | const U32 OSMB_OKCANCEL = 1; | ||
280 | const U32 OSMB_YESNO = 2; | ||
281 | |||
282 | const S32 OSBTN_YES = 0; | ||
283 | const S32 OSBTN_NO = 1; | ||
284 | const S32 OSBTN_OK = 2; | ||
285 | const S32 OSBTN_CANCEL = 3; | ||
286 | |||
287 | // | ||
288 | // LLWindowManager | ||
289 | // Manages window creation and error checking | ||
290 | |||
291 | class LLWindowManager | ||
292 | { | ||
293 | public: | ||
294 | static LLWindow* createWindow( | ||
295 | char *title, | ||
296 | char *name, | ||
297 | LLCoordScreen upper_left = LLCoordScreen(10, 10), | ||
298 | LLCoordScreen size = LLCoordScreen(320, 240), | ||
299 | U32 flags = 0, | ||
300 | BOOL fullscreen = FALSE, | ||
301 | BOOL clearBg = FALSE, | ||
302 | BOOL disable_vsync = TRUE, | ||
303 | BOOL use_gl = TRUE, | ||
304 | BOOL ignore_pixel_depth = FALSE); | ||
305 | static LLWindow *createWindow( | ||
306 | char* title, char* name, S32 x, S32 y, S32 width, S32 height, | ||
307 | U32 flags = 0, | ||
308 | BOOL fullscreen = FALSE, | ||
309 | BOOL clearBg = FALSE, | ||
310 | BOOL disable_vsync = TRUE, | ||
311 | BOOL use_gl = TRUE, | ||
312 | BOOL ignore_pixel_depth = FALSE); | ||
313 | static BOOL destroyWindow(LLWindow* window); | ||
314 | static BOOL isWindowValid(LLWindow *window); | ||
315 | }; | ||
316 | |||
317 | // | ||
318 | // helper funcs | ||
319 | // | ||
320 | |||
321 | // Protocols, like "http" and "https" we support in URLs | ||
322 | extern const S32 gURLProtocolWhitelistCount; | ||
323 | extern const char* gURLProtocolWhitelist[]; | ||
324 | extern const char* gURLProtocolWhitelistHandler[]; | ||
325 | |||
326 | // Loads a URL with the user's default browser | ||
327 | void spawn_web_browser(const char* escaped_url); | ||
328 | |||
329 | // Opens a file with ShellExecute. Security risk! | ||
330 | void shell_open(const char* file_path); | ||
331 | |||
332 | void simpleEscapeString ( std::string& stringIn ); | ||
333 | |||
334 | #endif // _LL_window_h_ | ||