X-Git-Url: http://git.kpe.io/?p=ctsim.git;a=blobdiff_plain;f=src%2Fdocs.cpp;h=8bdb8d017925ec936583ec51403c3e78c00f4007;hp=4520551adca8ecf90b27465828894c51b0e00474;hb=a5d437cb4228b07f8c005eaca497c317b8c19d14;hpb=01ed72399d433ce45a0195f8acaea349a421461e diff --git a/src/docs.cpp b/src/docs.cpp index 4520551..8bdb8d0 100644 --- a/src/docs.cpp +++ b/src/docs.cpp @@ -9,7 +9,7 @@ ** This is part of the CTSim program ** Copyright (C) 1983-2000 Kevin Rosenberg ** -** $Id: docs.cpp,v 1.13 2001/01/20 08:10:33 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 @@ -242,3 +242,47 @@ 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(GetFirstView()); + if (! view->getTextCtrl()->SaveFile(filename)) + return false; + Modify(false); + return true; +} + +bool TextEditDocument::OnOpenDocument(const wxString& filename) +{ + TextEditView *view = dynamic_cast(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(GetFirstView()); + if (view) + return (wxDocument::IsModified() || view->getTextCtrl()->IsModified()); + else + return wxDocument::IsModified(); +} +