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

Generated on Fri May 16 08:33:04 2008 for SecondLife by  doxygen 1.5.5