+
+// PlotFileDocument
+
+IMPLEMENT_DYNAMIC_CLASS(PlotFileDocument, wxDocument)
+
+bool PlotFileDocument::OnSaveDocument(const wxString& filename)
+{
+ m_namePlot = filename.c_str();
+ if (! m_plot.fileWrite (filename)) {
+ *theApp->getLog() << "Unable to write plot file " << filename << "\n";
+ return false;
+ }
+ *theApp->getLog() << "Wrote plot file " << filename << "\n";
+ Modify(false);
+ return true;
+}
+
+bool PlotFileDocument::OnOpenDocument(const wxString& filename)
+{
+ 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();
+ }
+ Modify (false);
+ UpdateAllViews();
+ GetFirstView()->OnUpdate (NULL, NULL);
+
+ return true;
+}
+
+
+bool PlotFileDocument::IsModified(void) const
+{
+ return wxDocument::IsModified();
+}
+
+void PlotFileDocument::Modify(bool mod)
+{
+ wxDocument::Modify(mod);
+}
+
+
+//////////////////////////////////////////////////////////////////////////
+//
+// TextEditDocument
+//
+//////////////////////////////////////////////////////////////////////////
+
+IMPLEMENT_DYNAMIC_CLASS(TextEditDocument, wxDocument)
+
+// Since text windows have their own method for saving to/loading from files,
+// we override OnSave/OpenDocument instead of Save/LoadObject
+bool TextEditDocument::OnSaveDocument(const wxString& filename)
+{
+ TextEditView *view = dynamic_cast<TextEditView*>(GetFirstView());
+ if (! view->getTextCtrl()->SaveFile(filename))
+ return false;
+ Modify(false);
+ return true;
+}
+
+bool TextEditDocument::OnOpenDocument(const wxString& filename)
+{
+ TextEditView *view = dynamic_cast<TextEditView*>(GetFirstView());
+
+ if (filename != "Log.txt" && ! view->getTextCtrl()->LoadFile(filename))
+ return false;
+
+ SetFilename (filename, true);
+ Modify (false);
+ UpdateAllViews();
+ return true;
+}
+
+bool TextEditDocument::IsModified(void) const
+{
+ return false;
+
+ TextEditView *view = dynamic_cast<TextEditView*>(GetFirstView());
+ if (view)
+ return (wxDocument::IsModified() || view->getTextCtrl()->IsModified());
+ else
+ return wxDocument::IsModified();
+}
+