diff --git a/docs/changes.txt b/docs/changes.txt index 071a3d6c24..9393c6ce65 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -25,7 +25,7 @@ All: All (GUI): -- XRC handler for wxAuiToolBar added (Kinaou Hervé). +- XRC handler for wxAuiToolBar added (Kinaou Hervé, David Hart). - Add support for sorting wxDataViewCtrl by multiple columns (Trigve). - Add wxHtmlWindow::SetDefaultHTMLCursor() (Jeff A. Marr). - Add default ctor and Create() to wxContextHelpButton (Hanmac). diff --git a/docs/doxygen/overviews/xrc_format.h b/docs/doxygen/overviews/xrc_format.h index a39a71ac2a..9b55c0fe30 100644 --- a/docs/doxygen/overviews/xrc_format.h +++ b/docs/doxygen/overviews/xrc_format.h @@ -597,6 +597,13 @@ Building an XRC for wxAuiToolBar is quite similar to wxToolBar. The only significant differences are: @li the use of the class name wxAuiToolBar @li the styles supported are the ones described in the wxAuiToolBar class definition +@li the 'space' pseudo-class has two optional, mutually exclusive, +integer properties: 'proportion' and 'width'. If 'width' is specified, a space +is added using wxAuiToolBar::AddSpacer(); if 'proportion', the value is used in +wxAuiToolBar::AddStretchSpacer(). If neither are provided, the default is a +stretch-spacer with a proportion of 1. +@li there is an additional pseudo-class, 'label', that has a string property. +See wxAuiToolBar::AddLabel(). Refer to the section @ref xrc_wxtoolbar for more details. diff --git a/misc/schema/xrc_schema.rnc b/misc/schema/xrc_schema.rnc index 5cf3bca212..f8892c439c 100644 --- a/misc/schema/xrc_schema.rnc +++ b/misc/schema/xrc_schema.rnc @@ -326,6 +326,7 @@ builtinNestedClassesNames = | "separator" | "break" | "space" + | "label" | "tool" | "panewindow" | "notebookpage" @@ -540,11 +541,24 @@ wxAuiToolBar = ( windowNode | wxToolBar_tool | + wxAuiToolBar_label | element object { attribute class { "separator" }, platform } | - element object { attribute class { "space" }, platform } + element object { attribute class { "space" } & + platform & + [xrc:p="o"] element width {_, t_integer }* & + [xrc:p="o"] element proportion {_, t_integer }* + } )* } +wxAuiToolBar_label = + element object { + attribute class { "label" } & + platform & + attribute name { t_identifier }? & + [xrc:p="important"] element label {_, t_text }* & + [xrc:p="o"] element width {_, t_integer }* + } wxBannerWindow = element object { diff --git a/samples/xrc/rc/aui.xrc b/samples/xrc/rc/aui.xrc index 649f18eb13..4c64d9d7b4 100644 --- a/samples/xrc/rc/aui.xrc +++ b/samples/xrc/rc/aui.xrc @@ -4,16 +4,24 @@ AUI XRC demo 1 - -1,300 + 500,300 wxVERTICAL + wxEXPAND + + + -1 + + + 25 + @@ -34,7 +42,9 @@ - + + 3 + Just a @@ -43,7 +53,7 @@ - + diff --git a/src/xrc/xh_auitoolb.cpp b/src/xrc/xh_auitoolb.cpp index 2043594835..d187db582e 100644 --- a/src/xrc/xh_auitoolb.cpp +++ b/src/xrc/xh_auitoolb.cpp @@ -136,7 +136,7 @@ wxObject *wxAuiToolBarXmlHandler::DoCreateResource() return m_toolbar; // must return non-NULL } - else if (m_class == wxS("separator") || m_class == wxS("space")) + else if (m_class == wxS("separator") || m_class == wxS("space") || m_class == wxS("label")) { if ( !m_toolbar ) { @@ -146,8 +146,43 @@ wxObject *wxAuiToolBarXmlHandler::DoCreateResource() if ( m_class == wxS("separator") ) m_toolbar->AddSeparator(); - else - m_toolbar->AddStretchSpacer(); + + else if (m_class == wxS("space")) + { + // This may be a stretch spacer (the default) or a non-stretch one + bool hasProportion = HasParam(wxS("proportion")); + bool hasWidth = HasParam(wxS("width")); + if (hasProportion && hasWidth) + { + ReportError("A space can't both stretch and have width"); + return NULL; + } + + if (hasWidth) + { + m_toolbar->AddSpacer + ( + GetLong(wxS("width")) + ); + } + else + { + m_toolbar->AddStretchSpacer + ( + GetLong(wxS("proportion"), 1l) + ); + } + } + + else if (m_class == wxS("label")) + { + m_toolbar->AddLabel + ( + GetID(), + GetText(wxS("label")), + GetLong(wxS("width"), -1l) + ); + } return m_toolbar; // must return non-NULL } @@ -201,6 +236,7 @@ wxObject *wxAuiToolBarXmlHandler::DoCreateResource() wxControl *control = wxDynamicCast(created, wxControl); if (!IsOfClass(n, wxS("tool")) && !IsOfClass(n, wxS("separator")) && + !IsOfClass(n, wxS("label")) && !IsOfClass(n, wxS("space")) && control != NULL) toolbar->AddControl(control); @@ -221,6 +257,7 @@ bool wxAuiToolBarXmlHandler::CanHandle(wxXmlNode *node) { return ((!m_isInside && IsOfClass(node, wxS("wxAuiToolBar"))) || (m_isInside && IsOfClass(node, wxS("tool"))) || + (m_isInside && IsOfClass(node, wxS("label"))) || (m_isInside && IsOfClass(node, wxS("space"))) || (m_isInside && IsOfClass(node, wxS("separator")))); }