From 5852e62f1fe76907832ba2c7f2b4099635e44c4b Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Mon, 18 Jan 2010 00:29:00 +0000 Subject: [PATCH] Add support for stretchable spacers to XRC wxToolBar handler. 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 1 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 | 7 +++++-- samples/xrc/rc/controls.xrc | 13 ++++++------- src/xrc/xh_toolb.cpp | 13 ++++++++++--- 3 files changed, 21 insertions(+), 12 deletions(-) diff --git a/docs/doxygen/overviews/xrc_format.h b/docs/doxygen/overviews/xrc_format.h index 00adb8849b..ab672a8882 100644 --- a/docs/doxygen/overviews/xrc_format.h +++ b/docs/doxygen/overviews/xrc_format.h @@ -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: bar.png + view.png @@ -1633,7 +1636,7 @@ Example: - + Just diff --git a/samples/xrc/rc/controls.xrc b/samples/xrc/rc/controls.xrc index 335f488d13..e5faea49f6 100644 --- a/samples/xrc/rc/controls.xrc +++ b/samples/xrc/rc/controls.xrc @@ -65,8 +65,7 @@ 0 0 0 - 0,1 - 0,1 + 1 wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxALL 5 @@ -75,9 +74,8 @@ - wxALIGN_CENTER_VERTICAL|wxALL + wxEXPAND|wxALL 5 - 300,60 2,2 @@ -116,7 +114,7 @@ - + Just @@ -141,7 +139,7 @@ - wxALIGN_CENTER_VERTICAL|wxALL + wxEXPAND|wxALL 5 @@ -165,6 +163,7 @@ + 1 @@ -181,7 +180,7 @@ - + Just diff --git a/src/xrc/xh_toolb.cpp b/src/xrc/xh_toolb.cpp index fc0c19c7b9..bfe713d9ae 100644 --- a/src/xrc/xh_toolb.cpp +++ b/src/xrc/xh_toolb.cpp @@ -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")))); } -- 2.45.2