]> git.saurik.com Git - wxWidgets.git/blobdiff - src/common/cmdproc.cpp
some wxArtProv docs
[wxWidgets.git] / src / common / cmdproc.cpp
index c2d44c895b52398a62e21a931fc50e6b39d7dfee..afdc6fff29acf7ef07a2e56433f60513c0b99888 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()
@@ -93,7 +95,12 @@ bool wxCommandProcessor::Submit(wxCommand *command, bool storeIt)
     wxCHECK_MSG( command, FALSE, _T("no command in wxCommandProcessor::Submit") );
 
     if ( !DoCommand(*command) )
+    {
+        // the user code expects the command to be deleted anyhow
+        delete command;
+
         return FALSE;
+    }
 
     if ( storeIt )
         Store(command);
@@ -154,12 +161,17 @@ bool wxCommandProcessor::Redo()
 {
     wxCommand *redoCommand = (wxCommand *) NULL;
     wxNode *redoNode = (wxNode *) NULL;
-    if (m_currentCommand && m_currentCommand->Next())
+
+    if ( m_currentCommand )
     {
-        redoCommand = (wxCommand *)m_currentCommand->Next()->Data();
-        redoNode = m_currentCommand->Next();
+        // is there anything to redo?
+        if ( m_currentCommand->Next() )
+        {
+            redoCommand = (wxCommand *)m_currentCommand->Next()->Data();
+            redoNode = m_currentCommand->Next();
+        }
     }
-    else
+    else // no current command, redo the first one
     {
         if (m_commands.Number() > 0)
         {
@@ -221,9 +233,9 @@ 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);
             m_commandEditMenu->Enable(wxID_UNDO, canUndo);
@@ -234,24 +246,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;
+                buf = wxString(_("&Redo ")) + redoCommandName + m_redoAccelerator;
                 m_commandEditMenu->SetLabel(wxID_REDO, buf);
                 m_commandEditMenu->Enable(wxID_REDO, TRUE);
             }
             else
             {
-                m_commandEditMenu->SetLabel(wxID_REDO, _("&Redo"));
+                m_commandEditMenu->SetLabel(wxID_REDO, _("&Redo") + m_redoAccelerator);
                 m_commandEditMenu->Enable(wxID_REDO, FALSE);
             }
         }
         else
         {
-            m_commandEditMenu->SetLabel(wxID_UNDO, _("&Undo"));
+            m_commandEditMenu->SetLabel(wxID_UNDO, _("&Undo") + m_undoAccelerator);
             m_commandEditMenu->Enable(wxID_UNDO, FALSE);
 
             if (m_commands.Number() == 0)
             {
-                m_commandEditMenu->SetLabel(wxID_REDO, _("&Redo"));
+                m_commandEditMenu->SetLabel(wxID_REDO, _("&Redo") + m_redoAccelerator);
                 m_commandEditMenu->Enable(wxID_REDO, FALSE);
             }
             else
@@ -261,7 +273,7 @@ void wxCommandProcessor::SetMenuStrings()
                 wxCommand *redoCommand = (wxCommand *)m_commands.First()->Data();
                 wxString redoCommandName(redoCommand->GetName());
                 if (redoCommandName == wxT("")) redoCommandName = _("Unnamed command");
-                buf = wxString(_("&Redo ")) + redoCommandName;
+                buf = wxString(_("&Redo ")) + redoCommandName + m_redoAccelerator;
                 m_commandEditMenu->SetLabel(wxID_REDO, buf);
                 m_commandEditMenu->Enable(wxID_REDO, TRUE);
             }