]> git.saurik.com Git - wxWidgets.git/commitdiff
added proportion parameter to wxFlexGridSizer::AddGrowableRow/Col()
authorVadim Zeitlin <vadim@wxwidgets.org>
Thu, 27 Feb 2003 11:55:26 +0000 (11:55 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Thu, 27 Feb 2003 11:55:26 +0000 (11:55 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@19361 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

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

index aa04782a0e4803a485060a566b48b5cbf293fc1d..4e0c9d2eb3086c66016e996c34299296db94646b 100644 (file)
@@ -29,6 +29,7 @@ wxBase:
 All GUI ports:
 
 - added wxSplitterWindow handler to XRC
 All GUI ports:
 
 - added wxSplitterWindow handler to XRC
+- added proportion to wxFlexGridSizer::AddGrowableRow/Col (Maxim Babitski)
 - added wxFlexGridSizer::SetFlexibleDirection() (Szczepan Holyszewski)
 - implemented GetEditControl for wxGenericTreeCtrl (Peter Stieber)
 - improved contrib/utils/convertrc parsing (David J. Cooke)
 - added wxFlexGridSizer::SetFlexibleDirection() (Szczepan Holyszewski)
 - implemented GetEditControl for wxGenericTreeCtrl (Peter Stieber)
 - improved contrib/utils/convertrc parsing (David J. Cooke)
index 6b85373992d07bcd02d4d08a37180d91f23e30eb..92c1f8d5c29f32c2bd95145317fc7ba7064a2305 100644 (file)
@@ -41,18 +41,25 @@ all children.
 
 \membersection{wxFlexGridSizer::AddGrowableCol}\label{wxflexgridsizeraddgrowablecol}
 
 
 \membersection{wxFlexGridSizer::AddGrowableCol}\label{wxflexgridsizeraddgrowablecol}
 
-\func{void}{AddGrowableCol}{\param{size\_t }{idx}}
+\func{void}{AddGrowableCol}{\param{size\_t }{idx}, \param{int }{proportion = $0$}}
 
 
-Specifies that column idx (starting from zero) should be grown if
+Specifies that column {\it idx} (starting from zero) should be grown if
 there is extra space available to the sizer.
 
 there is extra space available to the sizer.
 
+The {\it proportion} parameter has the same meaning as the stretch factor for
+the \helpref{sizers}{sizeroverview} except that if all proportions are $0$,
+then all columns are resized equally (instead of not being resized at all).
+
 \membersection{wxFlexGridSizer::AddGrowableRow}\label{wxflexgridsizeraddgrowablerow}
 
 \membersection{wxFlexGridSizer::AddGrowableRow}\label{wxflexgridsizeraddgrowablerow}
 
-\func{void}{AddGrowableRow}{\param{size\_t }{idx}}
+\func{void}{AddGrowableRow}{\param{size\_t }{idx}, \param{int }{proportion = $0$}}
 
 Specifies that row idx (starting from zero) should be grown if there
 is extra space available to the sizer.
 
 
 Specifies that row idx (starting from zero) should be grown if there
 is extra space available to the sizer.
 
+See \helpref{AddGrowableCol}{wxflexgridsizeraddgrowablecol} for the description
+of {\it proportion} parameter.
+
 \membersection{wxFlexGridSizer::GetFlexibleDirection}\label{wxflexgridsizergetflexibledrection}
 
 \constfunc{int}{GetFlexibleDirections}{\void}
 \membersection{wxFlexGridSizer::GetFlexibleDirection}\label{wxflexgridsizergetflexibledrection}
 
 \constfunc{int}{GetFlexibleDirections}{\void}
index b5f06659551fd8c880b0037d09f3644f3e747895..314d374d9f6d7afb6a316376fe95a8ece031d466 100644 (file)
@@ -395,9 +395,9 @@ public:
 
     // set the rows/columns which will grow (the others will remain of the
     // constant initial size)
 
     // set the rows/columns which will grow (the others will remain of the
     // constant initial size)
-    void AddGrowableRow( size_t idx );
+    void AddGrowableRow( size_t idx, int proportion = 0 );
     void RemoveGrowableRow( size_t idx );
     void RemoveGrowableRow( size_t idx );
-    void AddGrowableCol( size_t idx );
+    void AddGrowableCol( size_t idx, int proportion = 0 );
     void RemoveGrowableCol( size_t idx );
 
 
     void RemoveGrowableCol( size_t idx );
 
 
@@ -427,6 +427,10 @@ protected:
     wxArrayInt  m_growableRows,
                 m_growableCols;
 
     wxArrayInt  m_growableRows,
                 m_growableCols;
 
+    // proportion values of the corresponding growable rows and columns
+    wxArrayInt  m_growableRowsProportions,
+                m_growableColsProportions;
+
     // parameters describing whether the growable cells should be resized in
     // both directions or only one
     int m_flexDirection;
     // parameters describing whether the growable cells should be resized in
     // both directions or only one
     int m_flexDirection;
index 9e430cdb84bcbe1418c59dc14194bafda8279840..30cd5d68ec1a7b9e8d15bde3201df20349a062df 100644 (file)
@@ -1029,6 +1029,9 @@ void wxFlexGridSizer::RecalcSizes()
     int    delta;
     size_t idx, num;
     wxArrayInt temp;
     int    delta;
     size_t idx, num;
     wxArrayInt temp;
+    wxArrayInt temp_proportions;
+    int sum_proportions = 0;
+    int growable_space = 0;
 
     // what to do with the rows? by default, resize them proportionally
     if ( (m_flexDirection & wxVERTICAL) ||
 
     // what to do with the rows? by default, resize them proportionally
     if ( (m_flexDirection & wxVERTICAL) ||
@@ -1040,18 +1043,33 @@ void wxFlexGridSizer::RecalcSizes()
         for (idx = 0; idx < m_growableRows.GetCount(); idx++)
         {
             if (m_growableRows[idx] < nrows)
         for (idx = 0; idx < m_growableRows.GetCount(); idx++)
         {
             if (m_growableRows[idx] < nrows)
+            {
                 temp.Add( m_growableRows[idx] );
                 temp.Add( m_growableRows[idx] );
+                temp_proportions.Add( m_growableRowsProportions[idx] );
+                sum_proportions += m_growableRowsProportions[idx];
+                growable_space += m_rowHeights[ temp[idx] ];
+            }
         }
 
         num = temp.GetCount();
 
         if ((num > 0) && (sz.y > minsz.y))
         {
         }
 
         num = temp.GetCount();
 
         if ((num > 0) && (sz.y > minsz.y))
         {
-            delta = (sz.y - minsz.y) / num;
             for (idx = 0; idx < num; idx++)
             for (idx = 0; idx < num; idx++)
-                m_rowHeights[ temp[idx] ] += delta;
+            {
+                delta = (sz.y - minsz.y);
+                if (sum_proportions == 0)
+                    delta = (delta/num) + m_rowHeights[ temp[idx] ];
+                else
+                    delta = ((delta+growable_space)*temp_proportions[idx])/
+                                                     sum_proportions;
+                m_rowHeights[ temp[idx] ] = delta;
+            }
         }
         temp.Empty();
         }
         temp.Empty();
+        temp_proportions.Empty();
+               sum_proportions = 0;
+               growable_space = 0;
     }
     else if ( (m_growMode == wxFLEX_GROWMODE_ALL) && (sz.y > minsz.y) )
     {
     }
     else if ( (m_growMode == wxFLEX_GROWMODE_ALL) && (sz.y > minsz.y) )
     {
@@ -1068,16 +1086,28 @@ void wxFlexGridSizer::RecalcSizes()
         for (idx = 0; idx < m_growableCols.GetCount(); idx++)
         {
             if (m_growableCols[idx] < ncols)
         for (idx = 0; idx < m_growableCols.GetCount(); idx++)
         {
             if (m_growableCols[idx] < ncols)
+            {
                 temp.Add( m_growableCols[idx] );
                 temp.Add( m_growableCols[idx] );
+                temp_proportions.Add( m_growableColsProportions[idx] );
+                sum_proportions += m_growableColsProportions[idx];
+                growable_space += m_colWidths[idx];
+            }
         }
 
         num = temp.GetCount();
 
         if ((num > 0) && (sz.x > minsz.x))
         {
         }
 
         num = temp.GetCount();
 
         if ((num > 0) && (sz.x > minsz.x))
         {
-            delta = (sz.x - minsz.x) / num;
             for (idx = 0; idx < num; idx++)
             for (idx = 0; idx < num; idx++)
-                m_colWidths[ temp[idx] ] += delta;
+            {
+                delta = (sz.x - minsz.x);
+                if (sum_proportions == 0)
+                    delta = (delta/num) + m_colWidths[ temp[idx] ];
+               else
+                    delta = ((delta+growable_space)*temp_proportions[idx])/
+                                                     sum_proportions;
+                m_colWidths[ temp[idx] ] = delta;
+            }
         }
     }
     else if ( (m_growMode == wxFLEX_GROWMODE_ALL) && (sz.x > minsz.x) )
         }
     }
     else if ( (m_growMode == wxFLEX_GROWMODE_ALL) && (sz.x > minsz.x) )
@@ -1191,18 +1221,20 @@ wxSize wxFlexGridSizer::CalcMin()
                    height + (nrows-1) * m_vgap);
 }
 
                    height + (nrows-1) * m_vgap);
 }
 
-void wxFlexGridSizer::AddGrowableRow( size_t idx )
+void wxFlexGridSizer::AddGrowableRow( size_t idx, int proportion )
 {
     m_growableRows.Add( idx );
 {
     m_growableRows.Add( idx );
+    m_growableRowsProportions.Add( proportion );
 }
 
 void wxFlexGridSizer::RemoveGrowableRow( size_t WXUNUSED(idx) )
 {
 }
 
 }
 
 void wxFlexGridSizer::RemoveGrowableRow( size_t WXUNUSED(idx) )
 {
 }
 
-void wxFlexGridSizer::AddGrowableCol( size_t idx )
+void wxFlexGridSizer::AddGrowableCol( size_t idx, int proportion )
 {
     m_growableCols.Add( idx );
 {
     m_growableCols.Add( idx );
+    m_growableColsProportions.Add( proportion );
 }
 
 void wxFlexGridSizer::RemoveGrowableCol( size_t WXUNUSED(idx) )
 }
 
 void wxFlexGridSizer::RemoveGrowableCol( size_t WXUNUSED(idx) )