]> git.saurik.com Git - wxWidgets.git/commitdiff
Allow specifying all wxFlexGridSizer parameters in XRC.
authorVadim Zeitlin <vadim@wxwidgets.org>
Fri, 19 Oct 2012 22:03:25 +0000 (22:03 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Fri, 19 Oct 2012 22:03:25 +0000 (22:03 +0000)
Add support for specifying flexible direction, grow mode in non-flexible
direction and row/column proportions for the growable ones.

Closes #14767.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@72710 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

docs/changes.txt
docs/doxygen/overviews/xrc_format.h
include/wx/xrc/xh_sizer.h
src/xrc/xh_sizer.cpp

index aa5fafda43dc9fa175845a891c425d314a0bd2af..095511a1d9ec2dcc5840731084ebfc8400aac46b 100644 (file)
@@ -572,6 +572,7 @@ All (GUI):
 - Implement incremental search in wxGenericListCtrl (Jonathan Dagresta).
 - Make TAB behaviour in wxGrid more flexible (Fulvio Senore).
 - Add missing styles support to wxWindow XRC hanlder (Steffen Olszewski).
+- Allow specifying all wxFlexGridSizer parameters in XRC (Steffen Olszewski).
 
 wxGTK:
 
index 84e60f92fbf03161741d13804c1b03b94f2e2df5..3f46e151f3a3c59c5fed3b1ded7f369a1c92f7f8 100644 (file)
@@ -1919,8 +1919,8 @@ Example of sizers XRC code:
         <rows>0</rows>
         <vgap>0</vgap>
         <hgap>0</hgap>
-        <growablecols>0</growablecols>
-        <growablerows>0</growablerows>
+        <growablecols>0:1</growablecols>
+        <growablerows>0:1</growablerows>
         <object class="sizeritem">
             <flag>wxALIGN_CENTRE|wxALL</flag>
             <border>5</border>
@@ -2001,12 +2001,22 @@ class-specific properties. All classes support the following properties:
 @row3col{cols, integer, Number of columns in the grid (default: 0 - determine automatically).}
 @row3col{vgap, integer, Vertical gap between children (default: 0).}
 @row3col{hgap, integer, Horizontal gap between children (default: 0).}
+@row3col{flexibledirection, @ref overview_xrcformat_type_style,
+    Flexible direction, @c wxVERTICAL, @c wxHORIZONTAL or @c wxBOTH (default).
+    This property is only available since wxWidgets 2.9.5.}
+@row3col{nonflexiblegrowmode, @ref overview_xrcformat_type_style,
+    Grow mode in the non-flexible direction,
+    @c wxFLEX_GROWMODE_NONE, @c wxFLEX_GROWMODE_SPECIFIED (default) or
+    @c wxFLEX_GROWMODE_ALL.
+    This property is only available since wxWidgets 2.9.5.}
 @row3col{growablerows, comma-separated integers list,
-    Comma-separated list of indexes of rows that are growable
-    (default: none).}
+    Comma-separated list of indexes of rows that are growable (none by default).
+    Since wxWidgets 2.9.5 optional proportion can be appended to each number
+    after a colon (@c :).}
 @row3col{growablecols, comma-separated integers list,
-    Comma-separated list of indexes of columns that are growable
-    (default: none).}
+    Comma-separated list of indexes of columns that are growable (none by default).
+    Since wxWidgets 2.9.5 optional proportion can be appended to each number
+    after a colon (@c :).}
 @endTable
 
 @subsection overview_xrcformat_wxgridbagsizer wxGridBagSizer
@@ -2015,11 +2025,21 @@ class-specific properties. All classes support the following properties:
 @hdr3col{property, type, description}
 @row3col{vgap, integer, Vertical gap between children (default: 0).}
 @row3col{hgap, integer, Horizontal gap between children (default: 0).}
+@row3col{flexibledirection, @ref overview_xrcformat_type_style,
+    Flexible direction, @c wxVERTICAL, @c wxHORIZONTAL, @c wxBOTH (default: @c wxBOTH).}
+@row3col{nonflexiblegrowmode, @ref overview_xrcformat_type_style,
+    Grow mode in the non-flexible direction,
+    @c wxFLEX_GROWMODE_NONE, @c wxFLEX_GROWMODE_SPECIFIED, @c wxFLEX_GROWMODE_ALL
+    (default: @c wxFLEX_GROWMODE_SPECIFIED).}
 @row3col{growablerows, comma-separated integers list,
-    Comma-separated list of indexes of rows that are growable
+    Comma-separated list of indexes of rows that are growable,
+    optionally the proportion can be appended after each number
+    separated by a @c :
     (default: none).}
 @row3col{growablecols, comma-separated integers list,
-    Comma-separated list of indexes of columns that are growable
+    Comma-separated list of indexes of columns that are growable,
+    optionally the proportion can be appended after each number
+    separated by a @c :
     (default: none).}
 @endTable
 
