llwindowsdl.h

Go to the documentation of this file.
00001 
00032 #ifndef LL_LLWINDOWSDL_H
00033 #define LL_LLWINDOWSDL_H
00034 
00035 // Simple Directmedia Layer (http://libsdl.org/) implementation of LLWindow class
00036 
00037 #include "llwindow.h"
00038 
00039 #include "SDL/SDL.h"
00040 
00041 #if LL_X11
00042 // get X11-specific headers for use in low-level stuff like copy-and-paste support
00043 #include "SDL/SDL_syswm.h"
00044 #endif
00045 
00046 // AssertMacros.h does bad things.
00047 #undef verify
00048 #undef check
00049 #undef require
00050 
00051 
00052 class LLWindowSDL : public LLWindow
00053 {
00054 public:
00055         /*virtual*/ void show();
00056         /*virtual*/ void hide();
00057         /*virtual*/ void close();
00058         /*virtual*/ BOOL getVisible();
00059         /*virtual*/ BOOL getMinimized();
00060         /*virtual*/ BOOL getMaximized();
00061         /*virtual*/ BOOL maximize();
00062         /*virtual*/ BOOL getFullscreen();
00063         /*virtual*/ BOOL getPosition(LLCoordScreen *position);
00064         /*virtual*/ BOOL getSize(LLCoordScreen *size);
00065         /*virtual*/ BOOL getSize(LLCoordWindow *size);
00066         /*virtual*/ BOOL setPosition(LLCoordScreen position);
00067         /*virtual*/ BOOL setSize(LLCoordScreen size);
00068         /*virtual*/ BOOL switchContext(BOOL fullscreen, LLCoordScreen size, BOOL disable_vsync);
00069         /*virtual*/ BOOL setCursorPosition(LLCoordWindow position);
00070         /*virtual*/ BOOL getCursorPosition(LLCoordWindow *position);
00071         /*virtual*/ void showCursor();
00072         /*virtual*/ void hideCursor();
00073         /*virtual*/ void showCursorFromMouseMove();
00074         /*virtual*/ void hideCursorUntilMouseMove();
00075         /*virtual*/ BOOL isCursorHidden();
00076         /*virtual*/ void setCursor(ECursorType cursor);
00077         /*virtual*/ ECursorType getCursor();
00078         /*virtual*/ void captureMouse();
00079         /*virtual*/ void releaseMouse();
00080         /*virtual*/ void setMouseClipping( BOOL b );
00081         /*virtual*/ BOOL isClipboardTextAvailable();
00082         /*virtual*/ BOOL pasteTextFromClipboard(LLWString &dst);
00083         /*virtual*/ BOOL copyTextToClipboard(const LLWString & src);
00084         /*virtual*/ void flashIcon(F32 seconds);
00085         /*virtual*/ F32 getGamma();
00086         /*virtual*/ BOOL setGamma(const F32 gamma); // Set the gamma
00087         /*virtual*/ BOOL restoreGamma();                        // Restore original gamma table (before updating gamma)
00088         /*virtual*/ ESwapMethod getSwapMethod() { return mSwapMethod; }
00089         /*virtual*/ void gatherInput();
00090         /*virtual*/ void swapBuffers();
00091 
00092         /*virtual*/ LLString getTempFileName();
00093         /*virtual*/ void deleteFile( const char* file_name );
00094         /*virtual*/ S32 stat( const char* file_name, struct stat* stat_info );
00095         /*virtual*/ BOOL sendEmail(const char* address,const char* subject,const char* body_text,const char* attachment=NULL, const char* attachment_displayed_name=NULL);
00096 
00097     /*virtual*/ void delayInputProcessing() { };
00098 
00099         // handy coordinate space conversion routines
00100         /*virtual*/ BOOL convertCoords(LLCoordScreen from, LLCoordWindow *to);
00101         /*virtual*/ BOOL convertCoords(LLCoordWindow from, LLCoordScreen *to);
00102         /*virtual*/ BOOL convertCoords(LLCoordWindow from, LLCoordGL *to);
00103         /*virtual*/ BOOL convertCoords(LLCoordGL from, LLCoordWindow *to);
00104         /*virtual*/ BOOL convertCoords(LLCoordScreen from, LLCoordGL *to);
00105         /*virtual*/ BOOL convertCoords(LLCoordGL from, LLCoordScreen *to);
00106 
00107         /*virtual*/ LLWindowResolution* getSupportedResolutions(S32 &num_resolutions);
00108         /*virtual*/ F32 getNativeAspectRatio();
00109         /*virtual*/ F32 getPixelAspectRatio();
00110         /*virtual*/ void setNativeAspectRatio(F32 ratio) { mOverrideAspectRatio = ratio; }
00111 
00112         /*virtual*/ void beforeDialog();
00113         /*virtual*/ void afterDialog();
00114 
00115         /*virtual*/ BOOL dialog_color_picker(F32 *r, F32 *g, F32 *b);
00116 
00117         /*virtual*/ void *getPlatformWindow();
00118         /*virtual*/ void bringToFront();
00119 
00120         // Not great that these are public, but they have to be accessible
00121         // by non-class code and it's better than making them global.
00122 #if LL_X11
00123         // These are set up by the X11 clipboard initialization code
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         // Changes display resolution. Returns true if successful
00144         BOOL    setDisplayResolution(S32 width, S32 height, S32 bits, S32 refresh);
00145 
00146         // Go back to last fullscreen display resolution.
00147         BOOL    setFullscreenResolution();
00148 
00149         void    minimize();
00150         void    restore();
00151 
00152         BOOL    shouldPostQuit() { return mPostQuit; }
00153 
00154 
00155 protected:
00156         //
00157         // Platform specific methods
00158         //
00159 
00160         // create or re-create the GL context/window.  Called from the constructor and switchContext().
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         // Platform specific variables
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;           // Constructor figured out the window is too big, it needs a resize.
00182         LLCoordScreen   mNeedsResizeSize;
00183         F32                     mOverrideAspectRatio;
00184         F32             mGamma;
00185 
00186         int             mSDLFlags;
00187 
00188         SDL_Cursor*     mSDLCursors[UI_CURSOR_COUNT];
00189         int             mHaveInputFocus; /* 0=no, 1=yes, else unknown */
00190         int             mIsMinimized; /* 0=no, 1=yes, else unknown */
00191 
00192         friend class LLWindowManager;
00193 
00194 #if LL_X11
00195 private:
00196         // more X11 clipboard stuff
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         /*virtual*/ void showImpl();
00218         /*virtual*/ void updateImpl(const char* mesg);
00219         /*virtual*/ 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 // Lazily initialize and check the runtime GTK version for goodness.
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

Generated on Thu Jul 1 06:09:46 2010 for Second Life Viewer by  doxygen 1.4.7