]> git.saurik.com Git - wxWidgets.git/blobdiff - src/msw/toplevel.cpp
added alpha channel support for mask bitmaps
[wxWidgets.git] / src / msw / toplevel.cpp
index 4758fd9a52143c5591471749f2435d02fc828248..7e827494bde7718f7d6e1dee771fbeef497052e7 100644 (file)
@@ -42,7 +42,7 @@
 
 #include "wx/msw/private.h"
 
 
 #include "wx/msw/private.h"
 
-#include "wx/popupwin.h"
+#include "wx/display.h"
 
 #ifndef ICON_BIG
     #define ICON_BIG 1
 
 #ifndef ICON_BIG
     #define ICON_BIG 1
@@ -414,6 +414,8 @@ bool wxTopLevelWindowMSW::Create(wxWindow *parent,
                                  long style,
                                  const wxString& name)
 {
                                  long style,
                                  const wxString& name)
 {
+    bool ret = false;
+
     // init our fields
     Init();
 
     // init our fields
     Init();
 
@@ -458,15 +460,20 @@ bool wxTopLevelWindowMSW::Create(wxWindow *parent,
         if ( style & (wxRESIZE_BORDER | wxCAPTION) )
             dlgTemplate->style |= DS_MODALFRAME;
 
         if ( style & (wxRESIZE_BORDER | wxCAPTION) )
             dlgTemplate->style |= DS_MODALFRAME;
 
-        bool ret = CreateDialog(dlgTemplate, title, pos, size);
+        ret = CreateDialog(dlgTemplate, title, pos, size);
         free(dlgTemplate);
         free(dlgTemplate);
-
-        return ret;
     }
     else // !dialog
     {
     }
     else // !dialog
     {
-        return CreateFrame(title, pos, size);
+        ret = CreateFrame(title, pos, size);
+    }
+
+    if ( ret && !(GetWindowStyleFlag() & wxCLOSE_BOX) )
+    {
+        EnableCloseButton(false);
     }
     }
+
+    return ret;
 }
 
 wxTopLevelWindowMSW::~wxTopLevelWindowMSW()
 }
 
 wxTopLevelWindowMSW::~wxTopLevelWindowMSW()
@@ -600,18 +607,22 @@ void wxTopLevelWindowMSW::Restore()
 
 bool wxTopLevelWindowMSW::ShowFullScreen(bool show, long style)
 {
 
 bool wxTopLevelWindowMSW::ShowFullScreen(bool show, long style)
 {
-    if (show)
+    if ( show == IsFullScreen() )
     {
     {
-        if (IsFullScreen())
-            return FALSE;
+        // nothing to do
+        return TRUE;
+    }
+
+    m_fsIsShowing = show;
 
 
-        m_fsIsShowing = TRUE;
+    if ( show )
+    {
         m_fsStyle = style;
 
         // zap the frame borders
 
         // save the 'normal' window style
         m_fsStyle = style;
 
         // zap the frame borders
 
         // save the 'normal' window style
-        m_fsOldWindowStyle = GetWindowLong((HWND)GetHWND(), GWL_STYLE);
+        m_fsOldWindowStyle = GetWindowLong(GetHwnd(), GWL_STYLE);
 
         // save the old position, width & height, maximize state
         m_fsOldSize = GetRect();
 
         // save the old position, width & height, maximize state
         m_fsOldSize = GetRect();
@@ -624,44 +635,64 @@ bool wxTopLevelWindowMSW::ShowFullScreen(bool show, long style)
         if (style & wxFULLSCREEN_NOBORDER)
             offFlags |= WS_BORDER | WS_THICKFRAME;
         if (style & wxFULLSCREEN_NOCAPTION)
         if (style & wxFULLSCREEN_NOBORDER)
             offFlags |= WS_BORDER | WS_THICKFRAME;
         if (style & wxFULLSCREEN_NOCAPTION)
-            offFlags |= (WS_CAPTION | WS_SYSMENU);
+            offFlags |= WS_CAPTION | WS_SYSMENU;
 
 
-        newStyle &= (~offFlags);
+        newStyle &= ~offFlags;
 
         // change our window style to be compatible with full-screen mode
 
         // change our window style to be compatible with full-screen mode
-        ::SetWindowLong((HWND)GetHWND(), GWL_STYLE, newStyle);
+        ::SetWindowLong(GetHwnd(), GWL_STYLE, newStyle);
 
 
-        // resize to the size of the desktop
-        int width, height;
-
-        RECT rect = wxGetWindowRect(::GetDesktopWindow());
-        width = rect.right - rect.left;
-        height = rect.bottom - rect.top;
+        wxRect rect;
+#if wxUSE_DISPLAY
+        // resize to the size of the display containing us
+        int dpy = wxDisplay::GetFromWindow(this);
+        if ( dpy != wxNOT_FOUND )
+        {
+            rect = wxDisplay(dpy).GetGeometry();
+        }
+        else // fall back to the main desktop
+#else // wxUSE_DISPLAY
+        {
+            // resize to the size of the desktop
+            wxCopyRECTToRect(wxGetWindowRect(::GetDesktopWindow()), rect);
+        }
+#endif // wxUSE_DISPLAY
 
 
-        SetSize(width, height);
+        SetSize(rect);
 
         // now flush the window style cache and actually go full-screen
 
         // now flush the window style cache and actually go full-screen
-        SetWindowPos((HWND)GetHWND(), HWND_TOP, 0, 0, width, height, SWP_FRAMECHANGED);
+        long flags = SWP_FRAMECHANGED;
 
 
-        wxSizeEvent event(wxSize(width, height), GetId());
-        GetEventHandler()->ProcessEvent(event);
+        // showing the frame full screen should also show it if it's still
+        // hidden
+        if ( !IsShown() )
+        {
+            // don't call wxWindow version to avoid flicker from calling
+            // ::ShowWindow() -- we're going to show the window at the correct
+            // location directly below -- but do call the wxWindowBase version
+            // to sync the internal m_isShown flag
+            wxWindowBase::Show();
 
 
-        return TRUE;
-    }
-    else
-    {
-        if (!IsFullScreen())
-            return FALSE;
+            flags |= SWP_SHOWWINDOW;
+        }
 
 
-        m_fsIsShowing = FALSE;
+        SetWindowPos(GetHwnd(), HWND_TOP,
+                     rect.x, rect.y, rect.width, rect.height,
+                     flags);
 
 
+        // finally send an event allowing the window to relayout itself &c
+        wxSizeEvent event(rect.GetSize(), GetId());
+        GetEventHandler()->ProcessEvent(event);
+    }
+    else // stop showing full screen
+    {
         Maximize(m_fsIsMaximized);
         Maximize(m_fsIsMaximized);
-        SetWindowLong((HWND)GetHWND(),GWL_STYLE, m_fsOldWindowStyle);
-        SetWindowPos((HWND)GetHWND(),HWND_TOP,m_fsOldSize.x, m_fsOldSize.y,
+        SetWindowLong(GetHwnd(),GWL_STYLE, m_fsOldWindowStyle);
+        SetWindowPos(GetHwnd(),HWND_TOP,m_fsOldSize.x, m_fsOldSize.y,
             m_fsOldSize.width, m_fsOldSize.height, SWP_FRAMECHANGED);
             m_fsOldSize.width, m_fsOldSize.height, SWP_FRAMECHANGED);
-
-        return TRUE;
     }
     }
+
+    return TRUE;
 }
 
 // ----------------------------------------------------------------------------
 }
 
 // ----------------------------------------------------------------------------