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
|
#include "StdAfx.h"
#include "T2DlgItemSTimeTbl.h"
#include "T2MetroRailway.h"
#include "../T2TowerDoc.h"
#include "T2WorldDef.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
T2DlgItemSTimeTbl::T2DlgItemSTimeTbl(T2TowerDoc* inDoc, T2ImageObj* inImageObj, CPalette* inPalette)
: T2DlgItem(inDoc, inImageObj, inPalette)
{
mCFont = NULL;
}
/*virtual*/ T2DlgItemSTimeTbl::~T2DlgItemSTimeTbl() {
delete mCFont;
}
/*virtual*/ BOOL T2DlgItemSTimeTbl::Create(const char* windowName, DWORD style, const RECT& rect, CWnd* parentWnd, UINT nId) {
BOOL result = T2DlgItem::Create(windowName, style, rect, parentWnd, nId);
if (result) {
#line 34
mCFont = new CFont;
mCFont->CreateFont(-abs(9), 0, 0, 0, FW_NORMAL, false, false, false, SHIFTJIS_CHARSET, OUT_TT_PRECIS, CLIP_TT_ALWAYS, PROOF_QUALITY, DEFAULT_PITCH, "\x82\x6C\x82\x72 \x82\x6F\x83\x53\x83\x56\x83\x62\x83\x4E");
SetFont(*mCFont);
}
return result;
}
void T2DlgItemSTimeTbl::SetGrade(int inGrade) {
mGrade = inGrade;
}
/*virtual*/ BOOL T2DlgItemSTimeTbl::OnT2DlgItemEraseBkgnd(CDC* pDC) {
int save = pDC->SaveDC();
pDC->SelectPalette(mPalette, false);
pDC->RealizePalette();
CString str;
T2MetroRailway *theMetroRailway = mTowerDoc->mWorldDef->GetMetroRailway();
if (theMetroRailway) {
CRect timeRect, clientRect;
GetClientRect(clientRect);
SIZE timeSize;
timeSize.cx = (clientRect.right - clientRect.left) / (theMetroRailway->GetNofTimeTable() / 2);
timeSize.cy = (clientRect.bottom - clientRect.top) / 2;
pDC->SelectObject(mFont);
pDC->SetBkMode(TRANSPARENT);
for (int i = 0; i < theMetroRailway->GetNofTimeTable(); i++) {
timeRect.left = timeSize.cx * (i % (theMetroRailway->GetNofTimeTable() / 2));
timeRect.right = timeRect.left + timeSize.cx;
timeRect.top = timeSize.cy * (i / (theMetroRailway->GetNofTimeTable() / 2));
timeRect.bottom = timeRect.top + timeSize.cy;
DrawTime(pDC, theMetroRailway->GetArriveTime(i), theMetroRailway->GetTrainType(i) < mGrade, timeRect);
}
}
pDC->RestoreDC(save);
return true;
}
void T2DlgItemSTimeTbl::DrawTime(CDC* pDC, unsigned int inArriveTime, BOOL isGrade, CRect& inRect) {
int hour = inArriveTime / 60;
int minute = inArriveTime % 60;
UINT flag = DT_LEFT | DT_VCENTER | DT_WORDBREAK | DT_NOPREFIX;
CString str;
str.Format("%2d:%02d", hour, minute);
pDC->SetTextColor(isGrade ? PALETTEINDEX(255) : PALETTERGB(179, 179, 179));
pDC->DrawText(str, inRect, flag);
}
|