]> icculus.org git repositories - taylor/freespace2.git/blob - src/helped/helpeddoc.cpp
Initial revision
[taylor/freespace2.git] / src / helped / helpeddoc.cpp
1 // HelpEdDoc.cpp : implementation of the CHelpEdDoc class
2 //
3
4 #include "stdafx.h"
5 #include "helped.h"
6
7 #include "helpeddoc.h"
8
9 #ifdef _DEBUG
10 #define new DEBUG_NEW
11 #undef THIS_FILE
12 static char THIS_FILE[] = __FILE__;
13 #endif
14
15 /////////////////////////////////////////////////////////////////////////////
16 // CHelpEdDoc
17
18 IMPLEMENT_DYNCREATE(CHelpEdDoc, CDocument)
19
20 BEGIN_MESSAGE_MAP(CHelpEdDoc, CDocument)
21         //{{AFX_MSG_MAP(CHelpEdDoc)
22                 // NOTE - the ClassWizard will add and remove mapping macros here.
23                 //    DO NOT EDIT what you see in these blocks of generated code!
24         //}}AFX_MSG_MAP
25 END_MESSAGE_MAP()
26
27 /////////////////////////////////////////////////////////////////////////////
28 // CHelpEdDoc construction/destruction
29
30 CHelpEdDoc::CHelpEdDoc()
31 {
32         // TODO: add one-time construction code here
33
34 }
35
36 CHelpEdDoc::~CHelpEdDoc()
37 {
38 }
39
40 BOOL CHelpEdDoc::OnNewDocument()
41 {
42         if (!CDocument::OnNewDocument())
43                 return FALSE;
44
45         // TODO: add reinitialization code here
46         // (SDI documents will reuse this document)
47
48         return TRUE;
49 }
50
51
52
53 /////////////////////////////////////////////////////////////////////////////
54 // CHelpEdDoc serialization
55
56 void CHelpEdDoc::Serialize(CArchive& ar)
57 {
58         if (ar.IsStoring())
59         {
60                 // TODO: add storing code here
61         }
62         else
63         {
64                 // TODO: add loading code here
65         }
66 }
67
68 /////////////////////////////////////////////////////////////////////////////
69 // CHelpEdDoc diagnostics
70
71 #ifdef _DEBUG
72 void CHelpEdDoc::AssertValid() const
73 {
74         CDocument::AssertValid();
75 }
76
77 void CHelpEdDoc::Dump(CDumpContext& dc) const
78 {
79         CDocument::Dump(dc);
80 }
81 #endif //_DEBUG
82
83 /////////////////////////////////////////////////////////////////////////////
84 // CHelpEdDoc commands
85
86 HelpEdLine * CHelpEdDoc::AddLine(CPoint pointFrom, CPoint pointTo)
87 {
88         // create a new line
89         HelpEdLine *newline = new HelpEdLine(pointFrom, pointTo);
90         try {
91                 // add this line to object array
92                 line_array.Add(newline);
93                 // mark document dirty
94                 SetModifiedFlag();
95         }
96         // check for memory exception
97         catch (CMemoryException* addlineerror) {
98                 // display error message in pop box
99                 AfxMessageBox("Out of memory", MB_ICONSTOP | MB_OK);
100                 // if we created a HelpEdLine object, we should delete it
101                 if (newline) {
102                         delete newline;
103                         newline = NULL;
104                 }
105                 // delete the error message
106                 addlineerror->Delete();
107         }
108         return newline;
109 }
110
111 int CHelpEdDoc::get_line_count()
112 {
113         // return line_array size
114         return line_array.GetSize();
115 }