]> git.saurik.com Git - wxWidgets.git/commitdiff
split wxSizer::Fit() into ComputeFittingWindow/ClientSize() that only does computatio...
authorVáclav Slavík <vslavik@fastmail.fm>
Wed, 13 Feb 2008 21:32:11 +0000 (21:32 +0000)
committerVáclav Slavík <vslavik@fastmail.fm>
Wed, 13 Feb 2008 21:32:11 +0000 (21:32 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@51767 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

docs/latex/wx/sizer.tex
include/wx/sizer.h
src/common/sizer.cpp

index 8800335c251224b46695a4d9fc2050b23bd951ee..a1e1ef5c64b7094de604617f60b0cfe801af46c3 100644 (file)
@@ -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}}
@@ -222,10 +260,19 @@ 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 matchesthe 
-sizer's minimal size. This is commonly done in the constructor of the window
+Tell the sizer to resize the \arg{window} so that its client area matches the 
+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}
 
index 125dd55c7f95a8bd19eec4d1d17f338686f39dea..9ac8077b7d4f85faeeade675d0fcdd914a5cce38 100644 (file)
@@ -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 );
index 7c68b8a405cee50ce8fa114fe00e769b944eb590..d08036227403b24501535f6fd77333a2d9ab841f 100644 (file)
@@ -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();