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
This commit is contained in:
Vadim Zeitlin
2004-07-25 15:03:13 +00:00
parent 4524a24b40
commit 10cbb81eda

View File

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