00001 
00032 #ifndef LL_LLWINDOWWIN32_H
00033 #define LL_LLWINDOWWIN32_H
00034 
00035 
00036 #define WIN32_LEAN_AND_MEAN
00037 #include <winsock2.h>
00038 #include <windows.h>
00039 
00040 #include "llwindow.h"
00041 
00042 
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          void show();
00050          void hide();
00051          void close();
00052          BOOL getVisible();
00053          BOOL getMinimized();
00054          BOOL getMaximized();
00055          BOOL maximize();
00056          BOOL getFullscreen();
00057          BOOL getPosition(LLCoordScreen *position);
00058          BOOL getSize(LLCoordScreen *size);
00059          BOOL getSize(LLCoordWindow *size);
00060          BOOL setPosition(LLCoordScreen position);
00061          BOOL setSize(LLCoordScreen size);
00062          BOOL switchContext(BOOL fullscreen, LLCoordScreen size, BOOL disable_vsync);
00063          BOOL setCursorPosition(LLCoordWindow position);
00064          BOOL getCursorPosition(LLCoordWindow *position);
00065          void showCursor();
00066          void hideCursor();
00067          void showCursorFromMouseMove();
00068          void hideCursorUntilMouseMove();
00069          BOOL isCursorHidden();
00070          void setCursor(ECursorType cursor);
00071          ECursorType getCursor() const;
00072          void captureMouse();
00073          void releaseMouse();
00074          void setMouseClipping( BOOL b );
00075          BOOL isClipboardTextAvailable();
00076          BOOL pasteTextFromClipboard(LLWString &dst);
00077          BOOL copyTextToClipboard(const LLWString &src);
00078          void flashIcon(F32 seconds);
00079          F32 getGamma();
00080          BOOL setGamma(const F32 gamma); 
00081          BOOL restoreGamma();                        
00082          ESwapMethod getSwapMethod() { return mSwapMethod; }
00083          void gatherInput();
00084          void delayInputProcessing();
00085          void swapBuffers();
00086 
00087          LLString getTempFileName();
00088          void deleteFile( const char* file_name );
00089          S32 stat( const char* file_name, struct stat* stat_info );
00090          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         
00094          BOOL convertCoords(LLCoordScreen from, LLCoordWindow *to);
00095          BOOL convertCoords(LLCoordWindow from, LLCoordScreen *to);
00096          BOOL convertCoords(LLCoordWindow from, LLCoordGL *to);
00097          BOOL convertCoords(LLCoordGL from, LLCoordWindow *to);
00098          BOOL convertCoords(LLCoordScreen from, LLCoordGL *to);
00099          BOOL convertCoords(LLCoordGL from, LLCoordScreen *to);
00100 
00101          LLWindowResolution* getSupportedResolutions(S32 &num_resolutions);
00102          F32 getNativeAspectRatio();
00103          F32 getPixelAspectRatio();
00104          void setNativeAspectRatio(F32 ratio) { mOverrideAspectRatio = ratio; }
00105 
00106              BOOL dialog_color_picker (F32 *r, F32 *g, F32 *b );
00107 
00108          void *getPlatformWindow();
00109          void bringToFront();
00110          void focusClient();
00111 
00112          void allowLanguageTextInput(BOOL b);
00113          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         
00129         BOOL    setDisplayResolution(S32 width, S32 height, S32 bits, S32 refresh);
00130 
00131         
00132         BOOL    setFullscreenResolution();
00133 
00134         
00135         BOOL    resetDisplayResolution();
00136 
00137         void    minimize();
00138         void    restore();
00139 
00140         BOOL    shouldPostQuit() { return mPostQuit; }
00141 
00142 
00143 protected:
00144         
00145         
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         
00157         
00158         WCHAR           *mWindowTitle;
00159         WCHAR           *mWindowClassName;
00160 
00161         HWND            mWindowHandle;  
00162         HGLRC           mhRC;                   
00163         HDC                     mhDC;                   
00164         HINSTANCE       mhInstance;             
00165         WNDPROC         mWndProc;               
00166         RECT            mOldMouseClip;  
00167         WPARAM          mLastSizeWParam;
00168         F32                     mOverrideAspectRatio;
00169         F32                     mNativeAspectRatio;
00170 
00171         HCURSOR         mCursor[ UI_CURSOR_COUNT ];  
00172 
00173         static BOOL sIsClassRegistered; 
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         
00184         
00185         
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          void showImpl();
00202          void updateImpl(const char* mesg);
00203          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