r144: Initial CVS import
[ctsim.git] / src / docs.cpp
1 /*****************************************************************************
2 ** FILE IDENTIFICATION
3 **
4 **   Name:          doc.cpp
5 **   Purpose:       Document routines for CTSim program
6 **   Programmer:    Kevin Rosenberg
7 **   Date Started:  July 2000
8 **
9 **  This is part of the CTSim program
10 **  Copyright (C) 1983-2000 Kevin Rosenberg
11 **
12 **  $Id: docs.cpp,v 1.1 2000/07/13 07:01:59 kevin Exp $
13 **
14 **  This program is free software; you can redistribute it and/or modify
15 **  it under the terms of the GNU General Public License (version 2) as
16 **  published by the Free Software Foundation.
17 **
18 **  This program is distributed in the hope that it will be useful,
19 **  but WITHOUT ANY WARRANTY; without even the implied warranty of
20 **  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
21 **  GNU General Public License for more details.
22 **
23 **  You should have received a copy of the GNU General Public License
24 **  along with this program; if not, write to the Free Software
25 **  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
26 ******************************************************************************/
27
28 #ifdef __GNUG__
29 // #pragma implementation
30 #endif
31
32 // For compilers that support precompilation, includes "wx/wx.h".
33 #include "wx/wxprec.h"
34
35 #ifdef __BORLANDC__
36 #pragma hdrstop
37 #endif
38
39 #ifndef WX_PRECOMP
40 #include "wx/wx.h"
41 #endif
42 #include "wx/txtstrm.h"
43
44 #if !wxUSE_DOC_VIEW_ARCHITECTURE
45 #error You must set wxUSE_DOC_VIEW_ARCHITECTURE to 1 in setup.h!
46 #endif
47
48 #include "docs.h"
49 #include "views.h"
50
51
52
53 // ImageFileDocument
54
55 IMPLEMENT_DYNAMIC_CLASS(ImageFileDocument, wxDocument)
56
57 bool ImageFileDocument::OnSaveDocument(const wxString& filename)
58 {
59     if (!m_imageFile.fileWrite (filename))
60         return false;
61     Modify(false);
62     return true;
63 }
64
65 bool ImageFileDocument::OnOpenDocument(const wxString& filename)
66 {
67     if (! m_imageFile.fileRead (filename))
68         return false;
69     
70     SetFilename(filename, true);
71     Modify(false);
72     UpdateAllViews();
73     return true;
74 }
75
76 bool ImageFileDocument::IsModified(void) const
77 {
78   return wxDocument::IsModified();
79 }
80
81 void ImageFileDocument::Modify(bool mod)
82 {
83     wxDocument::Modify(mod);
84 }
85
86 // ProjectionFileDocument
87
88 IMPLEMENT_DYNAMIC_CLASS(ProjectionFileDocument, wxDocument)
89
90 bool ProjectionFileDocument::OnSaveDocument(const wxString& filename)
91 {
92     if (!m_projectionFile.write (filename))
93         return false;
94     Modify(false);
95     return true;
96 }
97
98 bool ProjectionFileDocument::OnOpenDocument(const wxString& filename)
99 {
100     if (! m_projectionFile.read (filename))
101         return false;
102     
103     SetFilename(filename, true);
104     Modify(false);
105     UpdateAllViews();
106     return true;
107 }
108
109 bool ProjectionFileDocument::IsModified(void) const
110 {
111   return wxDocument::IsModified();
112 }
113
114 void ProjectionFileDocument::Modify(bool mod)
115 {
116     wxDocument::Modify(mod);
117 }