* also distinguish between maximised and fullscreen on GHOST win32.
[blender-staging.git] / intern / ghost / intern / GHOST_WindowWin32.cpp
index 8e0858b118390bad48824963f4b3f36deb1eb9d3..81a6c89a433e23abaeb105c645165d5044746ecf 100644 (file)
 #include <GL/gl.h>
 #include <math.h>
 
+// MSVC6 still doesn't define M_PI
+#ifndef M_PI
+#define M_PI 3.1415926536
+#endif
+
 LPCSTR GHOST_WindowWin32::s_windowClassName = "GHOST_WindowClass";
 const int GHOST_WindowWin32::s_maxTitleLength = 128;
 HGLRC GHOST_WindowWin32::s_firsthGLRc = NULL;
@@ -140,7 +145,7 @@ GHOST_WindowWin32::GHOST_WindowWin32(
        }
        if (m_hWnd) {
                // Store a pointer to this class in the window structure
-               LONG result = ::SetWindowLong(m_hWnd, GWL_USERDATA, (LONG)this);
+               ::SetWindowLongPtr(m_hWnd, GWL_USERDATA, (LONG_PTR)this);
 
                // Store the device context
                m_hDC = ::GetDC(m_hWnd);
@@ -212,11 +217,6 @@ GHOST_WindowWin32::GHOST_WindowWin32(
                                }
                        }
 
-                       lc.lcInOrgX = 0;
-                       lc.lcInOrgY = 0;
-                       lc.lcInExtX = TabletX.axMax;
-                       lc.lcInExtY = TabletY.axMax;
-
                        if (fpWTOpen) {
                                m_tablet = fpWTOpen( m_hWnd, &lc, TRUE );
                                if (m_tablet) {
@@ -292,11 +292,20 @@ void GHOST_WindowWin32::getWindowBounds(GHOST_Rect& bounds) const
 void GHOST_WindowWin32::getClientBounds(GHOST_Rect& bounds) const
 {
        RECT rect;
-       ::GetClientRect(m_hWnd, &rect);
-       bounds.m_b = rect.bottom;
-       bounds.m_l = rect.left;
-       bounds.m_r = rect.right;
-       bounds.m_t = rect.top;
+       ::GetWindowRect(m_hWnd, &rect);
+
+       LONG_PTR result = ::GetWindowLongPtr(m_hWnd, GWL_STYLE);
+       if((result & (WS_POPUP | WS_MAXIMIZE)) != (WS_POPUP | WS_MAXIMIZE)) {
+               bounds.m_b = rect.bottom-GetSystemMetrics(SM_CYCAPTION)-GetSystemMetrics(SM_CYSIZEFRAME)*2;
+               bounds.m_l = rect.left;
+               bounds.m_r = rect.right-GetSystemMetrics(SM_CYSIZEFRAME)*2;
+               bounds.m_t = rect.top;
+       } else {
+               bounds.m_b = rect.bottom;
+               bounds.m_l = rect.left;
+               bounds.m_r = rect.right;
+               bounds.m_t = rect.top;
+       }
 }
 
 
@@ -364,7 +373,11 @@ GHOST_TWindowState GHOST_WindowWin32::getState() const
                state = GHOST_kWindowStateMinimized;
        }
        else if (::IsZoomed(m_hWnd)) {
-               state = GHOST_kWindowStateMaximized;
+               LONG_PTR result = ::GetWindowLongPtr(m_hWnd, GWL_STYLE);
+               if((result & (WS_POPUP | WS_MAXIMIZE)) != (WS_POPUP | WS_MAXIMIZE))
+                       state = GHOST_kWindowStateMaximized;
+               else
+                       state = GHOST_kWindowStateFullScreen;
        }
        else {
                state = GHOST_kWindowStateNormal;
@@ -405,11 +418,11 @@ GHOST_TSuccess GHOST_WindowWin32::setState(GHOST_TWindowState state)
                                //Solves redraw problems when switching from fullscreen to normal.
                                
                wp.showCmd = SW_SHOWMAXIMIZED; 
-               SetWindowLong(m_hWnd, GWL_STYLE, WS_OVERLAPPEDWINDOW);
+               SetWindowLongPtr(m_hWnd, GWL_STYLE, WS_OVERLAPPEDWINDOW);
                break;
        case GHOST_kWindowStateFullScreen:
                wp.showCmd = SW_SHOWMAXIMIZED;
-               SetWindowLong(m_hWnd, GWL_STYLE, WS_POPUP | WS_MAXIMIZE);
+               SetWindowLongPtr(m_hWnd, GWL_STYLE, WS_POPUP | WS_MAXIMIZE);
                break;
        case GHOST_kWindowStateNormal: 
        default: 
@@ -613,7 +626,7 @@ void GHOST_WindowWin32::loadCursor(bool visible, GHOST_TStandardCursor cursor) c
                }
                
                if (success) {
-                       HCURSOR hCursor = ::SetCursor(::LoadCursor(0, id));
+                       ::SetCursor(::LoadCursor(0, id));
                }
        }
 }
@@ -853,7 +866,7 @@ static int WeightPixelFormat(PIXELFORMATDESCRIPTOR& pfd) {
 static int EnumPixelFormats(HDC hdc) {
        int iPixelFormat;
        int i, n, w, weight = 0;
-       PIXELFORMATDESCRIPTOR pfd, pfd_fallback;
+       PIXELFORMATDESCRIPTOR pfd;
        
        /* we need a device context to do anything */
        if(!hdc) return 0;