#include "T2Name.h" #include "T2NameList.h" #include "T2NameTable.h" /*virtual*/ BOOL T2NameTable::OnT2DlgItemCreate(CREATESTRUCT* inCreateStruct) { return T2DlgItemTable::OnT2DlgItemCreate(inCreateStruct); } 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 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(UINT inFlags, CPoint inPt) { ClickSelf(inPt); } /*virtual*/ void T2NameTable::Add(T2NameList* inNameList) { if (inNameList) { LArrayIterator iterator(*inNameList); T2Name *name; while (iterator.Next(&name)) Add(name); } } /*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* 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* pDC, const TableCellT& inCell, BOOL inSelected) { DrawCell(pDC, inCell); } /*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; }