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..."));
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[] = {
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
{
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)