X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/c4c3e30f2eb4b6771869d1661c32e0b732a6874a..78c91815008ef5888231c6c7f3678872e9e35ff6:/src/common/stockitem.cpp?ds=sidebyside diff --git a/src/common/stockitem.cpp b/src/common/stockitem.cpp index b6336d5645..9b2d4e2b1e 100644 --- a/src/common/stockitem.cpp +++ b/src/common/stockitem.cpp @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////////// -// Name: common/stockitem.cpp +// Name: src/common/stockitem.cpp // Purpose: Stock buttons, menu and toolbar items labels // Author: Vaclav Slavik // Modified by: @@ -17,10 +17,6 @@ // headers // ---------------------------------------------------------------------------- -#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) - #pragma implementation "stockitem.h" -#endif - // For compilers that support precompilation, includes "wx.h". #include "wx/wxprec.h" @@ -29,8 +25,11 @@ #endif #include "wx/stockitem.h" -#include "wx/intl.h" +#ifndef WX_PRECOMP + #include "wx/intl.h" + #include "wx/utils.h" // for wxStripMenuCodes() +#endif bool wxIsStockID(wxWindowID id) { @@ -90,14 +89,17 @@ bool wxIsStockID(wxWindowID id) default: return false; - }; + } } -wxString wxGetStockLabel(wxWindowID id) +wxString wxGetStockLabel(wxWindowID id, bool withCodes, const wxString& accelerator) { + wxString stockLabel; + #define STOCKITEM(stockid, label) \ case stockid: \ - return label; + stockLabel = label; \ + break; switch (id) { @@ -158,8 +160,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 +183,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 +201,7 @@ const char *wxGetStockGtkID(wxWindowID id) #define STOCKITEM(wx,gtk) \ case wx: \ return gtk; - + #define STOCKITEM_MISSING(wx) \ case wx: \ return NULL; @@ -259,7 +271,7 @@ const char *wxGetStockGtkID(wxWindowID id) }; #undef STOCKITEM - + return NULL; }