- if (m_commands.Number() == 0)
- {
- m_commandEditMenu->SetLabel(wxID_REDO, "&Redo");
- m_commandEditMenu->Enable(wxID_REDO, FALSE);
- }
- else
- {
- // currentCommand is NULL but there are commands: this means that
- // we've undone to the start of the list, but can redo the first.
- wxCommand *redoCommand = (wxCommand *)m_commands.First()->Data();
- wxString redoCommandName(redoCommand->GetName());
- if (!redoCommandName) redoCommandName = "Unnamed command";
- buf = wxString("&Redo ") + redoCommandName;
- m_commandEditMenu->SetLabel(wxID_REDO, buf);
- m_commandEditMenu->Enable(wxID_REDO, TRUE);
- }
+void wxCommandProcessor::SetMenuStrings()
+{
+ if (m_commandEditMenu)
+ {
+ wxString buf;
+ if (m_currentCommand)
+ {
+ wxCommand *command = (wxCommand *)m_currentCommand->Data();
+ wxString commandName(command->GetName());
+ if (commandName == "") commandName = _("Unnamed command");
+ bool canUndo = command->CanUndo();
+ if (canUndo)
+ buf = wxString(_("&Undo ")) + commandName;
+ else
+ buf = wxString(_("Can't &Undo ")) + commandName;
+
+ m_commandEditMenu->SetLabel(wxID_UNDO, buf);
+ m_commandEditMenu->Enable(wxID_UNDO, canUndo);
+
+ // We can redo, if we're not at the end of the history.
+ if (m_currentCommand->Next())
+ {
+ wxCommand *redoCommand = (wxCommand *)m_currentCommand->Next()->Data();
+ wxString redoCommandName(redoCommand->GetName());
+ if (redoCommandName == "") redoCommandName = _("Unnamed command");
+ buf = wxString(_("&Redo ")) + redoCommandName;
+ m_commandEditMenu->SetLabel(wxID_REDO, buf);
+ m_commandEditMenu->Enable(wxID_REDO, TRUE);
+ }
+ else
+ {
+ m_commandEditMenu->SetLabel(wxID_REDO, _("&Redo"));
+ m_commandEditMenu->Enable(wxID_REDO, FALSE);
+ }
+ }
+ else
+ {
+ m_commandEditMenu->SetLabel(wxID_UNDO, _("&Undo"));
+ m_commandEditMenu->Enable(wxID_UNDO, FALSE);
+
+ if (m_commands.Number() == 0)
+ {
+ m_commandEditMenu->SetLabel(wxID_REDO, _("&Redo"));
+ m_commandEditMenu->Enable(wxID_REDO, FALSE);
+ }
+ else
+ {
+ // currentCommand is NULL but there are commands: this means that
+ // we've undone to the start of the list, but can redo the first.
+ wxCommand *redoCommand = (wxCommand *)m_commands.First()->Data();
+ wxString redoCommandName(redoCommand->GetName());
+ if (redoCommandName == "") redoCommandName = _("Unnamed command");
+ buf = wxString(_("&Redo ")) + redoCommandName;
+ m_commandEditMenu->SetLabel(wxID_REDO, buf);
+ m_commandEditMenu->Enable(wxID_REDO, TRUE);
+ }
+ }