From 10cbb81eda8caf834dc9a5552801ac9ce87e9de1 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sun, 25 Jul 2004 15:03:13 +0000 Subject: [PATCH] corrected Center() for cases when client display rect origin is not at (0, 0) (patch 973192) git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@28470 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/common/wincmn.cpp | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/src/common/wincmn.cpp b/src/common/wincmn.cpp index afcb8f9670..aa5c6d3865 100644 --- a/src/common/wincmn.cpp +++ b/src/common/wincmn.cpp @@ -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 -- 2.47.2