#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); }