index 5c941dea977eb2feda2a7706a69bedae5d3b268c..d38f778d95f38605a2ed41534c3d0b6bf68e74a6 100644 (file)
@@ -51,6 +51,7 @@ private:
     wxSizer*  Handle_wxWrapSizer();
 
     bool ValidateGridSizerChildren();
+    void SetFlexibleMode(wxFlexGridSizer* fsizer);
     void SetGrowables(wxFlexGridSizer* fsizer, const wxChar* param, bool rows);
     wxGBPosition GetGBPos(const wxString& param);
     wxGBSpan GetGBSpan(const wxString& param);
index 6fbe286e9650b6351bbbd83b04a227e52a7065d7..ad9fd5798652ee2bb571c6b0129a0af340b48ef4 100644 (file)
@@ -270,6 +270,7 @@ wxObject* wxSizerXmlHandler::Handle_sizer()
     // set growable rows and cols for sizers which support this
     if ( wxFlexGridSizer *flexsizer = wxDynamicCast(sizer, wxFlexGridSizer) )
     {
+        SetFlexibleMode(flexsizer);
         SetGrowables(flexsizer, wxT("growablerows"), true);
         SetGrowables(flexsizer, wxT("growablecols"), false);
     }
@@ -395,6 +396,50 @@ bool wxSizerXmlHandler::ValidateGridSizerChildren()
 }
 
 
+void wxSizerXmlHandler::SetFlexibleMode(wxFlexGridSizer* fsizer)
+{
+    if (HasParam(wxT("flexibledirection")))
+    {
+        wxString dir = GetParamValue(wxT("flexibledirection"));
+
+        if (dir == wxT("wxVERTICAL"))
+            fsizer->SetFlexibleDirection(wxVERTICAL);
+        else if (dir == wxT("wxHORIZONTAL"))
+            fsizer->SetFlexibleDirection(wxHORIZONTAL);
+        else if (dir == wxT("wxBOTH"))
+            fsizer->SetFlexibleDirection(wxBOTH);
+        else
+        {
+            ReportParamError
+            (
+                wxT("flexibledirection"),
+                wxString::Format("unknown direction \"%s\"", dir)
+            );
+        }
+    }
+
+    if (HasParam(wxT("nonflexiblegrowmode")))
+    {
+        wxString mode = GetParamValue(wxT("nonflexiblegrowmode"));
+
+        if (mode == wxT("wxFLEX_GROWMODE_NONE"))
+            fsizer->SetNonFlexibleGrowMode(wxFLEX_GROWMODE_NONE);
+        else if (mode == wxT("wxFLEX_GROWMODE_SPECIFIED"))
+            fsizer->SetNonFlexibleGrowMode(wxFLEX_GROWMODE_SPECIFIED);
+        else if (mode == wxT("wxFLEX_GROWMODE_ALL"))
+            fsizer->SetNonFlexibleGrowMode(wxFLEX_GROWMODE_ALL);
+        else
+        {
+            ReportParamError
+            (
+                wxT("nonflexiblegrowmode"),
+                wxString::Format("unknown grow mode \"%s\"", mode)
+            );
+        }
+    }
+}
+
+
 void wxSizerXmlHandler::SetGrowables(wxFlexGridSizer* sizer,
                                      const wxChar* param,
                                      bool rows)
@@ -408,18 +453,35 @@ void wxSizerXmlHandler::SetGrowables(wxFlexGridSizer* sizer,
 
     while (tkn.HasMoreTokens())
     {
-        unsigned long l;
-        if (!tkn.GetNextToken().ToULong(&l))
+        wxString propStr;
+        wxString idxStr = tkn.GetNextToken().BeforeFirst(wxT(':'), &propStr);
+
+        unsigned long li;
+        if (!idxStr.ToULong(&li))
         {
             ReportParamError
             (
                 param,
-                "value must be comma-separated list of row numbers"
+                "value must be a comma-separated list of numbers"
             );
             break;
         }
 
-        const int n = static_cast<int>(l);
+        unsigned long lp = 0;
+        if (!propStr.empty())
+        {
+            if (!propStr.ToULong(&lp))
+            {
+                ReportParamError
+                (
+                    param,
+                    "value must be a comma-separated list of numbers"
+                );
+                break;
+            }
+        }
+
+        const int n = static_cast<int>(li);
         if ( n >= nslots )
         {
             ReportParamError
@@ -439,9 +501,9 @@ void wxSizerXmlHandler::SetGrowables(wxFlexGridSizer* sizer,
         }
 
         if (rows)
-            sizer->AddGrowableRow(n);
+            sizer->AddGrowableRow(n, static_cast<int>(lp));
         else
-            sizer->AddGrowableCol(n);
+            sizer->AddGrowableCol(n, static_cast<int>(lp));
     }
 }