Add "checked" property for toolbar tool elements in XRC.

Allow toolbar tools to be created in checked (or toggled) state in XRC, just
as the menu items can already be created checked.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@69487 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2011-10-20 16:10:35 +00:00
parent 675f687593
commit f72ed38578
3 changed files with 21 additions and 0 deletions

View File

@@ -487,6 +487,7 @@ All (GUI):
- Allow converting to and from wxGraphicsBitmap and wxImage directly.
- Allow wxGraphicsFont creation without passing by wxFont.
- Added wxDataViewCustomRenderer::ActivateCell().
- Add "checked" property for toolbar tool elements in XRC.
OSX:

View File

@@ -1654,6 +1654,8 @@ properties:
Help text shown in statusbar when the mouse is on the tool (default: none).}
@row3col{disabled, @ref overview_xrcformat_type_bool,
Is the tool initially disabled (default: 0)?}
@row3col{checked, @ref overview_xrcformat_type_bool,
Is the tool initially checked (default: 0)? (only available since wxWidgets 2.9.3)}
@endTable
The presence of a @c dropdown property indicates that the tool is of type

View File

@@ -78,6 +78,7 @@ wxObject *wxToolBarXmlHandler::DoCreateResource()
kind = wxITEM_CHECK;
}
#if wxUSE_MENUS
// check whether we have dropdown tag inside
wxMenu *menu = NULL; // menu for drop down items
@@ -137,6 +138,23 @@ wxObject *wxToolBarXmlHandler::DoCreateResource()
if ( GetBool(wxT("disabled")) )
m_toolbar->EnableTool(GetID(), false);
if ( GetBool(wxS("checked")) )
{
if ( kind == wxITEM_NORMAL )
{
ReportParamError
(
"checked",
"only <radio> nor <toggle> tools can be checked"
);
}
else
{
m_toolbar->ToggleTool(GetID(), true);
}
}
#if wxUSE_MENUS
if ( menu )
tool->SetDropdownMenu(menu);