From 48f1ed8cf1df23dfe6d70380486c6a82f6aad80b Mon Sep 17 00:00:00 2001 From: Robert Roebling Date: Tue, 11 Apr 2000 10:26:16 +0000 Subject: [PATCH] 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 --- src/common/wincmn.cpp | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/src/common/wincmn.cpp b/src/common/wincmn.cpp index 0a8cdfaf9c..2cd6afe038 100644 --- a/src/common/wincmn.cpp +++ b/src/common/wincmn.cpp @@ -337,8 +337,16 @@ void wxWindowBase::Centre(int direction) } else { - // centre inside the parents rectangle - parent->GetClientSize(&widthParent, &heightParent); + if (IsTopLevel()) + { + // centre on the parent + parent->GetSize(&widthParent, &heightParent); + } + else + { + // centre inside the parents client rectangle + parent->GetClientSize(&widthParent, &heightParent); + } } int width, height; @@ -361,8 +369,17 @@ void wxWindowBase::Centre(int direction) // without parent which shouldn't happen wxCHECK_RET( parent, wxT("this window must have a parent") ); - // adjust to the parents client area origin - wxPoint posParent = parent->ClientToScreen(wxPoint(0, 0)); + wxPoint posParent; + 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; yNew += posParent.y;