From: Markus R. <rol...@us...> - 2007-07-09 18:49:12
|
Update of /cvsroot/simspark/simspark/contrib/rsgedit In directory sc8-pr-cvs8.sourceforge.net:/tmp/cvs-serv15216 Modified Files: mainframe.cpp mainframe.h Log Message: - added method OnUpdateEditCommand to manage edit command UI state Index: mainframe.h =================================================================== RCS file: /cvsroot/simspark/simspark/contrib/rsgedit/mainframe.h,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** mainframe.h 9 Jul 2007 18:42:09 -0000 1.20 --- mainframe.h 9 Jul 2007 18:49:08 -0000 1.21 *************** *** 165,168 **** --- 165,169 ---- void OnTabContextMenu(wxFlatNotebookEvent& event); + void OnUpdateEditCommand(wxUpdateUIEvent& event); void OnEditCommand(wxCommandEvent& event); void OnEditSavePointReached(wxScintillaEvent& event); Index: mainframe.cpp =================================================================== RCS file: /cvsroot/simspark/simspark/contrib/rsgedit/mainframe.cpp,v retrieving revision 1.27 retrieving revision 1.28 diff -C2 -d -r1.27 -r1.28 *** mainframe.cpp 9 Jul 2007 18:42:09 -0000 1.27 --- mainframe.cpp 9 Jul 2007 18:49:08 -0000 1.28 *************** *** 127,130 **** --- 127,137 ---- EVT_MENU(wxID_SELECTALL, mainframe::OnEditCommand) + EVT_UPDATE_UI(wxID_UNDO, mainframe::OnUpdateEditCommand) + EVT_UPDATE_UI(wxID_REDO, mainframe::OnUpdateEditCommand) + EVT_UPDATE_UI(wxID_CUT, mainframe::OnUpdateEditCommand) + EVT_UPDATE_UI(wxID_COPY, mainframe::OnUpdateEditCommand) + EVT_UPDATE_UI(wxID_PASTE, mainframe::OnUpdateEditCommand) + EVT_UPDATE_UI(wxID_SELECTALL, mainframe::OnUpdateEditCommand) + EVT_SPARK_CONTEXT(ID_SPARK_CONTEXT, mainframe::OnSparkContext) END_EVENT_TABLE() *************** *** 1378,1386 **** { case wxID_UNDO: { ! if (edit->CanUndo()) ! { ! edit->Undo(); ! } break; } --- 1385,1427 ---- { case wxID_UNDO: + edit->Undo(); + break; + + case wxID_REDO: + edit->Redo(); + break; + + case wxID_CUT: + edit->Cut (); + break; + + case wxID_COPY: + edit->Copy (); + break; + + case wxID_PASTE: + edit->Paste(); + break; + + case wxID_SELECTALL: + edit->SetSelection (0, edit->GetLength()); + break; + } + } + + void mainframe::OnUpdateEditCommand(wxUpdateUIEvent& event) + { + wxScintilla* edit = dynamic_cast<wxScintilla*>(mCtrNotebook->GetCurrentPage()); + if (edit == 0) + { + event.Enable(false); + return; + } + + switch (event.GetId()) + { + case wxID_UNDO: { ! event.Enable(edit->CanUndo()); break; } *************** *** 1388,1395 **** case wxID_REDO: { ! if (edit->CanRedo()) ! { ! edit->Redo(); ! } break; --- 1429,1433 ---- case wxID_REDO: { ! event.Enable(edit->CanRedo()); break; *************** *** 1398,1408 **** case wxID_CUT: { ! if ( ! (! edit->GetReadOnly()) && ! (edit->GetSelectionEnd()-edit->GetSelectionStart() > 0) ! ) ! { ! edit->Cut (); ! } break; } --- 1436,1443 ---- case wxID_CUT: { ! event.Enable( ! (! edit->GetReadOnly()) && ! (edit->GetSelectionEnd()-edit->GetSelectionStart() > 0) ! ); break; } *************** *** 1410,1417 **** case wxID_COPY: { ! if (edit->GetSelectionEnd()-edit->GetSelectionStart() > 0) ! { ! edit->Copy (); ! } break; } --- 1445,1452 ---- case wxID_COPY: { ! event.Enable ! ( ! (edit->GetSelectionEnd()-edit->GetSelectionStart() > 0) ! ); break; } *************** *** 1419,1426 **** case wxID_PASTE: { ! if (edit->CanPaste()) ! { ! edit->Paste(); ! } break; } --- 1454,1458 ---- case wxID_PASTE: { ! event.Enable(edit->CanPaste()); break; } *************** *** 1428,1432 **** case wxID_SELECTALL: { ! edit->SetSelection (0, edit->GetLength()); break; } --- 1460,1464 ---- case wxID_SELECTALL: { ! event.Enable(true); break; } |