A synonym for \helpref{Centre}{wxwindowcentre}.
+\membersection{wxWindow::CenterOnParent}\label{wxwindowcenteronparent}
+
+\func{void}{CenterOnParent}{\param{int}{ direction}}
+
+A synonym for \helpref{CentreOnParent}{wxwindowcentreonparent}.
+
\membersection{wxWindow::Centre}\label{wxwindowcentre}
-\func{virtual void}{Centre}{\param{int}{ direction = wxHORIZONTAL}}
+\func{void}{Centre}{\param{int}{ direction = wxHORIZONTAL}}
Centres the window.
\helpref{wxWindow::Center}{wxwindowcenter}
+\membersection{wxWindow::CentreOnParent}\label{wxwindowcentreonparent}
+
+\func{void}{CentreOnParent}{\param{int}{ direction = wxHORIZONTAL}}
+
+Centres the window.
+
+\wxheading{Parameters}
+
+\docparam{direction}{Specifies the direction for the centering. May be {\tt wxHORIZONTAL}, {\tt wxVERTICAL}\rtfsp
+or {\tt wxBOTH}.}
+
+\wxheading{Remarks}
+
+This methods provides for a way to center top level windows over their
+parents instead of the entire screen. If there is no parent or if the
+window is not a top level window, then behaviour is the same as
+\helpref{wxWindow::Centre}{wxwindowcentre}.
+
+\wxheading{See also}
+
+\helpref{wxWindow::CenterOnParent}{wxwindowcenteronparent}
+
\membersection{wxWindow::Clear}\label{wxwindowclear}
\func{void}{Clear}{\void}
\constfunc{long}{GetWindowStyleFlag}{\void}
-Gets the window style that was passed to the consructor or {\bf Create} member.
+Gets the window style that was passed to the consructor or {\bf Create} member.
{\bf GetWindowStyle} is synonymous.
\membersection{wxWindow::InitDialog}\label{wxwindowinitdialog}
\func{void}{Layout}{\void}
-Invokes the constraint-based layout algorithm for this window.
+Invokes the constraint-based layout algorithm for this window.
See \helpref{wxWindow::SetAutoLayout}{wxwindowsetautolayout} on when
this function gets called automatically using auto layout.
// centre with respect to the the parent window
void Centre( int direction = wxHORIZONTAL );
void Center( int direction = wxHORIZONTAL ) { Centre(direction); }
+ void CentreOnParent(int direction = wxHORIZONTAL );
+ void CenterOnParent(int direction = wxHORIZONTAL ) { CentreOnParent(direction); }
// set window size to wrap around its children
virtual void Fit();
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()
{