\membersection{wxSizer::Fit}\label{wxsizerfit}
-\func{void}{Fit}{\param{wxWindow* }{window}}
+\func{wxSize}{Fit}{\param{wxWindow* }{window}}
Tell the sizer to resize the {\it window} to match the sizer's minimal size. This
is commonly done in the constructor of the window itself, see sample in the description
-of \helpref{wxBoxSizer}{wxboxsizer}.
+of \helpref{wxBoxSizer}{wxboxsizer}. Returns the new size.
\membersection{wxSizer::FitInside}\label{wxsizerfitinside}
0, // make vertically unstretchable
wxALIGN_CENTER ); // no border and centre horizontally
- SetAutoLayout( TRUE ); // tell dialog to use sizer
- SetSizer( topsizer ); // actually set the sizer
+ SetSizer( topsizer ); // use the sizer for layout
- topsizer->Fit( this ); // set size to minimum size as calculated by the sizer
topsizer->SetSizeHints( this ); // set size hints to honour minimum size
}
\end{verbatim}
\func{void}{SetAutoLayout}{\param{bool}{ autoLayout}}
Determines whether the \helpref{wxWindow::Layout}{wxwindowlayout} function will
-be called automatically when the window is resized. Use in connection with
-\helpref{wxWindow::SetSizer}{wxwindowsetsizer} and
-\helpref{wxWindow::SetConstraints}{wxwindowsetconstraints} for laying out
-subwindows.
+be called automatically when the window is resized. It is called implicitly by
+\helpref{wxWindow::SetSizer}{wxwindowsetsizer} but if you use
+\helpref{wxWindow::SetConstraints}{wxwindowsetconstraints} you should call it
+manually or otherwise the window layout won't be correctly updated when its
+size changes.
\wxheading{Parameters}
If an existing layout constraints object is already owned by the
window, it will be deleted if the deleteOld parameter is TRUE.
+Note that this function will also call
+\helpref{SetAutoLayout}{wxwindowsetautolayout} implicitly with {\tt TRUE}
+parameter if the {\it sizer}\/ is non-NULL and {\tt FALSE} otherwise.
+
\wxheading{Parameters}
\docparam{sizer}{The sizer to set. Pass NULL to disassociate and conditionally delete
virtual void Layout();
- void Fit( wxWindow *window );
+ wxSize Fit( wxWindow *window );
void FitInside( wxWindow *window );
void SetSizeHints( wxWindow *window );
void SetVirtualSizeHints( wxWindow *window );
}
}
-void wxSizer::Fit( wxWindow *window )
+wxSize wxSizer::Fit( wxWindow *window )
{
wxSize size;
if (window->IsTopLevel())
else
size = GetMinWindowSize( window );
- //window->SetClientSize( size );
window->SetSize( size );
+
+ return size;
}
void wxSizer::FitInside( wxWindow *window )
// Preserve the window's max size hints, but set the
// lower bound according to the sizer calculations.
- Fit( window );
- wxSize size( window->GetSize() );
+ wxSize size = Fit( window );
+
window->SetSizeHints( size.x,
size.y,
window->GetMaxWidth(),