- if (filename == "untitled.plt") {
- wxString untitledFilename = theApp->getUntitledFilename();
- SetFilename (untitledFilename, true);
- } else {
- if (! m_plot.fileRead (filename.c_str())) {
- *theApp->getLog() << "Unable to read plot file " << filename << "\n";
- return false;
- }
- *theApp->getLog() << "Read plot file " << filename << "\n";
- SetFilename (filename, true);
- m_namePlot = filename.c_str();
+ if (! OnSaveModified())
+ return false;
+
+ if (! m_plot.fileRead (filename.mb_str(wxConvUTF8))) {
+ *theApp->getLog() << _T("Unable to read plot file ") << filename << _T("\n");
+ m_bBadFileOpen = true;
+ return false;
+ }
+ m_bBadFileOpen = false;
+
+ if (theApp->getVerboseLogging() && filename != _T(""))
+ *theApp->getLog() << _T("Read plot file ") << filename << _T("\n");
+
+ SetFilename (filename, true);
+ m_namePlot = filename.c_str();
+ Modify (false);
+ getView()->setInitialClientSize();
+ UpdateAllViews();
+
+ return true;
+}
+
+
+bool
+PlotFileDocument::IsModified(void) const
+{
+ return wxDocument::IsModified();
+}
+
+void
+PlotFileDocument::Modify (bool mod)
+{
+ wxDocument::Modify(mod);
+}
+
+PlotFileView*
+PlotFileDocument::getView() const
+{
+ return dynamic_cast<PlotFileView*>(GetFirstView());
+}
+
+void
+PlotFileDocument::Activate()
+{
+#if CTSIM_MDI
+ getView()->getFrame()->Activate();
+#endif
+};
+
+//////////////////////////////////////////////////////////////////////////
+//
+// TextFileDocument
+//
+//////////////////////////////////////////////////////////////////////////
+
+IMPLEMENT_DYNAMIC_CLASS(TextFileDocument, wxDocument)
+
+bool
+TextFileDocument::OnSaveDocument(const wxString& filename)
+{
+ TextFileView *view = getView();
+ if (! view->getTextCtrl()->SaveFile(filename))
+ return false;
+ Modify(false);
+ return true;
+}
+
+bool
+TextFileDocument::OnOpenDocument(const wxString& filename)
+{
+ TextFileView *view = getView();
+
+ if (! view->getTextCtrl()->LoadFile(filename)) {
+ m_bBadFileOpen = true;
+ return false;