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