From e0ef2c9f55f5f5e2aa8e17ef3bff008fa55aaf2a Mon Sep 17 00:00:00 2001 From: Rodrigo Braz Monteiro Date: Sun, 8 Apr 2007 02:41:40 +0000 Subject: [PATCH] Fixed undo & redo items in edit menu. Originally committed to SVN as r1027. --- aegisub/frame_main.cpp | 8 +++----- aegisub/frame_main_events.cpp | 13 ++++--------- aegisub/utils.cpp | 5 +++-- aegisub/utils.h | 2 +- 4 files changed, 11 insertions(+), 17 deletions(-) diff --git a/aegisub/frame_main.cpp b/aegisub/frame_main.cpp index 62ad2acfb..dc6507d50 100644 --- a/aegisub/frame_main.cpp +++ b/aegisub/frame_main.cpp @@ -272,7 +272,6 @@ void FrameMain::InitMenu() { fileMenu = new wxMenu(); AppendBitmapMenuItem(fileMenu,Menu_File_New_Subtitles, _("&New Subtitles\t") + Hotkeys.GetText(_T("New Subtitles")), _("New subtitles"),wxBITMAP(new_toolbutton)); AppendBitmapMenuItem(fileMenu,Menu_File_Open_Subtitles, _("&Open Subtitles...\t") + Hotkeys.GetText(_T("Open Subtitles")), _("Opens a subtitles file"),wxBITMAP(open_toolbutton)); - //fileMenu->Append(Menu_File_Open_Subtitles_Charset, _("&Open Subtitles with Charset..."), _("Opens a subtitles file with a specific charset")); AppendBitmapMenuItem(fileMenu,Menu_File_Open_Subtitles_Charset, _("&Open Subtitles with Charset..."), _("Opens a subtitles file with a specific charset"),wxBITMAP(open_with_toolbutton)); AppendBitmapMenuItem(fileMenu,Menu_File_Save_Subtitles, _("&Save Subtitles\t") + Hotkeys.GetText(_T("Save Subtitles")), _("Saves subtitles"),wxBITMAP(save_toolbutton)); AppendBitmapMenuItem(fileMenu,Menu_File_Save_Subtitles_As, _("Save Subtitles as..."), _("Saves subtitles with another name"), wxBITMAP(save_as_toolbutton)); @@ -288,16 +287,15 @@ void FrameMain::InitMenu() { MenuBar->Append(fileMenu, _("&File")); // Create Edit menu + // NOTE: Undo and Redo are actually controlled in frame_main_events, OnMenuOpen(). They will always be the first two items. editMenu = new wxMenu(); - wxMenuItem *item; - item = AppendBitmapMenuItem(editMenu,Menu_Edit_Undo, _("-") + wxString(_T("\t")) + Hotkeys.GetText(_T("Undo")), _("Undoes last action"),wxBITMAP(undo_button)); - item = AppendBitmapMenuItem(editMenu,Menu_Edit_Redo, _("-") + wxString(_T("\t")) + Hotkeys.GetText(_T("Redo")), _("Redoes last action"),wxBITMAP(redo_button)); + AppendBitmapMenuItem(editMenu,Menu_Edit_Undo, _("&Undo") + wxString(_T("\t")) + Hotkeys.GetText(_T("Undo")), _("Undoes last action"),wxBITMAP(undo_button)); + AppendBitmapMenuItem(editMenu,Menu_Edit_Redo, _("&Redo") + wxString(_T("\t")) + Hotkeys.GetText(_T("Redo")), _("Redoes last action"),wxBITMAP(redo_button)); editMenu->AppendSeparator(); AppendBitmapMenuItem(editMenu,Menu_Edit_Cut, _("Cut Lines\t") + Hotkeys.GetText(_T("Cut")), _("Cut subtitles"), wxBITMAP(cut_button)); AppendBitmapMenuItem(editMenu,Menu_Edit_Copy, _("Copy Lines\t") + Hotkeys.GetText(_T("Copy")), _("Copy subtitles"), wxBITMAP(copy_button)); AppendBitmapMenuItem(editMenu,Menu_Edit_Paste, _("Paste Lines\t") + Hotkeys.GetText(_T("Paste")), _("Paste subtitles"), wxBITMAP(paste_button)); AppendBitmapMenuItem(editMenu,Menu_Edit_Paste_Over, _("Paste Lines Over...\t") + Hotkeys.GetText(_T("Paste Over")) , _("Paste subtitles over others"),wxBITMAP(paste_over_button)); - //AppendBitmapMenuItem(editMenu,Menu_Edit_Delete, _("Delete Lines\t") + Hotkeys.GetText(_T("Grid Delete Rows")), _("Delete selected lines"), wxBITMAP(delete_button)); editMenu->AppendSeparator(); AppendBitmapMenuItem(editMenu,Menu_Edit_Find, _("&Find...\t") + Hotkeys.GetText(_T("Find")), _("Find words in subtitles"),wxBITMAP(find_button)); AppendBitmapMenuItem(editMenu,Menu_Edit_Find_Next, _("Find Next\t") + Hotkeys.GetText(_T("Find Next")), _("Find next match of last word"),wxBITMAP(find_next_button)); diff --git a/aegisub/frame_main_events.cpp b/aegisub/frame_main_events.cpp index 8b15c24a3..b496f898f 100644 --- a/aegisub/frame_main_events.cpp +++ b/aegisub/frame_main_events.cpp @@ -398,15 +398,10 @@ void FrameMain::OnMenuOpen (wxMenuEvent &event) { // Edit menu else if (curMenu == editMenu) { // Undo state - wxMenuItem *item; - item = MenuBar->FindItem(Menu_Edit_Undo); - item->SetText(_("&Undo")+wxString(_T(" "))+AssFile::GetUndoDescription()+_T("\t")+Hotkeys.GetText(_T("Undo"))); - item->SetBitmap(wxBITMAP(undo_button)); - item->Enable(!AssFile::IsUndoStackEmpty()); - item = MenuBar->FindItem(Menu_Edit_Redo); - item->SetText(_("&Redo")+wxString(_T(" "))+AssFile::GetRedoDescription()+_T("\t")+Hotkeys.GetText(_T("Redo"))); - item->SetBitmap(wxBITMAP(redo_button)); - item->Enable(!AssFile::IsRedoStackEmpty()); + editMenu->Remove(Menu_Edit_Undo); + editMenu->Remove(Menu_Edit_Redo); + AppendBitmapMenuItem(editMenu,Menu_Edit_Undo, _("&Undo") + wxString(_T(" ")) + AssFile::GetUndoDescription() + wxString(_T("\t")) + Hotkeys.GetText(_T("Undo")), _("Undoes last action"),wxBITMAP(undo_button),0)->Enable(!AssFile::IsUndoStackEmpty()); + AppendBitmapMenuItem(editMenu,Menu_Edit_Redo, _("&Redo") + wxString(_T(" ")) + AssFile::GetRedoDescription() + wxString(_T("\t")) + Hotkeys.GetText(_T("Redo")), _("Redoes last action"),wxBITMAP(redo_button),1)->Enable(!AssFile::IsRedoStackEmpty()); // Copy/cut/paste wxArrayInt sels = SubsBox->GetSelection(); diff --git a/aegisub/utils.cpp b/aegisub/utils.cpp index 1874e1f7b..af091b422 100644 --- a/aegisub/utils.cpp +++ b/aegisub/utils.cpp @@ -190,10 +190,11 @@ wxString PrettySize(int bytes) { ////////////////////////////////// // Append a menu item with bitmap -wxMenuItem* AppendBitmapMenuItem (wxMenu* parentMenu,int id,wxString text,wxString help,wxBitmap bmp) { +wxMenuItem* AppendBitmapMenuItem (wxMenu* parentMenu,int id,wxString text,wxString help,wxBitmap bmp,int pos) { wxMenuItem *cur = new wxMenuItem(parentMenu,id,text,help); cur->SetBitmap(bmp); - parentMenu->Append(cur); + if (pos == -1) parentMenu->Append(cur); + else parentMenu->Insert(pos,cur); return cur; } diff --git a/aegisub/utils.h b/aegisub/utils.h index 6f36a4be0..5a03ffda0 100644 --- a/aegisub/utils.h +++ b/aegisub/utils.h @@ -53,7 +53,7 @@ wxString PrettyFloatD(double src); wxString FloatToString(double value); wxString IntegerToString(int value); wxString PrettySize(int bytes); -wxMenuItem *AppendBitmapMenuItem (wxMenu* parentMenu,int id,wxString text,wxString help,wxBitmap bmp); +wxMenuItem *AppendBitmapMenuItem (wxMenu* parentMenu,int id,wxString text,wxString help,wxBitmap bmp,int pos=-1); int SmallestPowerOf2(int x);