00001
00032 #ifndef LL_LLWINDOW_H
00033 #define LL_LLWINDOW_H
00034
00035 #include <sys/stat.h>
00036
00037 #include "llrect.h"
00038 #include "llcoord.h"
00039 #include "llstring.h"
00040
00041
00042 enum ECursorType {
00043 UI_CURSOR_ARROW,
00044 UI_CURSOR_WAIT,
00045 UI_CURSOR_HAND,
00046 UI_CURSOR_IBEAM,
00047 UI_CURSOR_CROSS,
00048 UI_CURSOR_SIZENWSE,
00049 UI_CURSOR_SIZENESW,
00050 UI_CURSOR_SIZEWE,
00051 UI_CURSOR_SIZENS,
00052 UI_CURSOR_NO,
00053 UI_CURSOR_WORKING,
00054 UI_CURSOR_TOOLGRAB,
00055 UI_CURSOR_TOOLLAND,
00056 UI_CURSOR_TOOLFOCUS,
00057 UI_CURSOR_TOOLCREATE,
00058 UI_CURSOR_ARROWDRAG,
00059 UI_CURSOR_ARROWCOPY,
00060 UI_CURSOR_ARROWDRAGMULTI,
00061 UI_CURSOR_ARROWCOPYMULTI,
00062 UI_CURSOR_NOLOCKED,
00063 UI_CURSOR_ARROWLOCKED,
00064 UI_CURSOR_GRABLOCKED,
00065 UI_CURSOR_TOOLTRANSLATE,
00066 UI_CURSOR_TOOLROTATE,
00067 UI_CURSOR_TOOLSCALE,
00068 UI_CURSOR_TOOLCAMERA,
00069 UI_CURSOR_TOOLPAN,
00070 UI_CURSOR_TOOLZOOMIN,
00071 UI_CURSOR_TOOLPICKOBJECT3,
00072 UI_CURSOR_TOOLSIT,
00073 UI_CURSOR_TOOLBUY,
00074 UI_CURSOR_TOOLPAY,
00075 UI_CURSOR_TOOLOPEN,
00076 UI_CURSOR_PIPETTE,
00077 UI_CURSOR_COUNT
00078 };
00079
00080 enum EStereoMode
00081 {
00082 STEREO_MODE_NONE = 0,
00083 STEREO_MODE_ANAGLYPH = 1,
00084 STEREO_MODE_ACTIVE = 2
00085 };
00086
00087
00088
00089 class LLSplashScreen;
00090
00091 class LLWindow;
00092
00093 class LLWindowCallbacks
00094 {
00095 public:
00096 virtual ~LLWindowCallbacks() {}
00097 virtual BOOL handleTranslatedKeyDown(KEY key, MASK mask, BOOL repeated);
00098 virtual BOOL handleTranslatedKeyUp(KEY key, MASK mask);
00099 virtual void handleScanKey(KEY key, BOOL key_down, BOOL key_up, BOOL key_level);
00100 virtual BOOL handleUnicodeChar(llwchar uni_char, MASK mask);
00101
00102 virtual BOOL handleMouseDown(LLWindow *window, LLCoordGL pos, MASK mask);
00103 virtual BOOL handleMouseUp(LLWindow *window, LLCoordGL pos, MASK mask);
00104 virtual void handleMouseLeave(LLWindow *window);
00105
00106 virtual BOOL handleCloseRequest(LLWindow *window);
00107
00108 virtual void handleQuit(LLWindow *window);
00109 virtual BOOL handleRightMouseDown(LLWindow *window, LLCoordGL pos, MASK mask);
00110 virtual BOOL handleRightMouseUp(LLWindow *window, LLCoordGL pos, MASK mask);
00111 virtual BOOL handleMiddleMouseDown(LLWindow *window, LLCoordGL pos, MASK mask);
00112 virtual BOOL handleMiddleMouseUp(LLWindow *window, LLCoordGL pos, MASK mask);
00113 virtual BOOL handleActivate(LLWindow *window, BOOL activated);
00114 virtual void handleMouseMove(LLWindow *window, LLCoordGL pos, MASK mask);
00115 virtual void handleScrollWheel(LLWindow *window, S32 clicks);
00116 virtual void handleResize(LLWindow *window, S32 width, S32 height);
00117 virtual void handleFocus(LLWindow *window);
00118 virtual void handleFocusLost(LLWindow *window);
00119 virtual void handleMenuSelect(LLWindow *window, S32 menu_item);
00120 virtual BOOL handlePaint(LLWindow *window, S32 x, S32 y, S32 width, S32 height);
00121 virtual BOOL handleDoubleClick(LLWindow *window, LLCoordGL pos, MASK mask);
00122 virtual void handleWindowBlock(LLWindow *window);
00123 virtual void handleWindowUnblock(LLWindow *window);
00124 virtual void handleDataCopy(LLWindow *window, S32 data_type, void *data);
00125 };
00126
00127
00128
00129 class LLWindow
00130 {
00131 public:
00132 struct LLWindowResolution
00133 {
00134 S32 mWidth;
00135 S32 mHeight;
00136 };
00137 enum ESwapMethod
00138 {
00139 SWAP_METHOD_UNDEFINED,
00140 SWAP_METHOD_EXCHANGE,
00141 SWAP_METHOD_COPY
00142 };
00143 enum EFlags
00144 {
00145
00146 };
00147
00148 public:
00149 virtual void show() = 0;
00150 virtual void hide() = 0;
00151 virtual void close() = 0;
00152 virtual BOOL getVisible() = 0;
00153 virtual BOOL getMinimized() = 0;
00154 virtual BOOL getMaximized() = 0;
00155 virtual BOOL maximize() = 0;
00156 BOOL getFullscreen() { return mFullscreen; };
00157 virtual BOOL getPosition(LLCoordScreen *position) = 0;
00158 virtual BOOL getSize(LLCoordScreen *size) = 0;
00159 virtual BOOL getSize(LLCoordWindow *size) = 0;
00160 virtual BOOL setPosition(LLCoordScreen position) = 0;
00161 virtual BOOL setSize(LLCoordScreen size) = 0;
00162 virtual BOOL switchContext(BOOL fullscreen, LLCoordScreen size, BOOL disable_vsync) = 0;
00163 virtual BOOL setCursorPosition(LLCoordWindow position) = 0;
00164 virtual BOOL getCursorPosition(LLCoordWindow *position) = 0;
00165 virtual void showCursor() = 0;
00166 virtual void hideCursor() = 0;
00167 virtual BOOL isCursorHidden() = 0;
00168 virtual void showCursorFromMouseMove() = 0;
00169 virtual void hideCursorUntilMouseMove() = 0;
00170
00171
00172
00173
00174 virtual void incBusyCount();
00175 virtual void decBusyCount();
00176 virtual void resetBusyCount() { mBusyCount = 0; }
00177 virtual S32 getBusyCount() const { return mBusyCount; }
00178
00179
00180 virtual void setCursor(ECursorType cursor) = 0;
00181 virtual ECursorType getCursor() const { return mCurrentCursor; }
00182
00183 virtual void captureMouse() = 0;
00184 virtual void releaseMouse() = 0;
00185 virtual void setMouseClipping( BOOL b ) = 0;
00186 virtual BOOL isClipboardTextAvailable() = 0;
00187 virtual BOOL pasteTextFromClipboard(LLWString &dst) = 0;
00188 virtual BOOL copyTextToClipboard(const LLWString &src) = 0;
00189 virtual void flashIcon(F32 seconds) = 0;
00190 virtual F32 getGamma() = 0;
00191 virtual BOOL setGamma(const F32 gamma) = 0;
00192 virtual BOOL restoreGamma() = 0;
00193 virtual ESwapMethod getSwapMethod() { return mSwapMethod; }
00194 virtual void gatherInput() = 0;
00195 virtual void delayInputProcessing() = 0;
00196 virtual void swapBuffers() = 0;
00197 virtual void bringToFront() = 0;
00198 virtual void focusClient() { };
00199
00200 virtual S32 stat( const char* file_name, struct stat* stat_info ) = 0;
00201 virtual BOOL sendEmail(const char* address,const char* subject,const char* body_text, const char* attachment=NULL, const char* attachment_displayed_name=NULL ) = 0;
00202
00203
00204
00205
00206
00207 virtual BOOL convertCoords( LLCoordScreen from, LLCoordWindow *to) = 0;
00208 virtual BOOL convertCoords( LLCoordWindow from, LLCoordScreen *to) = 0;
00209 virtual BOOL convertCoords( LLCoordWindow from, LLCoordGL *to) = 0;
00210 virtual BOOL convertCoords( LLCoordGL from, LLCoordWindow *to) = 0;
00211 virtual BOOL convertCoords( LLCoordScreen from, LLCoordGL *to) = 0;
00212 virtual BOOL convertCoords( LLCoordGL from, LLCoordScreen *to) = 0;
00213
00214
00215 virtual LLWindowResolution* getSupportedResolutions(S32 &num_resolutions) = 0;
00216 virtual F32 getNativeAspectRatio() = 0;
00217 virtual F32 getPixelAspectRatio() = 0;
00218 virtual void setNativeAspectRatio(F32 aspect) = 0;
00219
00220 F32 getJoystickAxis(U32 axis);
00221 U8 getJoystickButton(U32 button);
00222
00223 void setCallbacks(LLWindowCallbacks *callbacks);
00224
00225 virtual void beforeDialog() {};
00226 virtual void afterDialog() {};
00227
00228
00229 virtual BOOL dialog_color_picker (F32 *r, F32 *g, F32 *b) { return FALSE; };
00230
00231
00232 virtual void *getPlatformWindow() = 0;
00233
00234
00235 virtual void allowLanguageTextInput( BOOL b ) {};
00236 virtual void setLanguageTextInput( const LLCoordGL & pos ) {};
00237 virtual void setStereoMode( S32 mode ) { mStereoMode = mode; }
00238 virtual S32 getStereoMode() const { return mStereoMode; }
00239
00240 protected:
00241 LLWindow(BOOL fullscreen, U32 flags);
00242 virtual ~LLWindow() {}
00243 virtual BOOL isValid() {return TRUE;}
00244 virtual BOOL canDelete() {return TRUE;}
00245 protected:
00246 static LLWindowCallbacks sDefaultCallbacks;
00247
00248 protected:
00249 LLWindowCallbacks* mCallbacks;
00250
00251 BOOL mPostQuit;
00252 BOOL mFullscreen;
00253 S32 mFullscreenWidth;
00254 S32 mFullscreenHeight;
00255 S32 mFullscreenBits;
00256 S32 mFullscreenRefresh;
00257 LLWindowResolution* mSupportedResolutions;
00258 S32 mNumSupportedResolutions;
00259 ECursorType mCurrentCursor;
00260 BOOL mCursorHidden;
00261 S32 mBusyCount;
00262 BOOL mIsMouseClipping;
00263 ESwapMethod mSwapMethod;
00264 BOOL mHideCursorPermanent;
00265 U32 mFlags;
00266 F32 mJoyAxis[6];
00267 U8 mJoyButtonState[16];
00268 U16 mHighSurrogate;
00269 S32 mStereoMode;
00270
00271
00272
00273
00274
00275
00276
00277 void handleUnicodeUTF16(U16 utf16, MASK mask);
00278
00279 friend class LLWindowManager;
00280 };
00281
00282
00283
00284
00285
00286
00287
00288
00289 class LLSplashScreen
00290 {
00291 public:
00292 LLSplashScreen() { };
00293 virtual ~LLSplashScreen() { };
00294
00295
00296
00297 static LLSplashScreen * create();
00298 static void show();
00299 static void hide();
00300 static void update(const char* string);
00301
00302 static bool isVisible();
00303 protected:
00304
00305 virtual void showImpl() = 0;
00306 virtual void updateImpl(const char* string) = 0;
00307 virtual void hideImpl() = 0;
00308
00309 static BOOL sVisible;
00310
00311 };
00312
00313
00314 S32 OSMessageBox(const char* text, const char* caption, U32 type);
00315 const U32 OSMB_OK = 0;
00316 const U32 OSMB_OKCANCEL = 1;
00317 const U32 OSMB_YESNO = 2;
00318
00319 const S32 OSBTN_YES = 0;
00320 const S32 OSBTN_NO = 1;
00321 const S32 OSBTN_OK = 2;
00322 const S32 OSBTN_CANCEL = 3;
00323
00324
00325
00326
00327
00328 class LLWindowManager
00329 {
00330 public:
00331 static LLWindow* createWindow(
00332 char *title,
00333 char *name,
00334 LLCoordScreen upper_left = LLCoordScreen(10, 10),
00335 LLCoordScreen size = LLCoordScreen(320, 240),
00336 U32 flags = 0,
00337 BOOL fullscreen = FALSE,
00338 BOOL clearBg = FALSE,
00339 BOOL disable_vsync = TRUE,
00340 BOOL use_gl = TRUE,
00341 BOOL ignore_pixel_depth = FALSE,
00342 S32 stereo_mode = 0);
00343 static LLWindow *createWindow(
00344 char* title, char* name, S32 x, S32 y, S32 width, S32 height,
00345 U32 flags = 0,
00346 BOOL fullscreen = FALSE,
00347 BOOL clearBg = FALSE,
00348 BOOL disable_vsync = TRUE,
00349 BOOL use_gl = TRUE,
00350 BOOL ignore_pixel_depth = FALSE,
00351 S32 stereo_mode = 0);
00352 static BOOL destroyWindow(LLWindow* window);
00353 static BOOL isWindowValid(LLWindow *window);
00354 };
00355
00356
00357
00358
00359 extern BOOL gDebugWindowProc;
00360
00361
00362 extern const S32 gURLProtocolWhitelistCount;
00363 extern const char* gURLProtocolWhitelist[];
00364 extern const char* gURLProtocolWhitelistHandler[];
00365
00366
00367 void spawn_web_browser(const char* escaped_url);
00368
00369
00370 void shell_open(const char* file_path);
00371
00372 void simpleEscapeString ( std::string& stringIn );
00373
00374 #endif // _LL_window_h_