llwindowwin32.h

Go to the documentation of this file.
00001 
00032 #ifndef LL_LLWINDOWWIN32_H
00033 #define LL_LLWINDOWWIN32_H
00034 
00035 // Limit Windows API to small and manageable set.
00036 #define WIN32_LEAN_AND_MEAN
00037 #include <winsock2.h>
00038 #include <windows.h>
00039 
00040 #include "llwindow.h"
00041 
00042 // Hack for async host by name
00043 #define LL_WM_HOST_RESOLVED      (WM_APP + 1)
00044 typedef void (*LLW32MsgCallback)(const MSG &msg);
00045 
00046 class LLWindowWin32 : 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() const;
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*/     BOOL dialog_color_picker (F32 *r, F32 *g, F32 *b );
00107 
00108         /*virtual*/ void *getPlatformWindow();
00109         /*virtual*/ void bringToFront();
00110         /*virtual*/ void focusClient();
00111 
00112         /*virtual*/ void allowLanguageTextInput(BOOL b);
00113         /*virtual*/ void setLanguageTextInput( const LLCoordGL & pos );
00114 
00115 protected:
00116         LLWindowWin32(
00117                 char *title, char *name, int x, int y, int width, int height, U32 flags, 
00118                 BOOL fullscreen, BOOL clearBg, BOOL disable_vsync, BOOL use_gl,
00119                 BOOL ignore_pixel_depth, S32 stereo_mode);
00120         ~LLWindowWin32();
00121 
00122         void    initCursors();
00123         HCURSOR loadColorCursor(LPCTSTR name);
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         BOOL    getClientRectInScreenSpace(RECT* rectp);
00149         void    updateJoystick( );
00150 
00151         static LRESULT CALLBACK mainWindowProc(HWND h_wnd, UINT u_msg, WPARAM w_param, LPARAM l_param);
00152         static BOOL CALLBACK enumChildWindows(HWND h_wnd, LPARAM l_param);
00153 
00154 
00155         //
00156         // Platform specific variables
00157         //
00158         WCHAR           *mWindowTitle;
00159         WCHAR           *mWindowClassName;
00160 
00161         HWND            mWindowHandle;  // window handle
00162         HGLRC           mhRC;                   // OpenGL rendering context
00163         HDC                     mhDC;                   // Windows Device context handle
00164         HINSTANCE       mhInstance;             // handle to application instance
00165         WNDPROC         mWndProc;               // user-installable window proc
00166         RECT            mOldMouseClip;  // Screen rect to which the mouse cursor was globally constrained before we changed it in clipMouse()
00167         WPARAM          mLastSizeWParam;
00168         F32                     mOverrideAspectRatio;
00169         F32                     mNativeAspectRatio;
00170 
00171         HCURSOR         mCursor[ UI_CURSOR_COUNT ];  // Array of all mouse cursors
00172 
00173         static BOOL sIsClassRegistered; // has the window class been registered?
00174 
00175         F32                     mCurrentGamma;
00176         WORD            mPrevGammaRamp[256*3];
00177         WORD            mCurrentGammaRamp[256*3];
00178 
00179         LPWSTR          mIconResource;
00180         BOOL            mMousePositionModified;
00181         BOOL            mInputProcessingPaused;
00182 
00183         // The following variables are for Language Text Input control.
00184         // They are all static, since one context is shared by all LLWindowWin32
00185         // instances.
00186         static BOOL             sLanguageTextInputAllowed;
00187         static BOOL             sWinIMEOpened;
00188         static HKL              sWinInputLocale;
00189         static DWORD    sWinIMEConversionMode;
00190         static DWORD    sWinIMESentenceMode;
00191 
00192         friend class LLWindowManager;
00193 };
00194 
00195 class LLSplashScreenWin32 : public LLSplashScreen
00196 {
00197 public:
00198         LLSplashScreenWin32();
00199         virtual ~LLSplashScreenWin32();
00200 
00201         /*virtual*/ void showImpl();
00202         /*virtual*/ void updateImpl(const char* mesg);
00203         /*virtual*/ void hideImpl();
00204 
00205 #if LL_WINDOWS
00206         static LRESULT CALLBACK windowProc(HWND h_wnd, UINT u_msg, 
00207                 WPARAM w_param, LPARAM l_param);
00208 #endif
00209 
00210 private:
00211 #if LL_WINDOWS
00212         HWND mWindow;
00213 #endif
00214 };
00215 
00216 extern LLW32MsgCallback gAsyncMsgCallback;
00217 extern LPWSTR gIconResource;
00218 
00219 static void     handleMessage( const MSG& msg );
00220 
00221 S32 OSMessageBoxWin32(const char* text, const char* caption, U32 type);
00222 
00223 #endif //LL_LLWINDOWWIN32_H

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