]> git.saurik.com Git - wxWidgets.git/blobdiff - src/common/stockitem.cpp
[ 1522987 ] wxComboCtrl crashes if TAB is pressed while popup is open
[wxWidgets.git] / src / common / stockitem.cpp
index 5f4bc508ba557bc1b19a0bd5911fac109f8bf327..9b2d4e2b1e8e92936edbfa257f3624fd202bbc26 100644 (file)
@@ -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:
 // 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"
 
 #endif
 
 #include "wx/stockitem.h"
-#include "wx/intl.h"
-#include "wx/utils.h" // for wxStripMenuCodes()
+
+#ifndef WX_PRECOMP
+    #include "wx/intl.h"
+    #include "wx/utils.h" // for wxStripMenuCodes()
+#endif
 
 bool wxIsStockID(wxWindowID id)
 {
@@ -90,20 +89,17 @@ bool wxIsStockID(wxWindowID id)
 
         default:
             return false;
-    };
+    }
 }
 
-wxString wxGetStockLabel(wxWindowID id)
+wxString wxGetStockLabel(wxWindowID id, bool withCodes, const wxString& accelerator)
 {
-#if defined(__SMARTPHONE__) || defined(__WXPALMOS__)
-    #define STOCKITEM(stockid, label) \
-        case stockid:                 \
-            return wxStripMenuCodes(label);
-#else
+    wxString stockLabel;
+
     #define STOCKITEM(stockid, label) \
         case stockid:                 \
-            return label;
-#endif
+            stockLabel = label;       \
+            break;
 
     switch (id)
     {
@@ -165,7 +161,17 @@ 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)