From e5251d4f78176837e2eb857fae246435207ccaf2 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Thu, 13 Jun 2002 20:21:20 +0000 Subject: [PATCH] fixes to the sizers behaviour necessary to make the log dialog work again (thanks to Dimitri) and a few updates to the docs after the recent changes git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@15828 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- docs/latex/wx/sizer.tex | 4 ++-- docs/latex/wx/tsizer.tex | 4 +--- docs/latex/wx/window.tex | 13 +++++++++---- include/wx/sizer.h | 2 +- src/common/sizer.cpp | 9 +++++---- 5 files changed, 18 insertions(+), 14 deletions(-) diff --git a/docs/latex/wx/sizer.tex b/docs/latex/wx/sizer.tex index 0c5586bf06..e052026c43 100644 --- a/docs/latex/wx/sizer.tex +++ b/docs/latex/wx/sizer.tex @@ -125,11 +125,11 @@ Here, the sizer will do the actual calculation of its children minimal sizes. \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} diff --git a/docs/latex/wx/tsizer.tex b/docs/latex/wx/tsizer.tex index dd32bf4bd8..4f60169188 100644 --- a/docs/latex/wx/tsizer.tex +++ b/docs/latex/wx/tsizer.tex @@ -252,10 +252,8 @@ MyDialog::MyDialog(wxFrame *parent, wxWindowID id, const wxString &title ) 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} diff --git a/docs/latex/wx/window.tex b/docs/latex/wx/window.tex index fb3a4c3fba..1c7e69c99a 100644 --- a/docs/latex/wx/window.tex +++ b/docs/latex/wx/window.tex @@ -1914,10 +1914,11 @@ Sets the accelerator table for this window. See \helpref{wxAcceleratorTable}{wxa \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} @@ -2481,6 +2482,10 @@ will then own the object, and will take care of its deletion. 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 diff --git a/include/wx/sizer.h b/include/wx/sizer.h index d406d059b6..76b3f14090 100644 --- a/include/wx/sizer.h +++ b/include/wx/sizer.h @@ -184,7 +184,7 @@ public: virtual void Layout(); - void Fit( wxWindow *window ); + wxSize Fit( wxWindow *window ); void FitInside( wxWindow *window ); void SetSizeHints( wxWindow *window ); void SetVirtualSizeHints( wxWindow *window ); diff --git a/src/common/sizer.cpp b/src/common/sizer.cpp index 678dd70433..125f342b32 100644 --- a/src/common/sizer.cpp +++ b/src/common/sizer.cpp @@ -400,7 +400,7 @@ void wxSizer::DeleteWindows() } } -void wxSizer::Fit( wxWindow *window ) +wxSize wxSizer::Fit( wxWindow *window ) { wxSize size; if (window->IsTopLevel()) @@ -408,8 +408,9 @@ void wxSizer::Fit( wxWindow *window ) else size = GetMinWindowSize( window ); - //window->SetClientSize( size ); window->SetSize( size ); + + return size; } void wxSizer::FitInside( wxWindow *window ) @@ -434,8 +435,8 @@ void wxSizer::SetSizeHints( 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(), -- 2.45.2