00001
00032 #ifndef LL_LLWINDOWSDL_H
00033 #define LL_LLWINDOWSDL_H
00034
00035
00036
00037 #include "llwindow.h"
00038
00039 #include "SDL/SDL.h"
00040
00041 #if LL_X11
00042
00043 #include "SDL/SDL_syswm.h"
00044 #endif
00045
00046
00047 #undef verify
00048 #undef check
00049 #undef require
00050
00051
00052 class LLWindowSDL : public LLWindow
00053 {
00054 public:
00055 void show();
00056 void hide();
00057 void close();
00058 BOOL getVisible();
00059 BOOL getMinimized();
00060 BOOL getMaximized();
00061 BOOL maximize();
00062 BOOL getFullscreen();
00063 BOOL getPosition(LLCoordScreen *position);
00064 BOOL getSize(LLCoordScreen *size);
00065 BOOL getSize(LLCoordWindow *size);
00066 BOOL setPosition(LLCoordScreen position);
00067 BOOL setSize(LLCoordScreen size);
00068 BOOL switchContext(BOOL fullscreen, LLCoordScreen size, BOOL disable_vsync);
00069 BOOL setCursorPosition(LLCoordWindow position);
00070 BOOL getCursorPosition(LLCoordWindow *position);
00071 void showCursor();
00072 void hideCursor();
00073 void showCursorFromMouseMove();
00074 void hideCursorUntilMouseMove();
00075 BOOL isCursorHidden();
00076 void setCursor(ECursorType cursor);
00077 ECursorType getCursor();
00078 void captureMouse();
00079 void releaseMouse();
00080 void setMouseClipping( BOOL b );
00081 BOOL isClipboardTextAvailable();
00082 BOOL pasteTextFromClipboard(LLWString &dst);
00083 BOOL copyTextToClipboard(const LLWString & src);
00084 void flashIcon(F32 seconds);
00085 F32 getGamma();
00086 BOOL setGamma(const F32 gamma);
00087 BOOL restoreGamma();
00088 ESwapMethod getSwapMethod() { return mSwapMethod; }
00089 void gatherInput();
00090 void swapBuffers();
00091
00092 LLString getTempFileName();
00093 void deleteFile( const char* file_name );
00094 S32 stat( const char* file_name, struct stat* stat_info );
00095 BOOL sendEmail(const char* address,const char* subject,const char* body_text,const char* attachment=NULL, const char* attachment_displayed_name=NULL);
00096
00097 void delayInputProcessing() { };
00098
00099
00100 BOOL convertCoords(LLCoordScreen from, LLCoordWindow *to);
00101 BOOL convertCoords(LLCoordWindow from, LLCoordScreen *to);
00102 BOOL convertCoords(LLCoordWindow from, LLCoordGL *to);
00103 BOOL convertCoords(LLCoordGL from, LLCoordWindow *to);
00104 BOOL convertCoords(LLCoordScreen from, LLCoordGL *to);
00105 BOOL convertCoords(LLCoordGL from, LLCoordScreen *to);
00106
00107 LLWindowResolution* getSupportedResolutions(S32 &num_resolutions);
00108 F32 getNativeAspectRatio();
00109 F32 getPixelAspectRatio();
00110 void setNativeAspectRatio(F32 ratio) { mOverrideAspectRatio = ratio; }
00111
00112 void beforeDialog();
00113 void afterDialog();
00114
00115 BOOL dialog_color_picker(F32 *r, F32 *g, F32 *b);
00116
00117 void *getPlatformWindow();
00118 void bringToFront();
00119
00120
00121
00122 #if LL_X11
00123
00124 Window mSDL_XWindowID;
00125 Display *mSDL_Display;
00126 #endif
00127 void (*Lock_Display)(void);
00128 void (*Unlock_Display)(void);
00129
00130 protected:
00131 LLWindowSDL(
00132 char *title, int x, int y, int width, int height, U32 flags,
00133 BOOL fullscreen, BOOL clearBg, BOOL disable_vsync, BOOL use_gl,
00134 BOOL ignore_pixel_depth, S32 stereo_mode);
00135 ~LLWindowSDL();
00136
00137 void initCursors();
00138 void quitCursors();
00139 BOOL isValid();
00140 void moveWindow(const LLCoordScreen& position,const LLCoordScreen& size);
00141
00142
00143
00144 BOOL setDisplayResolution(S32 width, S32 height, S32 bits, S32 refresh);
00145
00146
00147 BOOL setFullscreenResolution();
00148
00149 void minimize();
00150 void restore();
00151
00152 BOOL shouldPostQuit() { return mPostQuit; }
00153
00154
00155 protected:
00156
00157
00158
00159
00160
00161 BOOL createContext(int x, int y, int width, int height, int bits, BOOL fullscreen, BOOL disable_vsync);
00162 void destroyContext();
00163 void setupFailure(const char* text, const char* caption, U32 type);
00164 void adjustCursorDecouple(bool warpingMouse = false);
00165 void fixWindowSize(void);
00166 U32 SDLCheckGrabbyKeys(SDLKey keysym, BOOL gain);
00167 BOOL SDLReallyCaptureInput(BOOL capture);
00168
00169
00170
00171
00172 U32 mGrabbyKeyFlags;
00173 int mReallyCapturedCount;
00174 SDL_Surface * mWindow;
00175 char * mWindowTitle;
00176 double mOriginalAspectRatio;
00177 BOOL mCursorDecoupled;
00178 S32 mCursorLastEventDeltaX;
00179 S32 mCursorLastEventDeltaY;
00180 BOOL mCursorIgnoreNextDelta;
00181 BOOL mNeedsResize;
00182 LLCoordScreen mNeedsResizeSize;
00183 F32 mOverrideAspectRatio;
00184 F32 mGamma;
00185
00186 int mSDLFlags;
00187
00188 SDL_Cursor* mSDLCursors[UI_CURSOR_COUNT];
00189 int mHaveInputFocus;
00190 int mIsMinimized;
00191
00192 friend class LLWindowManager;
00193
00194 #if LL_X11
00195 private:
00196
00197 int init_x11clipboard(void);
00198 void quit_x11clipboard(void);
00199 int is_empty_x11clipboard(void);
00200 void put_x11clipboard(int type, int srclen, const char *src);
00201 void get_x11clipboard(int type, int *dstlen, char **dst);
00202 void x11_set_urgent(BOOL urgent);
00203 BOOL mFlashing;
00204 LLTimer mFlashTimer;
00205 #endif //LL_X11
00206
00207
00208 };
00209
00210
00211 class LLSplashScreenSDL : public LLSplashScreen
00212 {
00213 public:
00214 LLSplashScreenSDL();
00215 virtual ~LLSplashScreenSDL();
00216
00217 void showImpl();
00218 void updateImpl(const char* mesg);
00219 void hideImpl();
00220 };
00221
00222 S32 OSMessageBoxSDL(const char* text, const char* caption, U32 type);
00223
00224 void load_url_external(const char* url);
00225 void shell_open( const char* file_path );
00226
00227 #if LL_GTK
00228
00229 BOOL ll_try_gtk_init(void);
00230 #endif // LL_GTK
00231
00232 #if LL_X11
00233 Window get_SDL_XWindowID(void);
00234 Display* get_SDL_Display(void);
00235 #endif // LL_X11
00236
00237 #endif //LL_LLWINDOWSDL_H