From: Markus R. <rol...@us...> - 2007-06-23 13:13:03
|
Update of /cvsroot/simspark/simspark/contrib/rsgedit In directory sc8-pr-cvs8.sourceforge.net:/tmp/cvs-serv20637 Modified Files: Tag: RSGEDIT_SCINTILLA mainframe.cpp Log Message: - notify user when closing modified tabs Index: mainframe.cpp =================================================================== RCS file: /cvsroot/simspark/simspark/contrib/rsgedit/mainframe.cpp,v retrieving revision 1.21.2.12 retrieving revision 1.21.2.13 diff -C2 -d -r1.21.2.12 -r1.21.2.13 *** mainframe.cpp 23 Jun 2007 11:11:14 -0000 1.21.2.12 --- mainframe.cpp 23 Jun 2007 13:13:00 -0000 1.21.2.13 *************** *** 246,254 **** { wxString title(wxT("SimSpark")); ! ! wxString simFName = SparkEdit::GetStartScriptFile(); ! if (! simFName.empty()) { ! title += wxT(" <") + simFName + wxT(">"); } --- 246,252 ---- { wxString title(wxT("SimSpark")); ! if (SparkEdit::GetStartScript() != 0) { ! title += wxT(" <") + SparkEdit::GetStartScriptFile() + wxT(">"); } *************** *** 368,371 **** --- 366,386 ---- } + int n = mCtrNotebook->GetPageCount(); + + for (int i=(n-1);i>=0;--i) + { + wxWindow* page = mCtrNotebook->GetPage(i); + if (page == mCanvas) + { + continue; + } + + if (! mCtrNotebook->RemovePage(i)) + { + event.Veto(); + return; + } + } + // close agentframes wxWindowList& children = GetChildren(); *************** *** 1014,1019 **** return; } ! ! SaveModified(); SelectCanvasTab(); OpenSimulation(simName); --- 1029,1034 ---- return; } ! ! SaveModified(); SelectCanvasTab(); OpenSimulation(simName); *************** *** 1171,1180 **** wxScintilla* edit = dynamic_cast<wxScintilla*>(page); ! if (edit != 0) { ! SparkEdit::PutEdit(edit); ! UpdateTitle(); } event.Skip(); } --- 1186,1228 ---- wxScintilla* edit = dynamic_cast<wxScintilla*>(page); ! if (edit == 0) { ! event.Skip(); ! return; } + if (edit->GetModify()) + { + int res = wxMessageBox("The file '"+SparkEdit::GetFile(edit)+"' is modified.\n" + "Do you want to save your changes?", + "rsgedit", + wxYES_NO|wxCANCEL|wxICON_QUESTION + ); + + switch (res) + { + default: + assert(false); + // fall through + + case wxCANCEL: + event.Veto(); + return; + + case wxYES: + SparkEdit::SaveFile(edit); + break; + + case wxNO: + break; + } + } + + if (edit != 0) + { + SparkEdit::PutEdit(edit); + UpdateTitle(); + } + event.Skip(); } |