]> git.saurik.com Git - wxWidgets.git/commitdiff
Add support for stretchable spacers to XRC wxToolBar handler.
authorVadim Zeitlin <vadim@wxwidgets.org>
Mon, 18 Jan 2010 00:29:00 +0000 (00:29 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Mon, 18 Jan 2010 00:29:00 +0000 (00:29 +0000)
Notice that currently only stretchable spacers are supported via
separator-like "space" XRC element. If we ever add support for fixed spacers
in the toolbar we should do it via its fixed sub-element, e.g. they would be
specified with <fixed>1</fixed> in XRC file.

Also use spacers instead of separator in the XRC sample and ensure that the
toolbars in it are resized.

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

docs/doxygen/overviews/xrc_format.h
samples/xrc/rc/controls.xrc
src/xrc/xh_toolb.cpp

index 00adb8849bb4f442234fbe16d6ace202d86f324b..ab672a888292f3823868a40f43ec8ea91eeb292c 100644 (file)
@@ -1570,7 +1570,9 @@ A toolbar can have one or more child objects of any wxControl-derived class or
 one of two pseudo-classes: @c separator or @c tool.
 
 The @c separator pseudo-class is used to insert separators into the toolbar and
-has neither properties nor children.
+has neither properties nor children. Similarly, the @c space pseudo-class is
+used for stretchable spaces (see wxToolBar::AddStretchableSpace(), new since
+wxWidgets 2.9.1).
 
 The @c tool pseudo-class objects specify toolbar buttons and have the following
 properties:
@@ -1619,6 +1621,7 @@ Example:
         <bitmap>bar.png</bitmap>
         <label>Bar</label>
     </object>
+    <object class="separator"/>
     <object class="tool" name="view_auto">
         <bitmap>view.png</bitmap>
         <label>View</label>
@@ -1633,7 +1636,7 @@ Example:
             </object>
         </dropdown>
     </object>
-    <object class="separator"/>
+    <object class="space"/>
     <object class="wxComboBox">
         <content>
             <item>Just</item>
index 335f488d13e08c8047652263b68210a86e9cc556..e5faea49f62f79b69c2d593edca1ef2462340414 100644 (file)
@@ -65,8 +65,7 @@
                             <rows>0</rows>
                             <vgap>0</vgap>
                             <hgap>0</hgap>
-                            <growablecols>0,1</growablecols>
-                            <growablerows>0,1</growablerows>
+                            <growablecols>1</growablecols>
                             <object class="sizeritem">
                                 <flag>wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxALL</flag>
                                 <border>5</border>
@@ -75,9 +74,8 @@
                                 </object>
                             </object>
                             <object class="sizeritem">
-                                <flag>wxALIGN_CENTER_VERTICAL|wxALL</flag>
+                                <flag>wxEXPAND|wxALL</flag>
                                 <border>5</border>
-                                <size>300,60</size>
                                 <object class="wxToolBar">
                                     <style>wxTB_FLAT|wxTB_NODIVIDER</style>
                                     <margins>2,2</margins>
                                         <bitmap stock_id="wxART_GO_DOWN"/>
                                         <label>Down</label>
                                     </object>
-                                    <object class="separator"/>
+                                    <object class="space"/>
                                     <object class="wxComboBox">
                                         <content>
                                             <item>Just</item>
                                 </object>
                             </object>
                             <object class="sizeritem">
-                                <flag>wxALIGN_CENTER_VERTICAL|wxALL</flag>
+                                <flag>wxEXPAND|wxALL</flag>
                                 <border>5</border>
                                 <object class="wxToolBar">
                                     <style>wxTB_FLAT|wxTB_NODIVIDER</style>
                                             </object>
                                         </dropdown>
                                     </object>
+                                    <object class="separator"/>
                                     <object class="tool" name="home">
                                         <toggle>1</toggle>
                                         <bitmap stock_id="wxART_GO_HOME"/>
                                         <bitmap stock_id="wxART_GO_DOWN"/>
                                         <label>Down</label>
                                     </object>
-                                    <object class="separator"/>
+                                    <object class="space"/>
                                     <object class="wxComboBox">
                                         <content>
                                             <item>Just</item>
index fc0c19c7b9cac829d6b5eaa2751938c5667d1fc3..bfe713d9ae5678a9524be458a53b14abefd10689 100644 (file)
@@ -145,14 +145,19 @@ wxObject *wxToolBarXmlHandler::DoCreateResource()
         return m_toolbar; // must return non-NULL
     }
 
-    else if (m_class == wxT("separator"))
+    else if (m_class == wxT("separator") || m_class == wxT("space"))
     {
         if ( !m_toolbar )
         {
-            ReportError("separator only allowed inside wxToolBar");
+            ReportError("separators only allowed inside wxToolBar");
             return NULL;
         }
-        m_toolbar->AddSeparator();
+
+        if ( m_class == wxT("separator") )
+            m_toolbar->AddSeparator();
+        else
+            m_toolbar->AddStretchableSpace();
+
         return m_toolbar; // must return non-NULL
     }
 
@@ -206,6 +211,7 @@ wxObject *wxToolBarXmlHandler::DoCreateResource()
                 wxControl *control = wxDynamicCast(created, wxControl);
                 if (!IsOfClass(n, wxT("tool")) &&
                     !IsOfClass(n, wxT("separator")) &&
+                    !IsOfClass(n, wxT("space")) &&
                     control != NULL)
                     toolbar->AddControl(control);
             }
@@ -232,6 +238,7 @@ bool wxToolBarXmlHandler::CanHandle(wxXmlNode *node)
 {
     return ((!m_isInside && IsOfClass(node, wxT("wxToolBar"))) ||
             (m_isInside && IsOfClass(node, wxT("tool"))) ||
+            (m_isInside && IsOfClass(node, wxT("space"))) ||
             (m_isInside && IsOfClass(node, wxT("separator"))));
 }