summaryrefslogtreecommitdiff
path: root/src/T2DLL/T2NameTable.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/T2NameTable.cpp
parent37e364b2c6cc7487a1c888d256a73e5337bb7189 (diff)
downloadt2win-c0c336500955a23e344651e5412c9d9d441ef4ee.tar.gz
t2win-c0c336500955a23e344651e5412c9d9d441ef4ee.zip
first pass of T2DLL
Diffstat (limited to 'src/T2DLL/T2NameTable.cpp')
-rw-r--r--src/T2DLL/T2NameTable.cpp87
1 files changed, 78 insertions, 9 deletions
diff --git a/src/T2DLL/T2NameTable.cpp b/src/T2DLL/T2NameTable.cpp
index c68c2fd..994ab5a 100644
--- a/src/T2DLL/T2NameTable.cpp
+++ b/src/T2DLL/T2NameTable.cpp
@@ -1,34 +1,103 @@
+#include "T2Name.h"
+#include "T2NameList.h"
#include "T2NameTable.h"
-/*virtual*/ int T2NameTable::OnT2DlgItemCreate(CREATESTRUCTA*) {
+/*virtual*/ BOOL T2NameTable::OnT2DlgItemCreate(CREATESTRUCT* inCreateStruct) {
+ return T2DlgItemTable::OnT2DlgItemCreate(inCreateStruct);
}
-T2NameTable::T2NameTable(T2TowerDoc*, T2ImageObj*, CPalette*) {
+T2NameTable::T2NameTable(T2TowerDoc* inDoc, T2ImageObj* inImageObj, CPalette* inPalette)
+ : T2VerticalTable(inDoc, inImageObj, inPalette)
+{
}
T2Name* T2NameTable::GetSelectedName() {
+ T2Name *theName = NULL;
+
+ if (IsValidCell(mSelectedCell))
+ GetCellData(mSelectedCell, &theName);
+
+ return theName;
}
-/*virtual*/ void T2NameTable::ClickSelf(POINT) {
+/*virtual*/ void T2NameTable::ClickSelf(POINT inPt) {
+ POINT pt = inPt;
+ ClientToView(&pt, 1);
+
+ TableCellT cell;
+ FetchCellHitBy(pt, cell);
+
+ if (IsValidCell(cell)) {
+ ClickCell(cell, inPt);
+
+ T2Name *theName;
+ GetCellData(cell, &theName);
+ BroadcastMessage(4201, theName);
+ }
}
-/*virtual*/ void T2NameTable::OnT2DlgItemLButtonDown(unsigned int, CPoint) {
+/*virtual*/ void T2NameTable::OnT2DlgItemLButtonDown(UINT inFlags, CPoint inPt) {
+ ClickSelf(inPt);
}
-/*virtual*/ void T2NameTable::Add(T2NameList*) {
+/*virtual*/ void T2NameTable::Add(T2NameList* inNameList) {
+ if (inNameList) {
+ LArrayIterator iterator(*inNameList);
+ T2Name *name;
+
+ while (iterator.Next(&name))
+ Add(name);
+ }
}
-/*virtual*/ void T2NameTable::Add(T2Name*) {
+/*virtual*/ void T2NameTable::Add(T2Name* inName) {
+ if (inName)
+ InsertRows(1, mRows, &inName);
}
/*virtual*/ void T2NameTable::RemoveCurrentCell() {
+ RemoveRows(1, mSelectedCell.row);
+ mSelectedCell.col = 0;
+ mSelectedCell.row = 0;
}
-/*virtual*/ void T2NameTable::DrawCell(CDC*, const TableCellT&) {
+/*virtual*/ void T2NameTable::DrawCell(CDC* pDC, const TableCellT& inCell) {
+ int save = pDC->SaveDC();
+ pDC->SelectPalette(mPalette, false);
+ pDC->RealizePalette();
+
+ RECT rect;
+ if (FetchLocalCellFrame(inCell, rect)) {
+ T2Name *theName;
+ GetCellData(inCell, &theName);
+ if (theName) {
+ CString str;
+ unsigned int id;
+ int nameType = theName->GetName(str, id);
+ pDC->TextOut(rect.left + 4, rect.bottom - 2, str, strlen(str));
+ }
+ }
+
+ pDC->RestoreDC(save);
}
-/*virtual*/ void T2NameTable::DrawCellSelf(CDC*, const TableCellT&, int) {
+/*virtual*/ void T2NameTable::DrawCellSelf(CDC* pDC, const TableCellT& inCell, BOOL inSelected) {
+ DrawCell(pDC, inCell);
}
-/*virtual*/ int T2NameTable::OnT2DlgItemEraseBkgnd(CDC*) {
+/*virtual*/ BOOL T2NameTable::OnT2DlgItemEraseBkgnd(CDC* 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);
+ }
+ }
+
+ InvalidateRect(NULL);
+ return true;
}