llwindowmacosx.h

Go to the documentation of this file.
00001 
00032 #ifndef LL_LLWINDOWMACOSX_H
00033 #define LL_LLWINDOWMACOSX_H
00034 
00035 #include "llwindow.h"
00036 
00037 #include <Carbon/Carbon.h>
00038 #include <AGL/agl.h>
00039 
00040 // AssertMacros.h does bad things.
00041 #undef verify
00042 #undef check
00043 #undef require
00044 
00045 
00046 class LLWindowMacOSX : public LLWindow
00047 {
00048 public:
00049         /*virtual*/ void show();
00050         /*virtual*/ void hide();
00051         /*virtual*/ void close();
00052         /*virtual*/ BOOL getVisible();
00053         /*virtual*/ BOOL getMinimized();
00054         /*virtual*/ BOOL getMaximized();
00055         /*virtual*/ BOOL maximize();
00056         /*virtual*/ BOOL getFullscreen();
00057         /*virtual*/ BOOL getPosition(LLCoordScreen *position);
00058         /*virtual*/ BOOL getSize(LLCoordScreen *size);
00059         /*virtual*/ BOOL getSize(LLCoordWindow *size);
00060         /*virtual*/ BOOL setPosition(LLCoordScreen position);
00061         /*virtual*/ BOOL setSize(LLCoordScreen size);
00062         /*virtual*/ BOOL switchContext(BOOL fullscreen, LLCoordScreen size, BOOL disable_vsync);
00063         /*virtual*/ BOOL setCursorPosition(LLCoordWindow position);
00064         /*virtual*/ BOOL getCursorPosition(LLCoordWindow *position);
00065         /*virtual*/ void showCursor();
00066         /*virtual*/ void hideCursor();
00067         /*virtual*/ void showCursorFromMouseMove();
00068         /*virtual*/ void hideCursorUntilMouseMove();
00069         /*virtual*/ BOOL isCursorHidden();
00070         /*virtual*/ void setCursor(ECursorType cursor);
00071         /*virtual*/ ECursorType getCursor();
00072         /*virtual*/ void captureMouse();
00073         /*virtual*/ void releaseMouse();
00074         /*virtual*/ void setMouseClipping( BOOL b );
00075         /*virtual*/ BOOL isClipboardTextAvailable();
00076         /*virtual*/ BOOL pasteTextFromClipboard(LLWString &dst);
00077         /*virtual*/ BOOL copyTextToClipboard(const LLWString & src);
00078         /*virtual*/ void flashIcon(F32 seconds);
00079         /*virtual*/ F32 getGamma();
00080         /*virtual*/ BOOL setGamma(const F32 gamma); // Set the gamma
00081         /*virtual*/ BOOL restoreGamma();                        // Restore original gamma table (before updating gamma)
00082         /*virtual*/ ESwapMethod getSwapMethod() { return mSwapMethod; }
00083         /*virtual*/ void gatherInput();
00084         /*virtual*/ void delayInputProcessing() {};
00085         /*virtual*/ void swapBuffers();
00086 
00087         /*virtual*/ LLString getTempFileName();
00088         /*virtual*/ void deleteFile( const char* file_name );
00089         /*virtual*/ S32 stat( const char* file_name, struct stat* stat_info );
00090         /*virtual*/ BOOL sendEmail(const char* address,const char* subject,const char* body_text,const char* attachment=NULL, const char* attachment_displayed_name=NULL);
00091 
00092 
00093         // handy coordinate space conversion routines
00094         /*virtual*/ BOOL convertCoords(LLCoordScreen from, LLCoordWindow *to);
00095         /*virtual*/ BOOL convertCoords(LLCoordWindow from, LLCoordScreen *to);
00096         /*virtual*/ BOOL convertCoords(LLCoordWindow from, LLCoordGL *to);
00097         /*virtual*/ BOOL convertCoords(LLCoordGL from, LLCoordWindow *to);
00098         /*virtual*/ BOOL convertCoords(LLCoordScreen from, LLCoordGL *to);
00099         /*virtual*/ BOOL convertCoords(LLCoordGL from, LLCoordScreen *to);
00100 
00101         /*virtual*/ LLWindowResolution* getSupportedResolutions(S32 &num_resolutions);
00102         /*virtual*/ F32 getNativeAspectRatio();
00103         /*virtual*/ F32 getPixelAspectRatio();
00104         /*virtual*/ void setNativeAspectRatio(F32 ratio) { mOverrideAspectRatio = ratio; }
00105 
00106         /*virtual*/ void beforeDialog();
00107         /*virtual*/ void afterDialog();
00108 
00109         /*virtual*/ BOOL dialog_color_picker(F32 *r, F32 *g, F32 *b);
00110 
00111         /*virtual*/ void *getPlatformWindow();
00112         /*virtual*/ void bringToFront() {};
00113         
00114         /*virtual*/ void allowLanguageTextInput(BOOL b);
00115         
00116 protected:
00117         LLWindowMacOSX(
00118                 char *title, char *name, int x, int y, int width, int height, U32 flags,
00119                 BOOL fullscreen, BOOL clearBg, BOOL disable_vsync, BOOL use_gl,
00120                 BOOL ignore_pixel_depth);
00121         ~LLWindowMacOSX();
00122 
00123         void    initCursors();
00124         BOOL    isValid();
00125         void    moveWindow(const LLCoordScreen& position,const LLCoordScreen& size);
00126 
00127 
00128         // Changes display resolution. Returns true if successful
00129         BOOL    setDisplayResolution(S32 width, S32 height, S32 bits, S32 refresh);
00130 
00131         // Go back to last fullscreen display resolution.
00132         BOOL    setFullscreenResolution();
00133 
00134         // Restore the display resolution to its value before we ran the app.
00135         BOOL    resetDisplayResolution();
00136 
00137         void    minimize();
00138         void    restore();
00139 
00140         BOOL    shouldPostQuit() { return mPostQuit; }
00141 
00142 
00143 protected:
00144         //
00145         // Platform specific methods
00146         //
00147 
00148         // create or re-create the GL context/window.  Called from the constructor and switchContext().
00149         BOOL createContext(int x, int y, int width, int height, int bits, BOOL fullscreen, BOOL disable_vsync);
00150         void destroyContext();
00151         void setupFailure(const char* text, const char* caption, U32 type);
00152         static pascal OSStatus staticEventHandler (EventHandlerCallRef myHandler, EventRef event, void* userData);
00153         OSStatus eventHandler (EventHandlerCallRef myHandler, EventRef event);
00154         void adjustCursorDecouple(bool warpingMouse = false);
00155         void fixWindowSize(void);
00156         void stopDockTileBounce();
00157 
00158 
00159         //
00160         // Platform specific variables
00161         //
00162         WindowRef               mWindow;
00163         AGLContext              mContext;
00164         AGLPixelFormat  mPixelFormat;
00165         CGDirectDisplayID       mDisplay;
00166         CFDictionaryRef         mOldDisplayMode;
00167         EventLoopTimerRef       mTimer;
00168         EventHandlerUPP         mEventHandlerUPP;
00169         EventHandlerRef         mGlobalHandlerRef;
00170         EventHandlerRef         mWindowHandlerRef;
00171         Rect            mOldMouseClip;  // Screen rect to which the mouse cursor was globally constrained before we changed it in clipMouse()
00172         Str255          mWindowTitle;
00173         double          mOriginalAspectRatio;
00174         BOOL            mSimulatedRightClick;
00175         UInt32          mLastModifiers;
00176         BOOL            mHandsOffEvents;        // When true, temporarially disable CarbonEvent processing.
00177         // Used to allow event processing when putting up dialogs in fullscreen mode.
00178         BOOL            mCursorDecoupled;
00179         S32                     mCursorLastEventDeltaX;
00180         S32                     mCursorLastEventDeltaY;
00181         BOOL            mCursorIgnoreNextDelta;
00182         BOOL            mNeedsResize;           // Constructor figured out the window is too big, it needs a resize.
00183         LLCoordScreen   mNeedsResizeSize;
00184         F32                     mOverrideAspectRatio;
00185         BOOL            mMinimized;
00186 
00187         F32                     mBounceTime;
00188         NMRec           mBounceRec;
00189         LLTimer         mBounceTimer;
00190 
00191         // Imput method management through Text Service Manager.
00192         TSMDocumentID   mTSMDocument;
00193         BOOL            mLanguageTextInputAllowed;
00194         ScriptCode      mTSMScriptCode;
00195         LangCode        mTSMLangCode;
00196 
00197         friend class LLWindowManager;
00198 };
00199 
00200 
00201 class LLSplashScreenMacOSX : public LLSplashScreen
00202 {
00203 public:
00204         LLSplashScreenMacOSX();
00205         virtual ~LLSplashScreenMacOSX();
00206 
00207         /*virtual*/ void showImpl();
00208         /*virtual*/ void updateImpl(const char* mesg);
00209         /*virtual*/ void hideImpl();
00210 
00211 private:
00212         WindowRef   mWindow;
00213 };
00214 
00215 S32 OSMessageBoxMacOSX(const char* text, const char* caption, U32 type);
00216 
00217 void load_url_external(const char* url);
00218 void shell_open( const char* file_path );
00219 
00220 #endif //LL_LLWINDOWMACOSX_H

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