Added back the missing Undo/Redo accelerators that unaccountably

went missing after 2.3.1


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@15096 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Julian Smart
2002-04-11 16:50:55 +00:00
parent 412633c4a5
commit 6aa3ea889a
3 changed files with 22 additions and 8 deletions

View File

@@ -225,7 +225,9 @@ copy %src\bin\tex2rtf.exe bin
copy %src\bin\dbgview.* bin copy %src\bin\dbgview.* bin
copy %src\bin\widgets.exe bin copy %src\bin\widgets.exe bin
copy %src\bin\widgets.exe.manifest bin copy %src\bin\widgets.exe.manifest bin
Rem copy %src\demos\life\breeder.lif bin copy %src\bin\life.exe bin
copy %src\bin\life.exe.manifest bin
copy %src\demos\life\breeder.lif bin
copy %src\docs\htmlhelp\dialoged.chm bin copy %src\docs\htmlhelp\dialoged.chm bin
copy %src\docs\htmlhelp\tex2rtf.chm bin copy %src\docs\htmlhelp\tex2rtf.chm bin

View File

@@ -87,6 +87,13 @@ public:
int GetMaxCommands() const { return m_maxNoCommands; } int GetMaxCommands() const { return m_maxNoCommands; }
virtual void ClearCommands(); virtual void ClearCommands();
// By default, the accelerators are "\tCtrl+Z" and "\tCtrl+Y"
const wxString& GetUndoAccelerator() const { return m_undoAccelerator; }
const wxString& GetRedoAccelerator() const { return m_redoAccelerator; }
void SetUndoAccelerator(const wxString& accel) { m_undoAccelerator = accel; }
void SetRedoAccelerator(const wxString& accel) { m_redoAccelerator = accel; }
protected: protected:
// for further flexibility, command processor doesn't call wxCommand::Do() // for further flexibility, command processor doesn't call wxCommand::Do()
// and Undo() directly but uses these functions which can be overridden in // and Undo() directly but uses these functions which can be overridden in
@@ -102,6 +109,9 @@ protected:
wxMenu* m_commandEditMenu; wxMenu* m_commandEditMenu;
#endif // wxUSE_MENUS #endif // wxUSE_MENUS
wxString m_undoAccelerator;
wxString m_redoAccelerator;
private: private:
DECLARE_DYNAMIC_CLASS(wxCommandProcessor) DECLARE_DYNAMIC_CLASS(wxCommandProcessor)
}; };

View File

@@ -68,6 +68,8 @@ wxCommandProcessor::wxCommandProcessor(int maxCommands)
#if wxUSE_MENUS #if wxUSE_MENUS
m_commandEditMenu = (wxMenu *) NULL; m_commandEditMenu = (wxMenu *) NULL;
#endif // wxUSE_MENUS #endif // wxUSE_MENUS
m_undoAccelerator = wxT("\tCtrl+Z");
m_redoAccelerator = wxT("\tCtrl+Y");
} }
wxCommandProcessor::~wxCommandProcessor() wxCommandProcessor::~wxCommandProcessor()
@@ -231,9 +233,9 @@ void wxCommandProcessor::SetMenuStrings()
if (commandName == wxT("")) commandName = _("Unnamed command"); if (commandName == wxT("")) commandName = _("Unnamed command");
bool canUndo = command->CanUndo(); bool canUndo = command->CanUndo();
if (canUndo) if (canUndo)
buf = wxString(_("&Undo ")) + commandName; buf = wxString(_("&Undo ")) + commandName + m_undoAccelerator;
else else
buf = wxString(_("Can't &Undo ")) + commandName; buf = wxString(_("Can't &Undo ")) + commandName + m_undoAccelerator;
m_commandEditMenu->SetLabel(wxID_UNDO, buf); m_commandEditMenu->SetLabel(wxID_UNDO, buf);
m_commandEditMenu->Enable(wxID_UNDO, canUndo); m_commandEditMenu->Enable(wxID_UNDO, canUndo);
@@ -244,24 +246,24 @@ void wxCommandProcessor::SetMenuStrings()
wxCommand *redoCommand = (wxCommand *)m_currentCommand->Next()->Data(); wxCommand *redoCommand = (wxCommand *)m_currentCommand->Next()->Data();
wxString redoCommandName(redoCommand->GetName()); wxString redoCommandName(redoCommand->GetName());
if (redoCommandName == wxT("")) redoCommandName = _("Unnamed command"); if (redoCommandName == wxT("")) redoCommandName = _("Unnamed command");
buf = wxString(_("&Redo ")) + redoCommandName; buf = wxString(_("&Redo ")) + redoCommandName + m_redoAccelerator;
m_commandEditMenu->SetLabel(wxID_REDO, buf); m_commandEditMenu->SetLabel(wxID_REDO, buf);
m_commandEditMenu->Enable(wxID_REDO, TRUE); m_commandEditMenu->Enable(wxID_REDO, TRUE);
} }
else else
{ {
m_commandEditMenu->SetLabel(wxID_REDO, _("&Redo")); m_commandEditMenu->SetLabel(wxID_REDO, _("&Redo") + m_redoAccelerator);
m_commandEditMenu->Enable(wxID_REDO, FALSE); m_commandEditMenu->Enable(wxID_REDO, FALSE);
} }
} }
else else
{ {
m_commandEditMenu->SetLabel(wxID_UNDO, _("&Undo")); m_commandEditMenu->SetLabel(wxID_UNDO, _("&Undo") + m_undoAccelerator);
m_commandEditMenu->Enable(wxID_UNDO, FALSE); m_commandEditMenu->Enable(wxID_UNDO, FALSE);
if (m_commands.Number() == 0) 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); m_commandEditMenu->Enable(wxID_REDO, FALSE);
} }
else else
@@ -271,7 +273,7 @@ void wxCommandProcessor::SetMenuStrings()
wxCommand *redoCommand = (wxCommand *)m_commands.First()->Data(); wxCommand *redoCommand = (wxCommand *)m_commands.First()->Data();
wxString redoCommandName(redoCommand->GetName()); wxString redoCommandName(redoCommand->GetName());
if (redoCommandName == wxT("")) redoCommandName = _("Unnamed command"); if (redoCommandName == wxT("")) redoCommandName = _("Unnamed command");
buf = wxString(_("&Redo ")) + redoCommandName; buf = wxString(_("&Redo ")) + redoCommandName + m_redoAccelerator;
m_commandEditMenu->SetLabel(wxID_REDO, buf); m_commandEditMenu->SetLabel(wxID_REDO, buf);
m_commandEditMenu->Enable(wxID_REDO, TRUE); m_commandEditMenu->Enable(wxID_REDO, TRUE);
} }