-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathObFileTreeDlg.cpp
340 lines (277 loc) · 12.1 KB
/
ObFileTreeDlg.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
/*===========================================================================
*
* File: Obfiletreedlg.CPP
* Author: Dave Humphrey ([email protected])
* Created On: August 4, 2006
*
* Description
*
*=========================================================================*/
/* Include Files */
#include "stdafx.h"
#include "obedit.h"
#include "ObFileTreeDlg.h"
/*===========================================================================
*
* Begin Local Definitions
*
*=========================================================================*/
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/*===========================================================================
* End of Local Definitions
*=========================================================================*/
/*===========================================================================
*
* Begin Message Map
*
*=========================================================================*/
BEGIN_MESSAGE_MAP(CObFileTreeDlg, CDialog)
//{{AFX_MSG_MAP(CObFileTreeDlg)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/*===========================================================================
* End of Message Map
*=========================================================================*/
/*===========================================================================
*
* Class CObFileTreeDlg Constructor
*
*=========================================================================*/
CObFileTreeDlg::CObFileTreeDlg(CWnd* pParent) : CDialog(CObFileTreeDlg::IDD, pParent) {
//{{AFX_DATA_INIT(CObFileTreeDlg)
//}}AFX_DATA_INIT
//m_pEspFile = NULL;
m_pTopGroup = NULL;
}
/*===========================================================================
* End of Class CObFileTreeDlg Constructor
*=========================================================================*/
/*===========================================================================
*
* Class CObFileTreeDlg Method - void CreateTree (void);
*
*=========================================================================*/
void CObFileTreeDlg::CreateTree (void) {
/* Clear the current contents */
m_FileTree.DeleteAllItems();
if (m_pTopGroup == NULL) return;
CreateTree(m_pTopGroup, m_FileTree.GetRootItem());
}
/*===========================================================================
* End of Class Method CObFileTreeDlg::CreateTree()
*=========================================================================*/
/*===========================================================================
*
* Class CObFileTreeDlg Method - void CreateTree (pTopGroup, hParent);
*
*=========================================================================*/
void CObFileTreeDlg::CreateTree (CObGroup* pTopGroup, HTREEITEM hParent) {
CObBaseRecord* pBaseRecord;
dword Index;
HTREEITEM hFile;
/* Add the file node */
hFile = m_FileTree.InsertItem("Filename TODO", hParent);
/* Add the file contents */
for (Index = 0; Index < pTopGroup->GetNumRecords(); ++Index) {
pBaseRecord = pTopGroup->GetRecord(Index);
if (pBaseRecord == NULL) continue;
AddTreeRecord(pBaseRecord, hFile);
}
}
/*===========================================================================
* End of Class Method CObFileTreeDlg::CreateTree()
*=========================================================================*/
/*===========================================================================
*
* Class CObFileTreeDlg Method - void AddTreeRecord (pBaseRecord, hParent);
*
*=========================================================================*/
void CObFileTreeDlg::AddTreeRecord (CObBaseRecord* pBaseRecord, HTREEITEM hParent) {
CObGroup* pGroup;
CObTypeGroup* pTypeGroup;
CObGridGroup* pGridGroup;
CObBlockGroup* pBlockGroup;
CObFormIDGroup* pFormIDGroup;
int test = pBaseRecord->GetMyClassType();
/* Determine the type of the record */
switch (pBaseRecord->GetMyClassType()) {
case OBCLASS_CObGroup:
pGroup = ObCastClass(CObGroup, pBaseRecord);
AddTreeGroup(pGroup, hParent);
break;
case OBCLASS_CObTypeGroup:
pTypeGroup = ObCastClass(CObTypeGroup, pBaseRecord);
AddTreeTypeGroup(pTypeGroup, hParent);
break;
case OBCLASS_CObFormIDGroup:
pFormIDGroup = ObCastClass(CObFormIDGroup, pBaseRecord);
AddTreeFormIDGroup(pFormIDGroup, hParent);
break;
case OBCLASS_CObBlockGroup:
pBlockGroup = ObCastClass(CObBlockGroup, pBaseRecord);
AddTreeBlockGroup(pBlockGroup, hParent);
break;
case OBCLASS_CObGridGroup:
pGridGroup = ObCastClass(CObGridGroup, pBaseRecord);
AddTreeGridGroup(pGridGroup, hParent);
break;
case OBCLASS_CObBaseRecord:
case OBCLASS_CObRecord:
default:
break;
}
}
/*===========================================================================
* End of Class Method CObFileTreeDlg::AddTreeRecord()
*=========================================================================*/
/*===========================================================================
*
* Class CObFileTreeDlg Method - void AddTreeGroupChildren (pGroup, hParent);
*
*=========================================================================*/
void CObFileTreeDlg::AddTreeGroupChildren (CObGroup* pGroup, HTREEITEM hParent) {
CObBaseRecord* pBaseRecord;
dword Index;
/* Add the group contents */
for (Index = 0; Index < pGroup->GetNumRecords(); ++Index) {
pBaseRecord = pGroup->GetRecord(Index);
if (pBaseRecord == NULL) continue;
AddTreeRecord(pBaseRecord, hParent);
}
}
/*===========================================================================
* End of Class Method CObFileTreeDlg::AddTreeGroupChildren()
*=========================================================================*/
/*===========================================================================
*
* Class CObFileTreeDlg Method - void AddTreeGroup (pGroup, hParent);
*
*=========================================================================*/
void CObFileTreeDlg::AddTreeGroup (CObGroup* pGroup, HTREEITEM hParent) {
CString Buffer;
HTREEITEM hItem;
if (pGroup == NULL) return;
Buffer.Format(_T("General Group -- %u records"), pGroup->GetNumRecords());
hItem = m_FileTree.InsertItem(Buffer, hParent);
AddTreeGroupChildren(pGroup, hItem);
}
/*===========================================================================
* End of Class Method CObFileTreeDlg::AddTreeGroup()
*=========================================================================*/
/*===========================================================================
*
* Class CObFileTreeDlg Method - void AddTreeTypeGroup (pGroup, hParent);
*
*=========================================================================*/
void CObFileTreeDlg::AddTreeTypeGroup (CObTypeGroup* pGroup, HTREEITEM hParent) {
CString Buffer;
HTREEITEM hItem;
if (pGroup == NULL) return;
Buffer.Format(_T("Type Group (%4.4s)-- %u records"), pGroup->GetContainsType().Name, pGroup->GetNumRecords());
hItem = m_FileTree.InsertItem(Buffer, hParent);
AddTreeGroupChildren(pGroup, hItem);
}
/*===========================================================================
* End of Class Method CObFileTreeDlg::AddTreeTypeGroup()
*=========================================================================*/
/*===========================================================================
*
* Class CObFileTreeDlg Method - void AddTreeFormIDGroup (pGroup, hParent);
*
*=========================================================================*/
void CObFileTreeDlg::AddTreeFormIDGroup (CObFormIDGroup* pGroup, HTREEITEM hParent) {
CString Buffer;
CString TypeBuffer;
HTREEITEM hItem;
if (pGroup == NULL) return;
switch (pGroup->GetType()) {
case OB_GROUP_WORLDCHILD: TypeBuffer = "World Child"; break;
case OB_GROUP_CELLCHILD: TypeBuffer = "Cell Child"; break;
case OB_GROUP_TOPICCHILD: TypeBuffer = "Topic Child"; break;
case OB_GROUP_CELLPERSIST: TypeBuffer = "Cell Persist"; break;
case OB_GROUP_CELLTEMP: TypeBuffer = "Cell Temp"; break;
case OB_GROUP_CELLDISTANT: TypeBuffer = "Cell Distance"; break;
default: TypeBuffer = "Unknown"; break;
}
Buffer.Format(_T("%s Group (0x%08X) -- %u records"), TypeBuffer, pGroup->GetParentFormID(), pGroup->GetNumRecords());
hItem = m_FileTree.InsertItem(Buffer, hParent);
AddTreeGroupChildren(pGroup, hItem);
}
/*===========================================================================
* End of Class Method CObFileTreeDlg::AddTreeFormIDGroup()
*=========================================================================*/
/*===========================================================================
*
* Class CObFileTreeDlg Method - void AddTreeBlockGroup (pGroup, hParent);
*
*=========================================================================*/
void CObFileTreeDlg::AddTreeBlockGroup (CObBlockGroup* pGroup, HTREEITEM hParent) {
CString Buffer;
CString TypeBuffer;
HTREEITEM hItem;
if (pGroup == NULL) return;
switch (pGroup->GetType()) {
case OB_GROUP_INTCELL: TypeBuffer = "Interior Cell"; break;
case OB_GROUP_INTSUBCELL: TypeBuffer = "Interior Sub-Cell"; break;
default: TypeBuffer = "Unknown"; break;
}
Buffer.Format(_T("%s Group (%d) -- %u records"), TypeBuffer, pGroup->GetBlock(), pGroup->GetNumRecords());
hItem = m_FileTree.InsertItem(Buffer, hParent);
AddTreeGroupChildren(pGroup, hItem);
}
/*===========================================================================
* End of Class Method CObFileTreeDlg::AddTreeBlockGroup()
*=========================================================================*/
/*===========================================================================
*
* Class CObFileTreeDlg Method - void AddTreeGridGroup (pGroup, hParent);
*
*=========================================================================*/
void CObFileTreeDlg::AddTreeGridGroup (CObGridGroup* pGroup, HTREEITEM hParent) {
CString Buffer;
CString TypeBuffer;
HTREEITEM hItem;
if (pGroup == NULL) return;
switch (pGroup->GetType()) {
case OB_GROUP_EXTCELL: TypeBuffer = "Exterior Cell"; break;
case OB_GROUP_EXTSUBCELL: TypeBuffer = "Exterior Sub-Cell"; break;
default: TypeBuffer = "Unknown"; break;
}
Buffer.Format(_T("%s Group (%d, %d) -- %u records"), TypeBuffer, pGroup->GetGridX(), pGroup->GetGridY(), pGroup->GetNumRecords());
hItem = m_FileTree.InsertItem(Buffer, hParent);
AddTreeGroupChildren(pGroup, hItem);
}
/*===========================================================================
* End of Class Method CObFileTreeDlg::AddTreeGridGroup()
*=========================================================================*/
/*===========================================================================
*
* Class CObFileTreeDlg Method - void DoDataExchange (pDX);
*
*=========================================================================*/
void CObFileTreeDlg::DoDataExchange (CDataExchange* pDX) {
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CObFileTreeDlg)
DDX_Control(pDX, IDC_TREECTRL, m_FileTree);
//}}AFX_DATA_MAP
}
/*===========================================================================
* End of Class Method CObFileTreeDlg::DoDataExchange()
*=========================================================================*/
/*===========================================================================
*
* Class CObFileTreeDlg Event - BOOL OnInitDialog ();
*
*=========================================================================*/
BOOL CObFileTreeDlg::OnInitDialog() {
CDialog::OnInitDialog();
CreateTree();
return (TRUE);
}
/*===========================================================================
* End of Class Event CObFileTreeDlg::OnInitDialog()
*=========================================================================*/