OSDN Git Service

Revert command is implemented.
authortoshinagata1964 <toshinagata1964@a2be9bc6-48de-4e38-9406-05402d4bc13c>
Tue, 30 Oct 2012 00:37:39 +0000 (00:37 +0000)
committertoshinagata1964 <toshinagata1964@a2be9bc6-48de-4e38-9406-05402d4bc13c>
Tue, 30 Oct 2012 00:37:39 +0000 (00:37 +0000)
git-svn-id: svn+ssh://svn.sourceforge.jp/svnroot/molby/trunk@315 a2be9bc6-48de-4e38-9406-05402d4bc13c

wxSources/MyApp.cpp
wxSources/MyDocManager.cpp
wxSources/docview.cpp

index 5d8a297..0324a44 100755 (executable)
@@ -362,6 +362,7 @@ MyApp::CreateMenuBar(int kind, wxMenu **out_file_history_menu, wxMenu **out_edit
        file_menu->Append(wxID_CLOSE, _T("&Close\tCtrl-W"));
        file_menu->Append(wxID_SAVE, _T("&Save\tCtrl-S"));
        file_menu->Append(wxID_SAVEAS, _T("Save &As..."));      
+       file_menu->Append(wxID_REVERT, _T("Revert..."));        
        
        file_menu->AppendSeparator();
        file_menu->Append(myMenuID_Import, _T("Import..."));    
index ebf9ca5..a76e669 100644 (file)
@@ -25,6 +25,7 @@ BEGIN_EVENT_TABLE(MyDocManager, wxDocManager)
 EVT_MENU(wxID_OPEN, MyDocManager::OnFileOpen)
 EVT_MENU(wxID_SAVE, MyDocManager::OnFileSave)
 EVT_MENU(wxID_SAVEAS, MyDocManager::OnFileSaveAs)
+EVT_MENU(wxID_REVERT, MyDocManager::OnFileRevert)
 END_EVENT_TABLE()
 
 static const char *sReadOnlyTypes[] = {
index e382b26..909de4b 100644 (file)
@@ -410,12 +410,27 @@ wxOutputStream& wxDocument::SaveObject(wxOutputStream& stream)
     return stream;
 }
 
+/*  Taken from wxWidgets 2.9.3 and changed GetAppDisplayName() to GetAppName() */
 bool wxDocument::Revert()
 {
-    return false;
+    if ( wxMessageBox
+               (
+                _("Discard changes and reload the last saved version?"),
+                wxTheApp->GetAppName(),
+                wxYES_NO | wxCANCEL | wxICON_QUESTION,
+                GetDocumentWindow()
+                ) != wxYES )
+        return false;
+       
+    if ( !DoOpenDocument(GetFilename()) )
+        return false;
+       
+    Modify(false);
+    UpdateAllViews();
+       
+    return true;
 }
 
-
 // Get title, or filename if no title, else unnamed
 bool wxDocument::GetPrintableName(wxString& buf) const
 {
@@ -1092,10 +1107,11 @@ void wxDocManager::OnUpdateFileClose(wxUpdateUIEvent& event)
     event.Enable( (doc != (wxDocument*) NULL) );
 }
 
+/*  Taken from wxWidgets 2.9.3  */
 void wxDocManager::OnUpdateFileRevert(wxUpdateUIEvent& event)
 {
     wxDocument *doc = GetCurrentDocument();
-    event.Enable( (doc != (wxDocument*) NULL) );
+    event.Enable( (doc != (wxDocument*) NULL) && doc->IsModified() && doc->GetDocumentSaved() );
 }
 
 void wxDocManager::OnUpdateFileNew(wxUpdateUIEvent& event)