CentreOnParent() didn't work at all for top level windows

on top level windows.


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_2_BRANCH@7111 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Robert Roebling
2000-04-11 10:26:16 +00:00
parent df9b4349d5
commit 48f1ed8cf1

View File

@@ -337,8 +337,16 @@ void wxWindowBase::Centre(int direction)
} }
else else
{ {
// centre inside the parents rectangle if (IsTopLevel())
parent->GetClientSize(&widthParent, &heightParent); {
// centre on the parent
parent->GetSize(&widthParent, &heightParent);
}
else
{
// centre inside the parents client rectangle
parent->GetClientSize(&widthParent, &heightParent);
}
} }
int width, height; int width, height;
@@ -361,8 +369,17 @@ void wxWindowBase::Centre(int direction)
// without parent which shouldn't happen // without parent which shouldn't happen
wxCHECK_RET( parent, wxT("this window must have a parent") ); wxCHECK_RET( parent, wxT("this window must have a parent") );
// adjust to the parents client area origin wxPoint posParent;
wxPoint posParent = parent->ClientToScreen(wxPoint(0, 0)); if (IsTopLevel())
{
// adjust to the parents position
posParent = parent->GetPosition();
}
else
{
// adjust to the parents client area origin
posParent = parent->ClientToScreen(wxPoint(0, 0));
}
xNew += posParent.x; xNew += posParent.x;
yNew += posParent.y; yNew += posParent.y;