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
|
#include "StdAfx.h"
#include "T2DLL/T2PeopleDemandList.h"
#include "T2DLL/T2PeopleTimeZoneList.h"
#include "T2DLL/T2PeopleType.h"
#include "T2DLL/T2PeopleTypeArray.h"
#include "T2DLL/T2Pool.h"
#include "T2PoolView.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
#line 17
IMPLEMENT_DYNCREATE(T2PoolView, CFrameWnd)
T2PoolView::T2PoolView() {
mPool = NULL;
}
T2PoolView::~T2PoolView() {
}
BEGIN_MESSAGE_MAP(T2PoolView, CFrameWnd)
//{{AFX_MSG_MAP(T2PoolView)
ON_WM_ERASEBKGND()
ON_WM_VSCROLL()
ON_WM_LBUTTONDOWN()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
void T2PoolView::SetPool(T2Pool *inPool) {
mPool = inPool;
InvalidateRect(NULL);
}
BOOL T2PoolView::OnEraseBkgnd(CDC *pDC) {
Draw(pDC, NULL, NULL, NULL, NULL);
return true;
}
void T2PoolView::OnVScroll(UINT nSBCode, UINT nPos, CScrollBar *pScrollBar) {
int minPos, maxPos;
GetScrollRange(SB_VERT, &minPos, &maxPos);
int pos = GetScrollPos(SB_VERT);
switch (nSBCode) {
case SB_THUMBPOSITION:
case SB_THUMBTRACK:
pos = nPos;
break;
}
SetScrollPos(SB_VERT, pos);
InvalidateRect(NULL);
}
void T2PoolView::OnLButtonDown(UINT nFlags, CPoint point) {
T2PeopleTimeZoneList *peopleTimeZoneList = NULL;;
T2PeopleTypeArray *peopleTypeArray = NULL;
int weirdUnusedVariable = 0; // arbitrary name chosen to fit in
CDC *pDC = GetDC();
Draw(pDC, &point, &peopleTimeZoneList, &peopleTypeArray, &weirdUnusedVariable);
if (peopleTimeZoneList && !peopleTypeArray && !weirdUnusedVariable)
peopleTimeZoneList->_20 = !peopleTimeZoneList->_20;
if (peopleTimeZoneList && peopleTypeArray && !weirdUnusedVariable)
peopleTypeArray->m20 = !peopleTypeArray->m20;
ReleaseDC(pDC);
InvalidateRect(NULL);
}
void T2PoolView::Draw(CDC *pDC, CPoint *inPt, T2PeopleTimeZoneList **outTimeZoneList, T2PeopleTypeArray **outPeopleTypeArray, int *outUnknown) {
#pragma var_order(peopleTimeZoneList, peopleDemandListIterator, peopleDemandList, str, font, save, totalPopulation, x, height, y, rect, pt, brush)
if (!mPool)
return;
CPoint pt;
if (inPt) {
pt = *inPt;
} else {
pt.x = 0;
pt.y = 0;
}
int save = pDC->SaveDC();
CRect rect;
GetClientRect(rect);
pDC->SetTextColor(RGB(0, 0, 0));
pDC->SetBkColor(RGB(255, 255, 255));
CBrush brush;
brush.CreateStockObject(WHITE_BRUSH);
if (!inPt)
pDC->FillRect(rect, &brush);
CFont font;
font.CreateFont(-12, 0, 0, 0, FW_NORMAL, false, false, false, SHIFTJIS_CHARSET, OUT_TT_PRECIS, CLIP_TT_ALWAYS, DRAFT_QUALITY, DEFAULT_PITCH, "\x82\x6C\x82\x72 \x83\x53\x83\x56\x83\x62\x83\x4E");
pDC->SelectObject(&font);
int height = pDC->GetTextExtent("A").cy + 1;
int x = 4;
int y = -GetScrollPos(SB_VERT);
CString str;
T2PeopleDemandList *peopleDemandList = mPool->mDemandList;
LArrayIterator peopleDemandListIterator(*peopleDemandList);
T2PeopleTimeZoneList *peopleTimeZoneList;
int totalPopulation = 0;
while (peopleDemandListIterator.Next(&peopleTimeZoneList)) {
#pragma var_order(demandStartY, peopleTypeArray, demandTotal, peopleTimeZoneListIterator)
int demandStartY = y;
int demandTotal = 0;
LArrayIterator peopleTimeZoneListIterator(*peopleTimeZoneList);
T2PeopleTypeArray *peopleTypeArray;
while (peopleTimeZoneListIterator.Next(&peopleTypeArray)) {
#pragma var_order(peopleType, timeZoneStartY, peopleTypeArrayIterator, timeZoneTotal)
int timeZoneStartY = y;
int timeZoneTotal = 0;
LArrayIterator peopleTypeArrayIterator(*peopleTypeArray);
T2PeopleType peopleType;
while (peopleTypeArrayIterator.Next(&peopleType)) {
int peopleStartY = y;
timeZoneTotal++;
demandTotal++;
totalPopulation++;
if (peopleTypeArray->m20) {
str.Format(
" Sh=%-3d Dm=%-3d Tz=%-3d Lf=%-3d Et=%-3d",
peopleType.GetSilhouetteType(),
peopleType.GetDemandType(),
peopleType.GetTimeZoneType(),
peopleType.mLife,
peopleType.mEconoType
);
pDC->SetTextColor(RGB(0, 0, 0));
pDC->SetBkColor(RGB(255, 255, 255));
pDC->TextOut(x, y, str);
y += height;
}
if (peopleStartY <= pt.y && pt.y < y && outUnknown)
*outUnknown = 0;
}
if (peopleTimeZoneList->_20) {
str.Format(" TimeZone total : %d", timeZoneTotal);
if (peopleTypeArray->m20) {
pDC->SetTextColor(RGB(255, 255, 255));
pDC->SetBkColor(RGB(0, 0, 0));
} else {
pDC->SetTextColor(RGB(0, 0, 0));
pDC->SetBkColor(RGB(255, 255, 255));
}
pDC->TextOut(x, y, str);
y += height;
}
if (timeZoneStartY <= pt.y && pt.y < y && outPeopleTypeArray)
*outPeopleTypeArray = peopleTypeArray;
}
str.Format(" Demand total : %d", demandTotal);
if (peopleTimeZoneList->_20) {
pDC->SetTextColor(RGB(255, 255, 255));
pDC->SetBkColor(RGB(0, 0, 0));
} else {
pDC->SetTextColor(RGB(0, 0, 0));
pDC->SetBkColor(RGB(255, 255, 255));
}
pDC->TextOut(x, y, str);
y += height;
if (demandStartY <= pt.y && pt.y < y && outTimeZoneList)
*outTimeZoneList = peopleTimeZoneList;
}
pDC->SetTextColor(RGB(255, 255, 255));
pDC->SetBkColor(RGB(0, 0, 0));
str.Format("Total population : %d", totalPopulation);
pDC->TextOut(x, y, str);
y += height;
height = y + GetScrollPos(SB_VERT) - rect.Height();
if (height > 0)
SetScrollRange(SB_VERT, 0, height);
else
SetScrollRange(SB_VERT, 0, 0);
pDC->RestoreDC(save);
}
|