From f72ed385786eccca7a73cbace9bae975e3a2ae21 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Thu, 20 Oct 2011 16:10:35 +0000 Subject: [PATCH] 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 --- docs/changes.txt | 1 + docs/doxygen/overviews/xrc_format.h | 2 ++ src/xrc/xh_toolb.cpp | 18 ++++++++++++++++++ 3 files changed, 21 insertions(+) diff --git a/docs/changes.txt b/docs/changes.txt index 8693868a00..82e9bf1155 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -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: diff --git a/docs/doxygen/overviews/xrc_format.h b/docs/doxygen/overviews/xrc_format.h index 71325a6ebb..bd7f0e659b 100644 --- a/docs/doxygen/overviews/xrc_format.h +++ b/docs/doxygen/overviews/xrc_format.h @@ -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 diff --git a/src/xrc/xh_toolb.cpp b/src/xrc/xh_toolb.cpp index 041c8d8b66..c6e75a3615 100644 --- a/src/xrc/xh_toolb.cpp +++ b/src/xrc/xh_toolb.cpp @@ -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 nor tools can be checked" + ); + } + else + { + m_toolbar->ToggleTool(GetID(), true); + } + } + #if wxUSE_MENUS if ( menu ) tool->SetDropdownMenu(menu); -- 2.45.2