From 18b9d1a13c513bc0e2df984cf21b3bc131864c61 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Mon, 15 Jun 2009 19:35:19 +0000 Subject: [PATCH] add support for bitmap and bitmapposition tags to the wxButton XRC handler git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@61065 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- docs/doxygen/overviews/xrc_format.h | 8 ++++++-- src/xrc/xh_bttn.cpp | 32 +++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+), 2 deletions(-) diff --git a/docs/doxygen/overviews/xrc_format.h b/docs/doxygen/overviews/xrc_format.h index 3d8312cd94..00adb8849b 100644 --- a/docs/doxygen/overviews/xrc_format.h +++ b/docs/doxygen/overviews/xrc_format.h @@ -590,9 +590,13 @@ Example: @beginTable @hdr3col{property, type, description} @row3col{label, @ref overview_xrcformat_type_text, - Label to display on the button (required).} + Label to display on the button (may be empty if only bitmap is used).} +@row3col{bitmap, @ref overview_xrcformat_type_bitmap, + Bitmap to display in the button (optional).} +@row3col{bitmapposition, @c wxLEFT|wxRIGHT|wxTOP|wxBOTTOM, + Position of the bitmap in the button, see wxButton::SetBitmapPosition().} @row3col{default, @ref overview_xrcformat_type_bool, - Should this button be the default button in dialog (default: 0)?} + Should this button be the default button in dialog (default: 0)?} @endTable diff --git a/src/xrc/xh_bttn.cpp b/src/xrc/xh_bttn.cpp index d103e1ada3..963efd0848 100644 --- a/src/xrc/xh_bttn.cpp +++ b/src/xrc/xh_bttn.cpp @@ -50,6 +50,38 @@ wxObject *wxButtonXmlHandler::DoCreateResource() if (GetBool(wxT("default"), 0)) button->SetDefault(); + + if ( GetParamNode("bitmap") ) + { + wxDirection dir; + const wxString dirstr = GetParamValue("direction"); + if ( dirstr.empty() || dirstr == "wxLEFT" ) + dir = wxLEFT; + else if ( dirstr == "wxRIGHT" ) + dir = wxRIGHT; + else if ( dirstr == "wxTOP" ) + dir = wxTOP; + else if ( dirstr == "wxBOTTOM" ) + dir = wxBOTTOM; + else + { + ReportError + ( + GetParamNode("bitmapposition"), + wxString::Format + ( + "Invalid bitmap position \"%s\": must be one of " + "wxLEFT|wxRIGHT|wxTOP|wxBOTTOM.", + dirstr + ) + ); + + dir = wxLEFT; + } + + button->SetBitmap(GetBitmap("bitmap", wxART_BUTTON), dir); + } + SetupWindow(button); return button;