summaryrefslogtreecommitdiff
path: root/src/T2DLL/T2HallEventTable.cpp
diff options
context:
space:
mode:
authorAsh Wolf <ninji@wuffs.org>2023-06-28 22:22:32 +0100
committerAsh Wolf <ninji@wuffs.org>2023-06-28 22:22:32 +0100
commitc0c336500955a23e344651e5412c9d9d441ef4ee (patch)
tree790769c748db307cf3314f6e896e2f61c68561a2 /src/T2DLL/T2HallEventTable.cpp
parent37e364b2c6cc7487a1c888d256a73e5337bb7189 (diff)
downloadt2win-c0c336500955a23e344651e5412c9d9d441ef4ee.tar.gz
t2win-c0c336500955a23e344651e5412c9d9d441ef4ee.zip
first pass of T2DLL
Diffstat (limited to 'src/T2DLL/T2HallEventTable.cpp')
-rw-r--r--src/T2DLL/T2HallEventTable.cpp247
1 files changed, 228 insertions, 19 deletions
diff --git a/src/T2DLL/T2HallEventTable.cpp b/src/T2DLL/T2HallEventTable.cpp
index d77a1a9..b522ed2 100644
--- a/src/T2DLL/T2HallEventTable.cpp
+++ b/src/T2DLL/T2HallEventTable.cpp
@@ -1,64 +1,273 @@
+#include "CFilePluginList.h"
+#include "T2DateTime.h"
#include "T2HallEventTable.h"
+#include "T2HallEventPlugin.h"
+#include "T2TowerDoc.h"
-/*virtual*/ int T2HallEventTable::OnT2DlgItemCreate(CREATESTRUCTA*) {
+/*virtual*/ int T2HallEventTable::OnT2DlgItemCreate(CREATESTRUCT* cs) {
+ T2DlgItemTable::SetColWidth(cs->cx, 0, 0);
+ return T2DlgItemTable::OnT2DlgItemCreate(cs);
}
-T2HallEventTable::T2HallEventTable(T2TowerDoc*, T2ImageObj*, CPalette*) {
+T2HallEventTable::T2HallEventTable(T2TowerDoc* inDoc, T2ImageObj* inImageObj, CPalette* inPalette)
+ : T2VerticalTable(inDoc, inImageObj, inPalette)
+{
+ mClearBackground = true;
+ mUserCon = 0;
+
+ SetCellDataSize(sizeof(T2HallEventItem *));
+ InsertCols(1, 0, NULL);
+ SetHScrollerStyle(AlwaysHide);
+ SetVScrollerStyle(AlwaysHide);
}
/*virtual*/ T2HallEventTable::~T2HallEventTable() {
+ T2HallEventItem *item;
+ TableCellT theCell;
+ theCell.row = 0;
+ theCell.col = 1;
+
+ for (unsigned int i = 1; i <= mRows; i++) {
+ theCell.row = i;
+ GetCellData(theCell, &item);
+ delete item;
+ }
}
-/*virtual*/ void T2HallEventTable::Add(T2HallEventPlugin*) {
+/*virtual*/ void T2HallEventTable::Add(T2HallEventPlugin* inPlugin) {
+ unsigned int index = mRows;
+ T2HallEventItem *item = new T2HallEventItem(inPlugin, NULL);
+ InsertRows(1, index, &item);
}
-/*virtual*/ void T2HallEventTable::Add(const char*) {
+/*virtual*/ void T2HallEventTable::Add(const char* inStr) {
+ unsigned int index = mRows;
+ T2HallEventItem *item = new T2HallEventItem(NULL, inStr);
+ InsertRows(1, index, &item);
+
+ if (mUserCon)
+ SetVScrollerStyle(AlwaysShow);
}
-/*virtual*/ void T2HallEventTable::Add(CFilePluginList*) {
+/*virtual*/ void T2HallEventTable::Add(CFilePluginList* inList) {
+ T2HallEventPlugin *thePlugin;
+ T2HallEventItem *item;
+ unsigned int index = mRows;
+ POSITION pos = inList->GetHeadPosition();
+
+ while (pos) {
+ thePlugin = (T2HallEventPlugin *) inList->GetNext(pos);
+ item = new T2HallEventItem(thePlugin, NULL);
+ InsertRows(1, index, &item);
+ index++;
+ }
}
-/*virtual*/ void T2HallEventTable::SetCellData(const TableCellT&, T2HallEventPlugin*, const char*) {
+/*virtual*/ void T2HallEventTable::SetCellData(const TableCellT& inCell, T2HallEventPlugin* inPlugin, const char* inStr) {
+ T2HallEventItem *item;
+ GetCellData(inCell, &item);
+
+ if (item) {
+ item->mPlugin = inPlugin;
+ strcpy(item->mStr, inStr);
+ }
}
-/*virtual*/ void T2HallEventTable::DrawCellSelf(CDC*, const TableCellT&, int) {
+/*virtual*/ void T2HallEventTable::DrawCellSelf(CDC* pDC, const TableCellT& inCell, BOOL inSelected) {
+ DrawCell(pDC, inCell);
}
-/*virtual*/ void T2HallEventTable::DrawCell(CDC*, const TableCellT&) {
+/*virtual*/ void T2HallEventTable::DrawCell(CDC* pDC, const TableCellT& inCell) {
+ int save = pDC->SaveDC();
+ pDC->SelectPalette(mPalette, false);
+ pDC->RealizePalette();
+
+ CFont font;
+ RECT cellRect;
+
+ if (FetchLocalCellFrame(inCell, cellRect)) {
+ CString title;
+ T2HallEventItem *item;
+ T2HallEventPlugin *thePlugin;
+ GetCellData(inCell, &item);
+ if (item) {
+ thePlugin = item->mPlugin;
+ if (thePlugin)
+ thePlugin->GetTitle(title);
+ else
+ title = item->mStr;
+ }
+
+ font.CreateFont(-9, 0, 0, 0, FW_DONTCARE, false, false, false, SHIFTJIS_CHARSET, OUT_TT_PRECIS, CLIP_TT_ALWAYS, PROOF_QUALITY, DEFAULT_PITCH, "\x82\x6C\x82\x72 \x83\x53\x83\x56\x83\x62\x83\x4E");
+ pDC->SelectObject(&font);
+ pDC->SetBkMode(TRANSPARENT);
+ pDC->TextOut(cellRect.left + 4, cellRect.bottom - 12, title, strlen(title));
+
+ if (GetUserCon() == 0) {
+ if (inCell.row < 12)
+ cellRect.bottom++;
+
+ CBrush brush;
+ brush.CreateSolidBrush(RGB(0, 0, 0));
+ pDC->FrameRect(&cellRect, &brush);
+ }
+ }
+
+ pDC->RestoreDC(save);
}
-/*virtual*/ void T2HallEventTable::ClickCell(const TableCellT&, const CPoint&) {
+/*virtual*/ void T2HallEventTable::ClickCell(const TableCellT& inCell, const CPoint& inPt) {
+ T2DlgItemTable::ClickCell(inCell, inPt);
+
+ if (IsValidCell(mSelectedCell)) {
+ T2HallEventItem *item;
+ GetCellData(mSelectedCell, &item);
+
+ T2HallEventPlugin *thePlugin = item ? item->mPlugin : NULL;
+ BroadcastMessage(-GetDlgCtrlID(), thePlugin);
+ }
}
-/*virtual*/ void T2HallEventTable::OnT2DlgItemLButtonDown(unsigned int, CPoint) {
+/*virtual*/ void T2HallEventTable::OnT2DlgItemLButtonDown(UINT inFlags, CPoint inPt) {
+ CPoint pt = inPt;
+ ClientToView(&pt, 1);
+
+ TableCellT cell;
+ FetchCellHitBy(pt, cell);
+
+ if (IsValidCell(cell))
+ ClickCell(cell, inPt);
}
-/*virtual*/ int T2HallEventTable::OnT2DlgItemEraseBkgnd(CDC*) {
+/*virtual*/ BOOL T2HallEventTable::OnT2DlgItemEraseBkgnd(CDC* pDC) {
+ T2VerticalTable::OnT2DlgItemEraseBkgnd(pDC);
+
+ unsigned int numOfRows, numOfColumns, theRow, theColumn;
+
+ GetTableSize(numOfRows, numOfColumns);
+ for (theColumn = 1; theColumn <= numOfColumns; theColumn++) {
+ for (theRow = 1; theRow <= numOfRows; theRow++) {
+ TableCellT cell;
+ cell.row = theRow;
+ cell.col = theColumn;
+ DrawCell(pDC, cell);
+ }
+ }
+
+ T2DlgItemTable::HiliteCell(pDC, mSelectedCell);
+ return true;
}
-/*virtual*/ int T2MonthlyTable::OnT2DlgItemCreate(CREATESTRUCTA*) {
+
+
+/*virtual*/ int T2MonthlyTable::OnT2DlgItemCreate(CREATESTRUCT* cs) {
+ return T2DlgItemTable::OnT2DlgItemCreate(cs);
}
-T2MonthlyTable::T2MonthlyTable(T2TowerDoc*, T2ImageObj*, CPalette*) {
+T2MonthlyTable::T2MonthlyTable(T2TowerDoc* inDoc, T2ImageObj* inImageObj, CPalette* inPalette)
+ : T2VerticalTable(inDoc, inImageObj, inPalette)
+{
+ mStartMonth = 1;
+
+ SetCellDataSize(sizeof(int));
+ InsertCols(1, 0, NULL);
+ int zero = 0;
+ InsertRows(12, mRows, &zero);
+
+ SetHScrollerStyle(AlwaysHide);
+ SetVScrollerStyle(AlwaysHide);
}
/*virtual*/ T2MonthlyTable::~T2MonthlyTable() {
}
-void T2MonthlyTable::SetStartMonth(T2TowerDoc*, int) {
+void T2MonthlyTable::SetStartMonth(T2TowerDoc* inDoc, int inMonth) {
+ mStartMonth = inMonth;
+
+ T2DateTime *theNow = inDoc->towerDoc_vf120();
+ T2DateTime date = *theNow;
+
+ int months = 12;
+ for (int month = 0; month < 12; month++) {
+ date.mMonth = month + mStartMonth - 1;
+ if (date.mMonth >= 12) {
+ date.mYear = theNow->mYear + 1;
+ date.mMonth -= 12;
+ }
+
+ mIsHoliday[month] = date.IsHoliday(inDoc);
+ }
}
-/*virtual*/ void T2MonthlyTable::DrawCellSelf(CDC*, const TableCellT&, int) {
+/*virtual*/ void T2MonthlyTable::DrawCellSelf(CDC* pDC, const TableCellT& inCell, BOOL inSelected) {
+ DrawCell(pDC, inCell);
}
-/*virtual*/ void T2MonthlyTable::DrawCell(CDC*, const TableCellT&) {
+/*virtual*/ void T2MonthlyTable::DrawCell(CDC* pDC, const TableCellT& inCell) {
+ int save = pDC->SaveDC();
+ pDC->SelectPalette(mPalette, false);
+ pDC->RealizePalette();
+
+ CFont font;
+ RECT cellRect;
+
+ if (FetchLocalCellFrame(inCell, cellRect)) {
+ int n = (inCell.row - 1) + mStartMonth;
+ CString str;
+ str.Format("%d", (n > 12) ? (n - 12) : n);
+
+ if (mIsHoliday[inCell.row - 1])
+ pDC->FillSolidRect(&cellRect, RGB(255, 152, 152));
+
+ font.CreateFont(-9, 0, 0, 0, FW_DONTCARE, false, false, false, SHIFTJIS_CHARSET, OUT_TT_PRECIS, CLIP_TT_ALWAYS, PROOF_QUALITY, DEFAULT_PITCH, "\x82\x6C\x82\x72 \x83\x53\x83\x56\x83\x62\x83\x4E");
+
+ pDC->SelectObject(&font);
+ pDC->SetBkMode(TRANSPARENT);
+ pDC->TextOut(cellRect.left + 4, cellRect.bottom - 12, str, strlen(str));
+
+ if (inCell.row < 12)
+ cellRect.bottom++;
+
+ CBrush brush;
+ brush.CreateSolidBrush(RGB(0, 0, 0));
+ pDC->FrameRect(&cellRect, &brush);
+ }
+
+ pDC->RestoreDC(save);
}
-void T2MonthlyTable::ClickCell(const TableCellT&, const CPoint&) {
+void T2MonthlyTable::ClickCell(const TableCellT& inCell, const CPoint& inPt) {
+ TableCellT cell;
+ cell.row = 0;
+ cell.col = 0;
+ SelectCell(cell);
}
-/*virtual*/ void T2MonthlyTable::OnT2DlgItemLButtonDown(unsigned int, CPoint) {
+/*virtual*/ void T2MonthlyTable::OnT2DlgItemLButtonDown(UINT inFlags, CPoint inPt) {
+ CPoint pt = inPt;
+ ClientToView(&pt, 1);
+
+ TableCellT cell;
+ FetchCellHitBy(pt, cell);
+
+ if (IsValidCell(cell))
+ ClickCell(cell, inPt);
}
-/*virtual*/ int T2MonthlyTable::OnT2DlgItemEraseBkgnd(CDC*) {
+/*virtual*/ BOOL T2MonthlyTable::OnT2DlgItemEraseBkgnd(CDC* pDC) {
+ T2VerticalTable::OnT2DlgItemEraseBkgnd(pDC);
+
+ unsigned int numOfRows, numOfColumns, theRow, theColumn;
+
+ GetTableSize(numOfRows, numOfColumns);
+ for (theColumn = 1; theColumn <= numOfColumns; theColumn++) {
+ for (theRow = 1; theRow <= numOfRows; theRow++) {
+ TableCellT cell;
+ cell.row = theRow;
+ cell.col = theColumn;
+ DrawCell(pDC, cell);
+ }
+ }
+
+ return true;
}