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_TOOLPLAY,
00077 UI_CURSOR_TOOLPAUSE,
00078 UI_CURSOR_TOOLMEDIAOPEN,
00079 UI_CURSOR_PIPETTE,
00080 UI_CURSOR_COUNT
00081 };
00082
00083 class LLSplashScreen;
00084
00085 class LLWindow;
00086
00087 class LLPreeditor;
00088
00089 class LLWindowCallbacks
00090 {
00091 public:
00092 virtual ~LLWindowCallbacks() {}
00093 virtual BOOL handleTranslatedKeyDown(KEY key, MASK mask, BOOL repeated);
00094 virtual BOOL handleTranslatedKeyUp(KEY key, MASK mask);
00095 virtual void handleScanKey(KEY key, BOOL key_down, BOOL key_up, BOOL key_level);
00096 virtual BOOL handleUnicodeChar(llwchar uni_char, MASK mask);
00097
00098 virtual BOOL handleMouseDown(LLWindow *window, LLCoordGL pos, MASK mask);
00099 virtual BOOL handleMouseUp(LLWindow *window, LLCoordGL pos, MASK mask);
00100 virtual void handleMouseLeave(LLWindow *window);
00101
00102 virtual BOOL handleCloseRequest(LLWindow *window);
00103
00104 virtual void handleQuit(LLWindow *window);
00105 virtual BOOL handleRightMouseDown(LLWindow *window, LLCoordGL pos, MASK mask);
00106 virtual BOOL handleRightMouseUp(LLWindow *window, LLCoordGL pos, MASK mask);
00107 virtual BOOL handleMiddleMouseDown(LLWindow *window, LLCoordGL pos, MASK mask);
00108 virtual BOOL handleMiddleMouseUp(LLWindow *window, LLCoordGL pos, MASK mask);
00109 virtual BOOL handleActivate(LLWindow *window, BOOL activated);
00110 virtual BOOL handleActivateApp(LLWindow *window, BOOL activating);
00111 virtual void handleMouseMove(LLWindow *window, LLCoordGL pos, MASK mask);
00112 virtual void handleScrollWheel(LLWindow *window, S32 clicks);
00113 virtual void handleResize(LLWindow *window, S32 width, S32 height);
00114 virtual void handleFocus(LLWindow *window);
00115 virtual void handleFocusLost(LLWindow *window);
00116 virtual void handleMenuSelect(LLWindow *window, S32 menu_item);
00117 virtual BOOL handlePaint(LLWindow *window, S32 x, S32 y, S32 width, S32 height);
00118 virtual BOOL handleDoubleClick(LLWindow *window, LLCoordGL pos, MASK mask);
00119 virtual void handleWindowBlock(LLWindow *window);
00120 virtual void handleWindowUnblock(LLWindow *window);
00121 virtual void handleDataCopy(LLWindow *window, S32 data_type, void *data);
00122 virtual BOOL handleTimerEvent(LLWindow *window);
00123 virtual BOOL handleDeviceChange(LLWindow *window);
00124 };
00125
00126
00127
00128 class LLWindow
00129 {
00130 public:
00131 struct LLWindowResolution
00132 {
00133 S32 mWidth;
00134 S32 mHeight;
00135 };
00136 enum ESwapMethod
00137 {
00138 SWAP_METHOD_UNDEFINED,
00139 SWAP_METHOD_EXCHANGE,
00140 SWAP_METHOD_COPY
00141 };
00142 enum EFlags
00143 {
00144
00145 };
00146 public:
00147 virtual void show() = 0;
00148 virtual void hide() = 0;
00149 virtual void close() = 0;
00150 virtual BOOL getVisible() = 0;
00151 virtual BOOL getMinimized() = 0;
00152 virtual BOOL getMaximized() = 0;
00153 virtual BOOL maximize() = 0;
00154 BOOL getFullscreen() { return mFullscreen; };
00155 virtual BOOL getPosition(LLCoordScreen *position) = 0;
00156 virtual BOOL getSize(LLCoordScreen *size) = 0;
00157 virtual BOOL getSize(LLCoordWindow *size) = 0;
00158 virtual BOOL setPosition(LLCoordScreen position) = 0;
00159 virtual BOOL setSize(LLCoordScreen size) = 0;
00160 virtual BOOL switchContext(BOOL fullscreen, const LLCoordScreen &size, BOOL disable_vsync, const LLCoordScreen * const posp = NULL) = 0;
00161 virtual BOOL setCursorPosition(LLCoordWindow position) = 0;
00162 virtual BOOL getCursorPosition(LLCoordWindow *position) = 0;
00163 virtual void showCursor() = 0;
00164 virtual void hideCursor() = 0;
00165 virtual BOOL isCursorHidden() = 0;
00166 virtual void showCursorFromMouseMove() = 0;
00167 virtual void hideCursorUntilMouseMove() = 0;
00168
00169
00170
00171
00172 virtual void incBusyCount();
00173 virtual void decBusyCount();
00174 virtual void resetBusyCount() { mBusyCount = 0; }
00175 virtual S32 getBusyCount() const { return mBusyCount; }
00176
00177
00178 virtual void setCursor(ECursorType cursor) = 0;
00179 virtual ECursorType getCursor() const { return mCurrentCursor; }
00180
00181 virtual void captureMouse() = 0;
00182 virtual void releaseMouse() = 0;
00183 virtual void setMouseClipping( BOOL b ) = 0;
00184 virtual BOOL isClipboardTextAvailable() = 0;
00185 virtual BOOL pasteTextFromClipboard(LLWString &dst) = 0;
00186 virtual BOOL copyTextToClipboard(const LLWString &src) = 0;
00187 virtual void flashIcon(F32 seconds) = 0;
00188 virtual F32 getGamma() = 0;
00189 virtual BOOL setGamma(const F32 gamma) = 0;
00190 virtual void setFSAASamples(const U32 fsaa_samples) = 0;
00191 virtual U32 getFSAASamples() = 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 void setCallbacks(LLWindowCallbacks *callbacks);
00221
00222 virtual void beforeDialog() {};
00223 virtual void afterDialog() {};
00224
00225
00226 virtual BOOL dialog_color_picker (F32 *r, F32 *g, F32 *b) { return FALSE; };
00227
00228
00229 virtual void *getPlatformWindow() = 0;
00230
00231
00232 virtual void allowLanguageTextInput(LLPreeditor *preeditor, BOOL b) {}
00233 virtual void setLanguageTextInput( const LLCoordGL & pos ) {};
00234 virtual void updateLanguageTextInputArea() {}
00235 virtual void interruptLanguageTextInput() {}
00236
00237 static std::string getFontListSans();
00238
00239 protected:
00240 LLWindow(BOOL fullscreen, U32 flags);
00241 virtual ~LLWindow() {}
00242 virtual BOOL isValid() {return TRUE;}
00243 virtual BOOL canDelete() {return TRUE;}
00244 protected:
00245 static LLWindowCallbacks sDefaultCallbacks;
00246
00247 protected:
00248 LLWindowCallbacks* mCallbacks;
00249
00250 BOOL mPostQuit;
00251 BOOL mFullscreen;
00252 S32 mFullscreenWidth;
00253 S32 mFullscreenHeight;
00254 S32 mFullscreenBits;
00255 S32 mFullscreenRefresh;
00256 LLWindowResolution* mSupportedResolutions;
00257 S32 mNumSupportedResolutions;
00258 ECursorType mCurrentCursor;
00259 BOOL mCursorHidden;
00260 S32 mBusyCount;
00261 BOOL mIsMouseClipping;
00262 ESwapMethod mSwapMethod;
00263 BOOL mHideCursorPermanent;
00264 U32 mFlags;
00265 U16 mHighSurrogate;
00266
00267
00268
00269
00270
00271
00272
00273 void handleUnicodeUTF16(U16 utf16, MASK mask);
00274
00275 friend class LLWindowManager;
00276 };
00277
00278
00279
00280
00281
00282
00283
00284
00285 class LLSplashScreen
00286 {
00287 public:
00288 LLSplashScreen() { };
00289 virtual ~LLSplashScreen() { };
00290
00291
00292
00293 static LLSplashScreen * create();
00294 static void show();
00295 static void hide();
00296 static void update(const char* string);
00297
00298 static bool isVisible();
00299 protected:
00300
00301 virtual void showImpl() = 0;
00302 virtual void updateImpl(const char* string) = 0;
00303 virtual void hideImpl() = 0;
00304
00305 static BOOL sVisible;
00306
00307 };
00308
00309
00310 S32 OSMessageBox(const char* text, const char* caption, U32 type);
00311 const U32 OSMB_OK = 0;
00312 const U32 OSMB_OKCANCEL = 1;
00313 const U32 OSMB_YESNO = 2;
00314
00315 const S32 OSBTN_YES = 0;
00316 const S32 OSBTN_NO = 1;
00317 const S32 OSBTN_OK = 2;
00318 const S32 OSBTN_CANCEL = 3;
00319
00320
00321
00322
00323
00324 class LLWindowManager
00325 {
00326 public:
00327 static LLWindow* createWindow(
00328 char *title,
00329 char *name,
00330 LLCoordScreen upper_left = LLCoordScreen(10, 10),
00331 LLCoordScreen size = LLCoordScreen(320, 240),
00332 U32 flags = 0,
00333 BOOL fullscreen = FALSE,
00334 BOOL clearBg = FALSE,
00335 BOOL disable_vsync = TRUE,
00336 BOOL use_gl = TRUE,
00337 BOOL ignore_pixel_depth = FALSE);
00338 static LLWindow *createWindow(
00339 char* title, char* name, S32 x, S32 y, S32 width, S32 height,
00340 U32 flags = 0,
00341 BOOL fullscreen = FALSE,
00342 BOOL clearBg = FALSE,
00343 BOOL disable_vsync = TRUE,
00344 BOOL use_gl = TRUE,
00345 BOOL ignore_pixel_depth = FALSE,
00346 U32 fsaa_samples = 0);
00347 static BOOL destroyWindow(LLWindow* window);
00348 static BOOL isWindowValid(LLWindow *window);
00349 };
00350
00351
00352
00353
00354 extern BOOL gDebugWindowProc;
00355
00356
00357 extern const S32 gURLProtocolWhitelistCount;
00358 extern const char* gURLProtocolWhitelist[];
00359 extern const char* gURLProtocolWhitelistHandler[];
00360
00361
00362 void spawn_web_browser(const char* escaped_url);
00363
00364 void simpleEscapeString ( std::string& stringIn );
00365
00366 #endif // _LL_window_h_