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
|
#include "GlobalFunc.h"
#include "T2FloorInfo.h"
#include "T2FloorNumberTable.h"
#include "T2Mover.h"
#include "T2MoverModuleTable.h"
#include "T2TowerDoc.h"
T2FloorNumberTable::T2FloorNumberTable(T2TowerDoc* inDoc, T2ImageObj* inImageObj, CPalette* inPalette)
: T2DlgItemImageTable(inDoc, inImageObj, inPalette)
, mMover(NULL)
, mMoverModuleTable(NULL)
{
SetRect(&mRect, 0, 0, 0, 0);
_10C = 0;
_110 = 0;
}
/*virtual*/ T2FloorNumberTable::~T2FloorNumberTable() {
}
/*virtual*/ BOOL T2FloorNumberTable::Create(const char* inWindowName, DWORD inStyle, const RECT& inRect, CWnd* inParentWnd, UINT inID) {
return T2DlgItem::Create(inWindowName, inStyle, inRect, inParentWnd, inID);
}
void T2FloorNumberTable::SetMover(T2Mover* inMover) {
mMover = inMover;
InsertRows(mMover->GetLength(), 0, NULL);
}
void T2FloorNumberTable::SetMoverModuleTable(T2MoverModuleTable* inTable) {
mMoverModuleTable = inTable;
}
int T2FloorNumberTable::GetVScrValue() {
if (mMoverModuleTable)
return mMoverModuleTable->GetVScrValue();
else
return 0;
}
void T2FloorNumberTable::ClickCell(const TableCellT& inCell, POINT inPt) {
if (mMover) {
StflNotification info;
info.floorNumber = mRows - inCell.row;
info.theTable = this;
BroadcastMessage('stfl', &info);
}
}
void T2FloorNumberTable::RefreshCell(int inFloor) {
TableCellT theCell;
theCell.row = mRows - inFloor;
theCell.col = 1;
RECT cellRect;
if (FetchLocalCellFrame(theCell, cellRect))
InvalidateRect(&cellRect);
}
/*virtual*/ void T2FloorNumberTable::DrawCellSelf(CDC* pDC, const TableCellT& inCell, BOOL inSelected) {
if (mMover) {
RECT cellRect;
if (FetchLocalCellFrame(inCell, cellRect)) {
RECT theDrawArea = mRect;
OffsetRect(&theDrawArea, cellRect.left, cellRect.top);
T2FloorInfo *theFloorInfo = GetCurrentT2TowerDoc()->GetFloorInfo();
RECT moverArea;
mMover->GetEquipArea(moverArea);
int floor = mRows - inCell.row;
int floorNum = theFloorInfo->UnitToFloor(moverArea.top + inCell.row);
char buffer[256];
sprintf(buffer, "%d", floorNum);
int saveDC = pDC->SaveDC();
CBrush baseBrush;
baseBrush.CreateSolidBrush(RGB(255, 255, 255));
pDC->SelectObject(baseBrush);
pDC->SelectStockObject(BLACK_PEN);
pDC->Rectangle(&moverArea);
pDC->MoveTo(cellRect.left, cellRect.bottom - 1);
pDC->LineTo(cellRect.right - 1, cellRect.bottom - 1);
InflateRect(&theDrawArea, 1, 1);
pDC->DrawText(buffer, strlen(buffer), &theDrawArea, DT_CENTER | DT_VCENTER | DT_SINGLELINE);
if (!mMover->IsStopPosition(floor)) {
pDC->SetTextColor(_110);
pDC->MoveTo(theDrawArea.left, theDrawArea.top);
pDC->LineTo(theDrawArea.right - 1, theDrawArea.bottom - 1);
pDC->MoveTo(theDrawArea.left, theDrawArea.bottom - 1);
pDC->LineTo(theDrawArea.right - 1, theDrawArea.top);
}
pDC->RestoreDC(saveDC);
}
}
}
/*virtual*/ BOOL T2FloorNumberTable::OnT2DlgItemEraseBkgnd(CDC* pDC) {
RECT theTableRect, cellFrame;
GetClientRect(&theTableRect);
unsigned int height, width;
GetTableSize(height, width);
int position = GetVScrValue() * mRowHeight;
for (unsigned int x = 1; x <= width; x++) {
for (unsigned int y = 1; y <= height; y++) {
TableCellT cell;
cell.row = y;
cell.col = x;
if (FetchLocalCellFrame(cell, cellFrame)) {
OffsetRect(&cellFrame, 0, -position);
BOOL isVisible = IntersectRect(&cellFrame, &cellFrame, &theTableRect);
if (isVisible)
DrawCellSelf(pDC, cell, false);
}
}
}
InvalidateRect(&cellFrame);
return true;
}
/*virtual*/ void T2FloorNumberTable::OnT2DlgItemLButtonDown(UINT inFlags, CPoint inPt) {
POINT pt = inPt;
ClientToView(&pt, 1);
TableCellT cell;
FetchCellHitBy(pt, cell);
ClickCell(cell, inPt);
}
/*virtual*/ void T2FloorNumberTable::OnT2DlgItemLButtonUp(UINT inFlags, CPoint inPt) {
}
/*virtual*/ void T2FloorNumberTable::OnT2DlgItemMouseMove(UINT inFlags, CPoint inPt) {
}
|