]> git.saurik.com Git - wxWidgets.git/commitdiff
maximize the window to the correct display (i.e. the one it is currently on); ShowFul...
authorVadim Zeitlin <vadim@wxwidgets.org>
Sun, 2 Mar 2003 14:24:34 +0000 (14:24 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Sun, 2 Mar 2003 14:24:34 +0000 (14:24 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@19421 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

docs/latex/wx/frame.tex
src/msw/toplevel.cpp

index 34823f2d60eeaaf7b99942af2c2f0b1774a605ba..e351ee10dce7534d2a1c5b4848cfe0d77a3c7d93 100644 (file)
@@ -612,9 +612,10 @@ Sets the frame title.
 
 \func{bool}{ShowFullScreen}{\param{bool}{ show}, \param{long}{ style = wxFULLSCREEN\_ALL}}
 
-Passing true to {\it shows} shows the frame full-screen, and passing false restores the frame
-again. {\it style} is a bit list containing some or all of the following values, which
-indicate what elements of the frame to hide in full-screen mode:
+Depending on the value of {\it show} parameter the frame is either shown full
+screen or restored to its normal state. {\it style} is a bit list containing
+some or all of the following values, which indicate what elements of the frame
+to hide in full-screen mode:
 
 \begin{itemize}\itemsep=0pt
 \item wxFULLSCREEN\_NOMENUBAR
@@ -627,6 +628,9 @@ indicate what elements of the frame to hide in full-screen mode:
 
 This function has not been tested with MDI frames.
 
+Note that showing a frame full screen also actually 
+\helpref{Show()s}{wxwindowshow} if it hadn't been shown yet.
+
 \wxheading{See also}
 
 \helpref{wxFrame::IsFullScreen}{wxframeisfullscreen}
index 4758fd9a52143c5591471749f2435d02fc828248..96320bcfefb0ca79fd4081ac82b2685484ea23ba 100644 (file)
@@ -42,7 +42,7 @@
 
 #include "wx/msw/private.h"
 
-#include "wx/popupwin.h"
+#include "wx/display.h"
 
 #ifndef ICON_BIG
     #define ICON_BIG 1
@@ -600,18 +600,22 @@ void wxTopLevelWindowMSW::Restore()
 
 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_fsOldWindowStyle = GetWindowLong((HWND)GetHWND(), GWL_STYLE);
+        m_fsOldWindowStyle = GetWindowLong(GetHwnd(), GWL_STYLE);
 
         // save the old position, width & height, maximize state
         m_fsOldSize = GetRect();
@@ -624,44 +628,64 @@ bool wxTopLevelWindowMSW::ShowFullScreen(bool show, long style)
         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
-        ::SetWindowLong((HWND)GetHWND(), GWL_STYLE, newStyle);
-
-        // resize to the size of the desktop
-        int width, height;
+        ::SetWindowLong(GetHwnd(), GWL_STYLE, newStyle);
 
-        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
-        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);
-        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);
-
-        return TRUE;
     }
+
+    return TRUE;
 }
 
 // ----------------------------------------------------------------------------