]> git.saurik.com Git - wxWidgets.git/blobdiff - src/common/stockitem.cpp
don't crash if conversion of a command line argument to Unicode fails
[wxWidgets.git] / src / common / stockitem.cpp
index 13be116b1fafaba00e9ac4e272a670d5b2c1a853..c1b7d71ad8f51c5fab8c0e7dcc9854fcf9a2c326 100644 (file)
 // 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"
 
@@ -30,7 +26,7 @@
 
 #include "wx/stockitem.h"
 #include "wx/intl.h"
-
+#include "wx/utils.h" // for wxStripMenuCodes()
 
 bool wxIsStockID(wxWindowID id)
 {
@@ -90,14 +86,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)
     {
@@ -159,7 +158,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)