X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/c4c3e30f2eb4b6771869d1661c32e0b732a6874a..6bae67261c727ee5030abda0a5996e3f9fa6b6b2:/src/common/stockitem.cpp?ds=sidebyside diff --git a/src/common/stockitem.cpp b/src/common/stockitem.cpp index b6336d5645..2838320cb8 100644 --- a/src/common/stockitem.cpp +++ b/src/common/stockitem.cpp @@ -30,7 +30,7 @@ #include "wx/stockitem.h" #include "wx/intl.h" - +#include "wx/utils.h" // for wxStripMenuCodes() bool wxIsStockID(wxWindowID id) { @@ -90,14 +90,17 @@ bool wxIsStockID(wxWindowID id) default: return false; - }; + } } -wxString wxGetStockLabel(wxWindowID id) +wxString wxGetStockLabel(wxWindowID id, bool withCodes, wxString accelerator) { + wxString stockLabel; + #define STOCKITEM(stockid, label) \ case stockid: \ - return label; + stockLabel = label; \ + break; switch (id) { @@ -158,8 +161,18 @@ wxString wxGetStockLabel(wxWindowID id) }; #undef STOCKITEM - - return wxEmptyString; + + if(!withCodes) + { + stockLabel = wxStripMenuCodes( stockLabel ); + } + else if (!stockLabel.empty() && !accelerator.empty()) + { + stockLabel += _T("\t"); + stockLabel += accelerator; + } + + return stockLabel; } bool wxIsStockLabel(wxWindowID id, const wxString& label) @@ -171,11 +184,11 @@ bool wxIsStockLabel(wxWindowID id, const wxString& label) if (label == stock) return true; - + stock.Replace(_T("&"), wxEmptyString); if (label == stock) return true; - + return false; } @@ -189,7 +202,7 @@ const char *wxGetStockGtkID(wxWindowID id) #define STOCKITEM(wx,gtk) \ case wx: \ return gtk; - + #define STOCKITEM_MISSING(wx) \ case wx: \ return NULL; @@ -259,7 +272,7 @@ const char *wxGetStockGtkID(wxWindowID id) }; #undef STOCKITEM - + return NULL; }