]> git.saurik.com Git - wxWidgets.git/blobdiff - src/common/stockitem.cpp
Left in debug printf.
[wxWidgets.git] / src / common / stockitem.cpp
index bac9c10c1f5a68d47c275fd0208de6cdd45e349f..ee38d92f204cda59b6e0e7109a09cb09033ee448 100644 (file)
@@ -169,23 +169,61 @@ wxString wxGetStockLabel(wxWindowID id, long flags)
 
     #undef STOCKITEM
 
-    if(flags & wxSTOCK_WITH_MNEMONIC)
+    if ( !(flags & wxSTOCK_WITH_MNEMONIC) )
     {
-        stockLabel = wxStripMenuCodes( stockLabel );
+        stockLabel = wxStripMenuCodes(stockLabel);
     }
 
-    if (!stockLabel.empty() && (flags & wxSTOCK_WITH_ACCELERATOR))
+#if wxUSE_ACCEL
+    if ( !stockLabel.empty() && (flags & wxSTOCK_WITH_ACCELERATOR) )
     {
-        stockLabel += _T("\t");
-
         wxAcceleratorEntry accel = wxGetStockAccelerator(id);
         if (accel.IsOk())
-            stockLabel += accel.ToString();
+            stockLabel << _T('\t') << accel.ToString();
     }
+#endif // wxUSE_ACCEL
 
     return stockLabel;
 }
 
+wxString wxGetStockHelpString(wxWindowID id, wxStockHelpStringClient client)
+{
+    wxString stockHelp;
+
+    #define STOCKITEM(stockid, ctx, helpstr)             \
+        case stockid:                                    \
+            if (client==ctx) stockHelp = helpstr;        \
+            break;
+
+    switch (id)
+    {
+        // NB: these help string should be not too specific as they could be used
+        //     in completely different programs!
+        STOCKITEM(wxID_ABOUT,    wxSTOCK_MENU, _("Show about dialog"))
+        STOCKITEM(wxID_COPY,     wxSTOCK_MENU, _("Copy selection"))
+        STOCKITEM(wxID_CUT,      wxSTOCK_MENU, _("Cut selection"))
+        STOCKITEM(wxID_DELETE,   wxSTOCK_MENU, _("Delete selection"))
+        STOCKITEM(wxID_REPLACE,  wxSTOCK_MENU, _("Replace selection"))
+        STOCKITEM(wxID_PASTE,    wxSTOCK_MENU, _("Paste selection"))
+        STOCKITEM(wxID_EXIT,     wxSTOCK_MENU, _("Quit this program"))
+        STOCKITEM(wxID_REDO,     wxSTOCK_MENU, _("Redo last action"))
+        STOCKITEM(wxID_UNDO,     wxSTOCK_MENU, _("Undo last action"))
+        STOCKITEM(wxID_CLOSE,    wxSTOCK_MENU, _("Close current document"))
+        STOCKITEM(wxID_SAVE,     wxSTOCK_MENU, _("Save current document"))
+        STOCKITEM(wxID_SAVEAS,   wxSTOCK_MENU, _("Save current document with a different filename"))
+
+        default:
+            // there's no stock help string for this ID / client
+            return wxEmptyString;
+    }
+
+    #undef STOCKITEM
+
+    return stockHelp;
+}
+
+#if wxUSE_ACCEL
+
 wxAcceleratorEntry wxGetStockAccelerator(wxWindowID id)
 {
     wxAcceleratorEntry ret;
@@ -220,6 +258,8 @@ wxAcceleratorEntry wxGetStockAccelerator(wxWindowID id)
     return ret;
 }
 
+#endif // wxUSE_ACCEL
+
 bool wxIsStockLabel(wxWindowID id, const wxString& label)
 {
     if (label.empty())
@@ -340,6 +380,9 @@ const char *wxGetStockGtkID(wxWindowID id)
 
 bool wxGetStockGtkAccelerator(const char *id, GdkModifierType *mod, guint *key)
 {
+    if (!id)
+        return false;
+
     GtkStockItem stock_item;
     if (gtk_stock_lookup (id, &stock_item))
     {