** This is part of the CTSim program
** Copyright (C) 1983-2000 Kevin Rosenberg
**
-** $Id: docs.cpp,v 1.12 2001/01/06 15:33:15 kevin Exp $
+** $Id: docs.cpp,v 1.14 2001/01/20 17:43:41 kevin Exp $
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License (version 2) as
wxDocument::Modify(mod);
}
-bool ImageFileDocument::OnCloseDocument ()
-{
- bool bReturn = wxDocument::OnCloseDocument();
- return bReturn;
-}
// ProjectionFileDocument
}
-bool ProjectionFileDocument::OnCloseDocument ()
-{
- bool bReturn = wxDocument::OnCloseDocument();
- return bReturn;
-}
// PhantomDocument
return true;
}
-bool PhantomDocument::OnCloseDocument ()
-{
- bool bReturn = wxDocument::OnCloseDocument();
- return bReturn;
-}
-
bool PhantomDocument::IsModified(void) const
{
- return wxDocument::IsModified();
+ return false;
}
void PhantomDocument::Modify(bool mod)
return true;
}
-bool PlotFileDocument::OnCloseDocument ()
-{
- bool bReturn = wxDocument::OnCloseDocument();
- return bReturn;
-}
bool PlotFileDocument::IsModified(void) const
{
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();
+}
+