]> git.saurik.com Git - wxWidgets.git/blobdiff - src/common/cmdproc.cpp
print session additions
[wxWidgets.git] / src / common / cmdproc.cpp
index 7466686e7a5c848ea292f1c7efcaf7d3b74c7c8f..79456425653bcf8b2d2c7302fabceebaa8df0c98 100644 (file)
@@ -68,6 +68,8 @@ wxCommandProcessor::wxCommandProcessor(int maxCommands)
 #if wxUSE_MENUS
     m_commandEditMenu = (wxMenu *) NULL;
 #endif // wxUSE_MENUS
+    m_undoAccelerator = wxT("\tCtrl+Z");
+    m_redoAccelerator = wxT("\tCtrl+Y");
 }
 
 wxCommandProcessor::~wxCommandProcessor()
@@ -218,6 +220,11 @@ void wxCommandProcessor::Initialize()
     SetMenuStrings();
 }
 
+static void wxSetMenuLabel(wxMenu* menu, int id, const wxString& label)
+{
+    menu->SetLabel(id, label);
+}
+
 void wxCommandProcessor::SetMenuStrings()
 {
 #if wxUSE_MENUS
@@ -231,11 +238,12 @@ void wxCommandProcessor::SetMenuStrings()
             if (commandName == wxT("")) commandName = _("Unnamed command");
             bool canUndo = command->CanUndo();
             if (canUndo)
-                buf = wxString(_("&Undo ")) + commandName;
+                buf = wxString(_("&Undo ")) + commandName + m_undoAccelerator;
             else
-                buf = wxString(_("Can't &Undo ")) + commandName;
+                buf = wxString(_("Can't &Undo ")) + commandName + m_undoAccelerator;
 
-            m_commandEditMenu->SetLabel(wxID_UNDO, buf);
+            wxSetMenuLabel(m_commandEditMenu, wxID_UNDO, buf);
+            
             m_commandEditMenu->Enable(wxID_UNDO, canUndo);
 
             // We can redo, if we're not at the end of the history.
@@ -244,24 +252,24 @@ void wxCommandProcessor::SetMenuStrings()
                 wxCommand *redoCommand = (wxCommand *)m_currentCommand->Next()->Data();
                 wxString redoCommandName(redoCommand->GetName());
                 if (redoCommandName == wxT("")) redoCommandName = _("Unnamed command");
-                buf = wxString(_("&Redo ")) + redoCommandName;
-                m_commandEditMenu->SetLabel(wxID_REDO, buf);
+                buf = wxString(_("&Redo ")) + redoCommandName + m_redoAccelerator;
+                wxSetMenuLabel(m_commandEditMenu, wxID_REDO, buf);
                 m_commandEditMenu->Enable(wxID_REDO, TRUE);
             }
             else
             {
-                m_commandEditMenu->SetLabel(wxID_REDO, _("&Redo"));
+                wxSetMenuLabel(m_commandEditMenu, wxID_REDO, _("&Redo") + m_redoAccelerator);
                 m_commandEditMenu->Enable(wxID_REDO, FALSE);
             }
         }
         else
         {
-            m_commandEditMenu->SetLabel(wxID_UNDO, _("&Undo"));
+            wxSetMenuLabel(m_commandEditMenu, wxID_UNDO, _("&Undo") + m_undoAccelerator);
             m_commandEditMenu->Enable(wxID_UNDO, FALSE);
 
             if (m_commands.Number() == 0)
             {
-                m_commandEditMenu->SetLabel(wxID_REDO, _("&Redo"));
+                wxSetMenuLabel(m_commandEditMenu, wxID_REDO, _("&Redo") + m_redoAccelerator);
                 m_commandEditMenu->Enable(wxID_REDO, FALSE);
             }
             else
@@ -271,8 +279,8 @@ void wxCommandProcessor::SetMenuStrings()
                 wxCommand *redoCommand = (wxCommand *)m_commands.First()->Data();
                 wxString redoCommandName(redoCommand->GetName());
                 if (redoCommandName == wxT("")) redoCommandName = _("Unnamed command");
-                buf = wxString(_("&Redo ")) + redoCommandName;
-                m_commandEditMenu->SetLabel(wxID_REDO, buf);
+                buf = wxString(_("&Redo ")) + redoCommandName + m_redoAccelerator;
+                wxSetMenuLabel(m_commandEditMenu, wxID_REDO, buf);
                 m_commandEditMenu->Enable(wxID_REDO, TRUE);
             }
         }