diff options
author | Ash Wolf <ninji@wuffs.org> | 2023-06-28 22:22:32 +0100 |
---|---|---|
committer | Ash Wolf <ninji@wuffs.org> | 2023-06-28 22:22:32 +0100 |
commit | c0c336500955a23e344651e5412c9d9d441ef4ee (patch) | |
tree | 790769c748db307cf3314f6e896e2f61c68561a2 /src/T2DLL/T2DlgItemSTimeTbl.cpp | |
parent | 37e364b2c6cc7487a1c888d256a73e5337bb7189 (diff) | |
download | t2win-c0c336500955a23e344651e5412c9d9d441ef4ee.tar.gz t2win-c0c336500955a23e344651e5412c9d9d441ef4ee.zip |
first pass of T2DLL
Diffstat (limited to 'src/T2DLL/T2DlgItemSTimeTbl.cpp')
-rw-r--r-- | src/T2DLL/T2DlgItemSTimeTbl.cpp | 68 |
1 files changed, 63 insertions, 5 deletions
diff --git a/src/T2DLL/T2DlgItemSTimeTbl.cpp b/src/T2DLL/T2DlgItemSTimeTbl.cpp index a837aa5..e82ab91 100644 --- a/src/T2DLL/T2DlgItemSTimeTbl.cpp +++ b/src/T2DLL/T2DlgItemSTimeTbl.cpp @@ -1,19 +1,77 @@ #include "T2DlgItemSTimeTbl.h" +#include "T2MetroRailway.h" +#include "T2TowerDoc.h" +#include "T2WorldDef.h" -T2DlgItemSTimeTbl::T2DlgItemSTimeTbl(T2TowerDoc*, T2ImageObj*, CPalette*) { +T2DlgItemSTimeTbl::T2DlgItemSTimeTbl(T2TowerDoc* inDoc, T2ImageObj* inImageObj, CPalette* inPalette) + : T2DlgItem(inDoc, inImageObj, inPalette) +{ + mCFont = NULL; } /*virtual*/ T2DlgItemSTimeTbl::~T2DlgItemSTimeTbl() { + delete mCFont; } -/*virtual*/ int T2DlgItemSTimeTbl::Create(const char*, unsigned long, const RECT&, CWnd*, unsigned int) { +/*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 = DEBUG_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) { +void T2DlgItemSTimeTbl::SetGrade(int inGrade) { + mGrade = inGrade; } -/*virtual*/ int T2DlgItemSTimeTbl::OnT2DlgItemEraseBkgnd(CDC*) { +/*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*, unsigned int, int, CRect&) { +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); } |