Added wxWindowBase::CentreOnParent to allow top level windows to be

centered over their parent (if they have one) instead of the entire
screen.


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@2754 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Robin Dunn
1999-06-10 22:44:50 +00:00
parent 7e2c43b855
commit 7631a29204
3 changed files with 61 additions and 3 deletions

View File

@@ -316,6 +316,34 @@ void wxWindowBase::Centre(int direction)
Move(new_x, new_y);
}
// Center TopLevel windows over thier parent instead of the whole screen
void wxWindowBase::CentreOnParent(int direction)
{
wxPoint ppos;
wxSize psze;
wxSize wsze;
wxWindow* parent = GetParent();
int x, y;
if (!parent || !IsTopLevel()) {
Centre(direction);
return;
}
psze = parent->GetSize();
ppos = parent->ClientToScreen(wxPoint(0,0));
wsze = GetSize();
x = y = -1;
if (direction == wxBOTH || direction == wxHORIZONTAL)
x = ppos.x + (psze.x - wsze.x)/2;
if (direction == wxBOTH || direction == wxVERTICAL)
y = ppos.y + (psze.y - wsze.y)/2;
Move(x, y);
}
// fits the window around the children
void wxWindowBase::Fit()
{