summaryrefslogtreecommitdiffabout
path: root/T42Document.cpp
authorMichael Krelin <hacker@klever.net>2004-07-05 01:53:09 (UTC)
committer Michael Krelin <hacker@klever.net>2004-07-05 01:53:09 (UTC)
commit955d4e00adc9f39ab93bf21f07506eb75b013c70 (patch) (unidiff)
tree92493a2c9ac206b822e24a9e5a6f6b1589be6afb /T42Document.cpp
downloadT42-955d4e00adc9f39ab93bf21f07506eb75b013c70.zip
T42-955d4e00adc9f39ab93bf21f07506eb75b013c70.tar.gz
T42-955d4e00adc9f39ab93bf21f07506eb75b013c70.tar.bz2
initial commit into svn repository
git-svn-id: http://svn.klever.net/kin/T42/trunk@1 fe716a7a-6dde-0310-88d9-d003556173a8
Diffstat (limited to 'T42Document.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--T42Document.cpp181
1 files changed, 181 insertions, 0 deletions
diff --git a/T42Document.cpp b/T42Document.cpp
new file mode 100644
index 0000000..3eeb427
--- a/dev/null
+++ b/T42Document.cpp
@@ -0,0 +1,181 @@
1// T42Document.cpp : implementation file
2//
3
4#include "stdafx.h"
5#include "T42.h"
6#include "T42Document.h"
7
8#include "T42View.h"
9#include "T42Frame.h"
10
11#ifdef _DEBUG
12#define new DEBUG_NEW
13#undef THIS_FILE
14static char THIS_FILE[] = __FILE__;
15#endif
16
17/////////////////////////////////////////////////////////////////////////////
18// T42Document
19
20IMPLEMENT_DYNCREATE(T42Document, CDocument)
21
22T42Document::T42Document()
23{
24 m_pView=NULL;
25 m_pRobot = NULL;
26 m_bHidden = FALSE;
27}
28
29BOOL T42Document::OnNewDocument()
30{
31 if (!CDocument::OnNewDocument())
32 return FALSE;
33 return TRUE;
34}
35
36T42Document::~T42Document()
37{
38 if(m_pRobot)
39 DetachRobot();
40}
41
42
43BEGIN_MESSAGE_MAP(T42Document, CDocument)
44 //{{AFX_MSG_MAP(T42Document)
45 ON_COMMAND(ID_WINDOW_SAVELAYOUT, OnWindowSavelayout)
46 ON_UPDATE_COMMAND_UI(ID_WINDOW_AUTOSAVELAYOUT, OnUpdateWindowAutosavelayout)
47 ON_COMMAND(ID_WINDOW_AUTOSAVELAYOUT, OnWindowAutosavelayout)
48 //}}AFX_MSG_MAP
49END_MESSAGE_MAP()
50
51/////////////////////////////////////////////////////////////////////////////
52// T42Document diagnostics
53
54#ifdef _DEBUG
55void T42Document::AssertValid() const
56{
57 CDocument::AssertValid();
58}
59
60void T42Document::Dump(CDumpContext& dc) const
61{
62 CDocument::Dump(dc);
63}
64#endif //_DEBUG
65
66/////////////////////////////////////////////////////////////////////////////
67// T42Document serialization
68
69void T42Document::Serialize(CArchive& ar)
70{
71 if (ar.IsStoring())
72 {
73 }
74 else
75 {
76 }
77}
78
79/////////////////////////////////////////////////////////////////////////////
80// T42Document commands
81
82void T42Document::Talk(LPCTSTR from,LPCTSTR to,LPCTSTR tty,BOOL bPrompt)
83{
84 ASSERT(m_pView);
85 ASSERT(m_pView->m_pFrame);
86 m_pView->m_pFrame->m_Target = to?to:"";
87 m_pView->m_pFrame->m_LocalUser = from?from:"";
88 m_pView->m_pFrame->m_TargetTTY = tty?tty:"";
89 if(bPrompt || !(to && from))
90 m_pView->m_pFrame->PostMessage(WM_COMMAND,MAKELONG(ID_TALK_REMOTEUSER,0),NULL);
91 else
92 m_pView->m_pFrame->PostMessage(WM_INITIATETALK);
93}
94
95void T42Document::OnChangedViewList()
96{
97 CDocument::OnChangedViewList();
98POSITION p = GetFirstViewPosition();
99 m_pView=NULL;
100 while(p){
101 CView* pView = GetNextView(p);
102 ASSERT_KINDOF(T42View,pView);
103 ASSERT(!m_pView);
104 m_pView=(T42View*)pView;
105 }
106}
107
108void T42Document::SaveLayout()
109{
110 ASSERT(m_pView);
111 m_pView->SaveLayout();
112 ASSERT(m_pView->m_pFrame);
113 m_pView->m_pFrame->SaveLayout();
114}
115
116void T42Document::OnWindowSavelayout()
117{
118 SaveLayout();
119}
120
121void T42Document::OnUpdateWindowAutosavelayout(CCmdUI* pCmdUI)
122{
123CT42App* app = (CT42App*)AfxGetApp();
124 pCmdUI->SetCheck(app->m_bt42AutosaveLayout?1:0);
125}
126
127void T42Document::OnWindowAutosavelayout()
128{
129CT42App* app = (CT42App*)AfxGetApp();
130 app->m_bt42AutosaveLayout=!app->m_bt42AutosaveLayout;
131}
132
133void T42Document::AutosaveLayout()
134{
135CT42App* app = (CT42App*)AfxGetApp();
136 if(app->m_bt42AutosaveLayout)
137 SaveLayout();
138}
139
140BOOL T42Document::AttachRobot(CT42Robot* pRobot)
141{
142 if(m_pRobot)
143 DetachRobot();
144 m_pRobot = pRobot;
145 return m_pRobot->OnAttach(this);
146}
147
148BOOL T42Document::DetachRobot()
149{
150 ASSERT(m_pRobot);
151BOOL rv = m_pRobot->OnDetach();
152 m_pRobot=NULL;
153 return rv;
154}
155
156BOOL T42Document::SendOver(LPCTSTR str)
157{
158 // *** Or call T42View function?
159 for(LPCTSTR ptr=str;*ptr;ptr++){
160 m_pView->m_localCtl.PutCharacter(*ptr);
161 m_pView->m_pFrame->PostMessage(WM_TALKCHAR,0xFF&((WORD)*ptr));
162 }
163 return TRUE;
164}
165
166BOOL T42Document::OnOpenDocument(LPCTSTR lpszPathName)
167{
168 //if (!CDocument::OnOpenDocument(lpszPathName))
169 // return FALSE;
170
171 if(lpszPathName)
172 m_bHidden = TRUE;
173
174 return TRUE;
175}
176
177void T42Document::OnMinute()
178{
179 if(m_pRobot)
180 m_pRobot->OnMinute();
181}