]> git.saurik.com Git - wxWidgets.git/commitdiff
corrected Center() for cases when client display rect origin is not at (0, 0) (patch...
authorVadim Zeitlin <vadim@wxwidgets.org>
Sun, 25 Jul 2004 15:03:13 +0000 (15:03 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Sun, 25 Jul 2004 15:03:13 +0000 (15:03 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@28470 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

src/common/wincmn.cpp

index afcb8f96707a2599fe3617dd51945134fec76237..aa5c6d38653702256dbc393c32cb3fcf7bf338aa 100644 (file)
@@ -451,9 +451,8 @@ void wxWindowBase::Centre(int direction)
     yNew += posParent.y;
 
     // Base size of the visible dimensions of the display
-    // to take into account the taskbar
-    wxRect rect = wxGetClientDisplayRect();
-    wxSize size (rect.width,rect.height);
+    // to take into account the taskbar. And the Mac menu bar at top.
+    wxRect clientrect = wxGetClientDisplayRect();
 
     // NB: in wxMSW, negative position may not neccessary mean "out of screen",
     //     but it may mean that the window is placed on other than the main
@@ -461,21 +460,21 @@ void wxWindowBase::Centre(int direction)
     //     if the parent is at least partially present here.
     if (posParent.x + widthParent >= 0)  // if parent is (partially) on the main display
     {
-        if (xNew < 0)
-            xNew = 0;
-        else if (xNew+width > size.x)
-            xNew = size.x-width-1;
+        if (xNew < clientrect.GetLeft())
+            xNew = clientrect.GetLeft();
+        else if (xNew + width > clientrect.GetRight())
+            xNew = clientrect.GetRight() - width;
     }
     if (posParent.y + heightParent >= 0)  // if parent is (partially) on the main display
     {
-        if (yNew+height > size.y)
-            yNew = size.y-height-1;
+        if (yNew + height > clientrect.GetBottom())
+            yNew = clientrect.GetBottom() - height;
 
         // Make certain that the title bar is initially visible
         // always, even if this would push the bottom of the
-        // dialog of the visible area of the display
-        if (yNew < 0)
-            yNew = 0;
+        // dialog off the visible area of the display
+        if (yNew < clientrect.GetTop())
+            yNew = clientrect.GetTop();
     }
 
     // move the window to this position (keeping the old size but using