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, const LLCoordScreen &size, BOOL disable_vsync, const LLCoordScreen * const posp = NULL);
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*/ void setFSAASamples(const U32 fsaa_samples);
00082         /*virtual*/ U32 getFSAASamples();
00083         /*virtual*/ BOOL restoreGamma();                        // Restore original gamma table (before updating gamma)
00084         /*virtual*/ ESwapMethod getSwapMethod() { return mSwapMethod; }
00085         /*virtual*/ void gatherInput();
00086         /*virtual*/ void delayInputProcessing();
00087         /*virtual*/ void swapBuffers();
00088 
00089         /*virtual*/ LLString getTempFileName();
00090         /*virtual*/ void deleteFile( const char* file_name );
00091         /*virtual*/ S32 stat( const char* file_name, struct stat* stat_info );
00092         /*virtual*/ BOOL sendEmail(const char* address,const char* subject,const char* body_text,const char* attachment=NULL, const char* attachment_displayed_name=NULL);
00093 
00094 
00095         // handy coordinate space conversion routines
00096         /*virtual*/ BOOL convertCoords(LLCoordScreen from, LLCoordWindow *to);
00097         /*virtual*/ BOOL convertCoords(LLCoordWindow from, LLCoordScreen *to);
00098         /*virtual*/ BOOL convertCoords(LLCoordWindow from, LLCoordGL *to);
00099         /*virtual*/ BOOL convertCoords(LLCoordGL from, LLCoordWindow *to);
00100         /*virtual*/ BOOL convertCoords(LLCoordScreen from, LLCoordGL *to);
00101         /*virtual*/ BOOL convertCoords(LLCoordGL from, LLCoordScreen *to);
00102 
00103         /*virtual*/ LLWindowResolution* getSupportedResolutions(S32 &num_resolutions);
00104         /*virtual*/ F32 getNativeAspectRatio();
00105         /*virtual*/ F32 getPixelAspectRatio();
00106         /*virtual*/ void setNativeAspectRatio(F32 ratio) { mOverrideAspectRatio = ratio; }
00107 
00108         /*virtual*/     BOOL dialog_color_picker (F32 *r, F32 *g, F32 *b );
00109 
00110         /*virtual*/ void *getPlatformWindow();
00111         /*virtual*/ void bringToFront();
00112         /*virtual*/ void focusClient();
00113 
00114         /*virtual*/ void allowLanguageTextInput(LLPreeditor *preeditor, BOOL b);
00115         /*virtual*/ void setLanguageTextInput( const LLCoordGL & pos );
00116         /*virtual*/ void updateLanguageTextInputArea();
00117         /*virtual*/ void interruptLanguageTextInput();
00118 
00119         static std::string getFontListSans();
00120 
00121 protected:
00122         LLWindowWin32(
00123                 char *title, char *name, int x, int y, int width, int height, U32 flags, 
00124                 BOOL fullscreen, BOOL clearBg, BOOL disable_vsync, BOOL use_gl,
00125                 BOOL ignore_pixel_depth, U32 fsaa_samples);
00126         ~LLWindowWin32();
00127 
00128         void    initCursors();
00129         void    initInputDevices();
00130         HCURSOR loadColorCursor(LPCTSTR name);
00131         BOOL    isValid();
00132         void    moveWindow(const LLCoordScreen& position,const LLCoordScreen& size);
00133 
00134 
00135         // Changes display resolution. Returns true if successful
00136         BOOL    setDisplayResolution(S32 width, S32 height, S32 bits, S32 refresh);
00137 
00138         // Go back to last fullscreen display resolution.
00139         BOOL    setFullscreenResolution();
00140 
00141         // Restore the display resolution to its value before we ran the app.
00142         BOOL    resetDisplayResolution();
00143 
00144         void    minimize();
00145         void    restore();
00146 
00147         BOOL    shouldPostQuit() { return mPostQuit; }
00148 
00149         void    fillCompositionForm(const LLRect& bounds, COMPOSITIONFORM *form);
00150         void    fillCandidateForm(const LLCoordGL& caret, const LLRect& bounds, CANDIDATEFORM *form);
00151         void    fillCharPosition(const LLCoordGL& caret, const LLRect& bounds, const LLRect& control, IMECHARPOSITION *char_position);
00152         void    fillCompositionLogfont(LOGFONT *logfont);
00153         U32             fillReconvertString(const LLWString &text, S32 focus, S32 focus_length, RECONVERTSTRING *reconvert_string);
00154         void    handleStartCompositionMessage();
00155         void    handleCompositionMessage(U32 indexes);
00156         BOOL    handleImeRequests(U32 request, U32 param, LRESULT *result);
00157 
00158 protected:
00159         //
00160         // Platform specific methods
00161         //
00162 
00163         BOOL    getClientRectInScreenSpace(RECT* rectp);
00164         void    updateJoystick( );
00165 
00166         static LRESULT CALLBACK mainWindowProc(HWND h_wnd, UINT u_msg, WPARAM w_param, LPARAM l_param);
00167         static BOOL CALLBACK enumChildWindows(HWND h_wnd, LPARAM l_param);
00168 
00169 
00170         //
00171         // Platform specific variables
00172         //
00173         WCHAR           *mWindowTitle;
00174         WCHAR           *mWindowClassName;
00175 
00176         HWND            mWindowHandle;  // window handle
00177         HGLRC           mhRC;                   // OpenGL rendering context
00178         HDC                     mhDC;                   // Windows Device context handle
00179         HINSTANCE       mhInstance;             // handle to application instance
00180         WNDPROC         mWndProc;               // user-installable window proc
00181         RECT            mOldMouseClip;  // Screen rect to which the mouse cursor was globally constrained before we changed it in clipMouse()
00182         WPARAM          mLastSizeWParam;
00183         F32                     mOverrideAspectRatio;
00184         F32                     mNativeAspectRatio;
00185 
00186         HCURSOR         mCursor[ UI_CURSOR_COUNT ];  // Array of all mouse cursors
00187 
00188         static BOOL sIsClassRegistered; // has the window class been registered?
00189 
00190         F32                     mCurrentGamma;
00191         U32                     mFSAASamples;
00192         WORD            mPrevGammaRamp[256*3];
00193         WORD            mCurrentGammaRamp[256*3];
00194 
00195         LPWSTR          mIconResource;
00196         BOOL            mMousePositionModified;
00197         BOOL            mInputProcessingPaused;
00198 
00199         // The following variables are for Language Text Input control.
00200         // They are all static, since one context is shared by all LLWindowWin32
00201         // instances.
00202         static BOOL             sLanguageTextInputAllowed;
00203         static BOOL             sWinIMEOpened;
00204         static HKL              sWinInputLocale;
00205         static DWORD    sWinIMEConversionMode;
00206         static DWORD    sWinIMESentenceMode;
00207         static LLCoordWindow sWinIMEWindowPosition;
00208         LLCoordGL               mLanguageTextInputPointGL;
00209         LLRect                  mLanguageTextInputAreaGL;
00210 
00211         LLPreeditor             *mPreeditor;
00212 
00213         friend class LLWindowManager;
00214 };
00215 
00216 class LLSplashScreenWin32 : public LLSplashScreen
00217 {
00218 public:
00219         LLSplashScreenWin32();
00220         virtual ~LLSplashScreenWin32();
00221 
00222         /*virtual*/ void showImpl();
00223         /*virtual*/ void updateImpl(const char* mesg);
00224         /*virtual*/ void hideImpl();
00225 
00226 #if LL_WINDOWS
00227         static LRESULT CALLBACK windowProc(HWND h_wnd, UINT u_msg, 
00228                 WPARAM w_param, LPARAM l_param);
00229 #endif
00230 
00231 private:
00232 #if LL_WINDOWS
00233         HWND mWindow;
00234 #endif
00235 };
00236 
00237 extern LLW32MsgCallback gAsyncMsgCallback;
00238 extern LPWSTR gIconResource;
00239 
00240 static void     handleMessage( const MSG& msg );
00241 
00242 S32 OSMessageBoxWin32(const char* text, const char* caption, U32 type);
00243 
00244 #endif //LL_LLWINDOWWIN32_H

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