split wxSizer::Fit() into ComputeFittingWindow/ClientSize() that only does computations and Fit() that applies the result to the window
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@51767 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -197,6 +197,44 @@ Here, the sizer will do the actual calculation of its children's minimal sizes.
|
||||
Detaches all children from the sizer. If \arg{delete\_windows} is \true then child windows will also be deleted.
|
||||
|
||||
|
||||
\membersection{wxSizer::ComputeFittingClientSize}\label{wxsizercomputefittingclientsize}
|
||||
|
||||
\func{wxSize}{ComputeFittingClientSize}{\param{wxWindow* }{window}}
|
||||
|
||||
Computes client area size for \arg{window} so that it matches the
|
||||
sizer's minimal size. Unlike \helpref{GetMinSize}{wxsizergetminsize}, this
|
||||
method accounts for other constraints imposed on \arg{window}, namely display's
|
||||
size (returned size will never be too large for the display) and maximum
|
||||
window size if previously set by
|
||||
\helpref{wxWindow::SetMaxSize}{wxwindowsetmaxsize}.
|
||||
|
||||
The returned value is suitable for passing to
|
||||
\helpref{wxWindow::SetClientSize}{wxwindowsetclientsize} or
|
||||
\helpref{wxWindow::SetMinClientSize}{wxwindowsetminclientsize}.
|
||||
|
||||
\wxheading{See also}
|
||||
|
||||
\helpref{ComputeFittingWindowSize}{wxsizercomputefittingwindowsize},
|
||||
\helpref{Fit}{wxsizerfit}
|
||||
|
||||
|
||||
\membersection{wxSizer::ComputeFittintWindowSize}\label{wxsizercomputefittingwindowsize}
|
||||
|
||||
\func{wxSize}{ComputeFittingWindowSize}{\param{wxWindow* }{window}}
|
||||
|
||||
Like \helpref{ComputeFittingClientSize}{wxsizercomputefittingclientsize},
|
||||
but converts the result into \emph{window} size.
|
||||
|
||||
The returned value is suitable for passing to
|
||||
\helpref{wxWindow::SetSize}{wxwindowsetsize} or
|
||||
\helpref{wxWindow::SetMinSize}{wxwindowsetminsize}.
|
||||
|
||||
\wxheading{See also}
|
||||
|
||||
\helpref{ComputeFittingClientSize}{wxsizercomputefittingclientsize},
|
||||
\helpref{Fit}{wxsizerfit}
|
||||
|
||||
|
||||
\membersection{wxSizer::Detach}\label{wxsizerdetach}
|
||||
|
||||
\func{bool}{Detach}{\param{wxWindow* }{window}}
|
||||
@@ -223,9 +261,18 @@ Returns true if the child item was found and detached, false otherwise.
|
||||
\func{wxSize}{Fit}{\param{wxWindow* }{window}}
|
||||
|
||||
Tell the sizer to resize the \arg{window} so that its client area matches the
|
||||
sizer's minimal size. This is commonly done in the constructor of the window
|
||||
sizer's minimal size
|
||||
(\helpref{ComputeFittingClientSize}{wxsizercomputefittingclientsize} is called
|
||||
to determine it).
|
||||
This is commonly done in the constructor of the window
|
||||
itself, see sample in the description
|
||||
of \helpref{wxBoxSizer}{wxboxsizer}. Returns the new size.
|
||||
of \helpref{wxBoxSizer}{wxboxsizer}. Returns the new \emph{window} size.
|
||||
|
||||
\wxheading{See also}
|
||||
|
||||
\helpref{ComputeFittingClientSize}{wxsizercomputefittingclientsize},
|
||||
\helpref{ComputeFittingWindowSize}{wxsizercomputefittingwindowsize}
|
||||
|
||||
|
||||
\membersection{wxSizer::FitInside}\label{wxsizerfitinside}
|
||||
|
||||
@@ -309,6 +356,13 @@ Returns the minimal size of the sizer. This is either the combined minimal
|
||||
size of all the children and their borders or the minimal size set by
|
||||
\helpref{SetMinSize}{wxsizersetminsize}, depending on which is bigger.
|
||||
|
||||
Note that the returned value is \emph{client} size, not window size.
|
||||
In particular, if you use the value to set toplevel window's minimal or
|
||||
actual size, use \helpref{wxWindow::SetMinClientSize}{wxwindowsetminclientsize}
|
||||
or \helpref{wxWindow::SetClientSize}{wxwindowsetclientsize}, \emph{not}
|
||||
\helpref{wxWindow::SetMinSize}{wxwindowsetminsize}
|
||||
or \helpref{wxWindow::SetSize}{wxwindowsetsize}.
|
||||
|
||||
|
||||
\membersection{wxSizer::Hide}\label{wxsizerhide}
|
||||
|
||||
|
@@ -601,6 +601,9 @@ public:
|
||||
|
||||
virtual void Layout();
|
||||
|
||||
wxSize ComputeFittingClientSize(wxWindow *window);
|
||||
wxSize ComputeFittingWindowSize(wxWindow *window);
|
||||
|
||||
wxSize Fit( wxWindow *window );
|
||||
void FitInside( wxWindow *window );
|
||||
void SetSizeHints( wxWindow *window );
|
||||
|
@@ -834,8 +834,10 @@ void wxSizer::DeleteWindows()
|
||||
}
|
||||
}
|
||||
|
||||
wxSize wxSizer::Fit( wxWindow *window )
|
||||
wxSize wxSizer::ComputeFittingClientSize(wxWindow *window)
|
||||
{
|
||||
wxCHECK_MSG( window, wxDefaultSize, "window can't be NULL" );
|
||||
|
||||
// take the min size by default and limit it by max size
|
||||
wxSize size = GetMinClientSize(window);
|
||||
wxSize sizeMax;
|
||||
@@ -846,8 +848,7 @@ wxSize wxSizer::Fit( wxWindow *window )
|
||||
// hack for small screen devices where TLWs are always full screen
|
||||
if ( tlw->IsAlwaysMaximized() )
|
||||
{
|
||||
// do nothing
|
||||
return tlw->GetSize();
|
||||
return tlw->GetClientSize();
|
||||
}
|
||||
|
||||
// limit the window to the size of the display it is on
|
||||
@@ -873,8 +874,22 @@ wxSize wxSizer::Fit( wxWindow *window )
|
||||
if ( sizeMax.y != wxDefaultCoord && size.y > sizeMax.y )
|
||||
size.y = sizeMax.y;
|
||||
|
||||
return size;
|
||||
}
|
||||
|
||||
wxSize wxSizer::ComputeFittingWindowSize(wxWindow *window)
|
||||
{
|
||||
wxCHECK_MSG( window, wxDefaultSize, "window can't be NULL" );
|
||||
|
||||
return window->ClientToWindowSize(ComputeFittingClientSize(window));
|
||||
}
|
||||
|
||||
wxSize wxSizer::Fit( wxWindow *window )
|
||||
{
|
||||
wxCHECK_MSG( window, wxDefaultSize, "window can't be NULL" );
|
||||
|
||||
// set client size
|
||||
window->SetClientSize( size );
|
||||
window->SetClientSize(ComputeFittingClientSize(window));
|
||||
|
||||
// return entire size
|
||||
return window->GetSize();
|
||||
|
Reference in New Issue
Block a user