Add support for fixed spacers and labels to wxAuiToolBar XRC handler.
Allow specifying "width" and "proportion" attributes for the "space" elements and add "label" element support. Closes #15964. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@75920 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -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).
|
||||
|
@@ -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.
|
||||
|
||||
|
@@ -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 {
|
||||
|
@@ -4,16 +4,24 @@
|
||||
<title>AUI XRC demo</title>
|
||||
<centered>1</centered>
|
||||
<style>wxCAPTION|wxRESIZE_BORDER</style>
|
||||
<size>-1,300</size>
|
||||
<size>500,300</size>
|
||||
<object class="wxBoxSizer">
|
||||
<orient>wxVERTICAL</orient>
|
||||
<object class="sizeritem">
|
||||
<flag>wxEXPAND</flag>
|
||||
<object class="wxAuiToolBar" name="aui_toolbar">
|
||||
<style>wxAUI_TB_TEXT|wxAUI_TB_GRIPPER</style>
|
||||
<object class="label" name="label1">
|
||||
<label>Tools:</label>
|
||||
<width>-1</width>
|
||||
</object>
|
||||
<object class="tool" name="tool1">
|
||||
<bitmap stock_id="wxART_NEW"/>
|
||||
<label>Tool 1</label>
|
||||
</object>
|
||||
<object class="space">
|
||||
<width>25</width>
|
||||
</object>
|
||||
<object class="tool" name="tool2">
|
||||
<bitmap stock_id="wxART_FILE_OPEN"/>
|
||||
<label>Tool 2</label>
|
||||
@@ -34,7 +42,9 @@
|
||||
</dropdown>
|
||||
</object>
|
||||
<object class="separator"/>
|
||||
<object class="space"/>
|
||||
<object class="space">
|
||||
<proportion>3</proportion>
|
||||
</object>
|
||||
<object class="wxComboBox">
|
||||
<content>
|
||||
<item>Just a</item>
|
||||
@@ -43,7 +53,7 @@
|
||||
</content>
|
||||
</object>
|
||||
<object class="space"/>
|
||||
</object>
|
||||
</object>
|
||||
</object>
|
||||
<object class="sizeritem">
|
||||
<option>1</option>
|
||||
|
@@ -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"))));
|
||||
}
|
||||
|
Reference in New Issue
Block a user