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
|
#include "StdAfx.h"
#include "T2Name.h"
#include "T2NameList.h"
#include "T2NameTable.h"
/*virtual*/ BOOL T2NameTable::OnT2DlgItemCreate(CREATESTRUCT* inCreateStruct) {
return T2DlgItemTable::OnT2DlgItemCreate(inCreateStruct);
}
T2NameTable::T2NameTable(T2TowerDoc* inDoc, T2ImageObj* inImageObj, CPalette* inPalette)
: T2VerticalTable(inDoc, inImageObj, inPalette)
{
}
T2Name* T2NameTable::GetSelectedName() {
T2Name *theName = NULL;
if (IsValidCell(mSelectedCell))
GetCellData(mSelectedCell, &theName);
return theName;
}
/*virtual*/ void T2NameTable::ClickSelf(POINT inPt) {
POINT pt = inPt;
ClientToView(&pt, 1);
TableCellT cell;
FetchCellHitBy(pt, cell);
if (IsValidCell(cell)) {
ClickCell(cell, inPt);
T2Name *theName;
GetCellData(cell, &theName);
BroadcastMessage(4201, theName);
}
}
/*virtual*/ void T2NameTable::OnT2DlgItemLButtonDown(UINT inFlags, CPoint inPt) {
ClickSelf(inPt);
}
/*virtual*/ void T2NameTable::Add(T2NameList* inNameList) {
if (inNameList) {
LArrayIterator iterator(*inNameList);
T2Name *name;
while (iterator.Next(&name))
Add(name);
}
}
/*virtual*/ void T2NameTable::Add(T2Name* inName) {
if (inName)
InsertRows(1, mRows, &inName);
}
/*virtual*/ void T2NameTable::RemoveCurrentCell() {
RemoveRows(1, mSelectedCell.row);
mSelectedCell.col = 0;
mSelectedCell.row = 0;
}
/*virtual*/ void T2NameTable::DrawCell(CDC* pDC, const TableCellT& inCell) {
int save = pDC->SaveDC();
pDC->SelectPalette(mPalette, false);
pDC->RealizePalette();
RECT rect;
if (FetchLocalCellFrame(inCell, rect)) {
T2Name *theName;
GetCellData(inCell, &theName);
if (theName) {
CString str;
unsigned int id;
int nameType = theName->GetName(str, id);
pDC->TextOut(rect.left + 4, rect.bottom - 2, str, strlen(str));
}
}
pDC->RestoreDC(save);
}
/*virtual*/ void T2NameTable::DrawCellSelf(CDC* pDC, const TableCellT& inCell, BOOL inSelected) {
DrawCell(pDC, inCell);
}
/*virtual*/ BOOL T2NameTable::OnT2DlgItemEraseBkgnd(CDC* pDC) {
unsigned int numOfRows, numOfColumns, theRow, theColumn;
GetTableSize(numOfRows, numOfColumns);
for (theColumn = 1; theColumn <= numOfColumns; theColumn++) {
for (theRow = 1; theRow <= numOfRows; theRow++) {
TableCellT cell;
cell.row = theRow;
cell.col = theColumn;
DrawCell(pDC, cell);
}
}
InvalidateRect(NULL);
return true;
}
|