diff options
Diffstat (limited to 'src/T2DLL/T2AdvertiseTable.cpp')
-rw-r--r-- | src/T2DLL/T2AdvertiseTable.cpp | 153 |
1 files changed, 142 insertions, 11 deletions
diff --git a/src/T2DLL/T2AdvertiseTable.cpp b/src/T2DLL/T2AdvertiseTable.cpp index 5362e34..0f353bf 100644 --- a/src/T2DLL/T2AdvertiseTable.cpp +++ b/src/T2DLL/T2AdvertiseTable.cpp @@ -1,34 +1,165 @@ +#include "CFilePluginList.h" +#include "T2AdvertisePlugin.h" #include "T2AdvertiseTable.h" -/*virtual*/ int T2AdvertiseTable::OnT2DlgItemCreate(CREATESTRUCTA*) { +/*virtual*/ int T2AdvertiseTable::OnT2DlgItemCreate(CREATESTRUCT* cs) { + T2DlgItemTable::SetColWidth(cs->cx, 0, 0); + return T2DlgItemTable::OnT2DlgItemCreate(cs); } -T2AdvertiseTable::T2AdvertiseTable(T2TowerDoc*, T2ImageObj*, CPalette*) { +T2AdvertiseTable::T2AdvertiseTable(T2TowerDoc* inDoc, T2ImageObj* inImageObj, CPalette* inPalette) + : T2VerticalTable(inDoc, inImageObj, inPalette) +{ + mClearBackground = true; + SetCellDataSize(sizeof(T2AdvertisePlugin *)); + InsertCols(1, 0, NULL); + SetHScrollerStyle(AlwaysHide); + SetVScrollerStyle(AlwaysShow); } -void T2AdvertiseTable::Add(T2AdvertisePlugin*, int) { +void T2AdvertiseTable::Add(T2AdvertisePlugin* inPlugin, BOOL inSelect) { + unsigned int theRowIndex = mRows; + InsertRows(1, theRowIndex, &inPlugin); + + if (mCols == 1) + InsertCols(1, mCols, NULL); + + SetMark(mRows, inSelect); + if (inSelect) { + TableCellT cell; + cell.row = mRows; + cell.col = 1; + SelectCell(cell); + } } -void T2AdvertiseTable::Add(CFilePluginList*) { +void T2AdvertiseTable::Add(CFilePluginList* inPluginList) { + int theSubType = GetUserCon(); + POSITION pos = inPluginList->GetHeadPosition(); + + while (pos) { + T2AdvertisePlugin *thePlugin = (T2AdvertisePlugin *) inPluginList->GetNext(pos); + if (thePlugin->GetSubType() == theSubType && !thePlugin->IsTieupFinish()) + Add(thePlugin, false); + } } -/*virtual*/ void T2AdvertiseTable::DrawCell(CDC*, const TableCellT&) { +/*virtual*/ void T2AdvertiseTable::DrawCell(CDC* pDC, const TableCellT& inCell) { + int save = pDC->SaveDC(); + pDC->SelectPalette(mPalette, false); + pDC->RealizePalette(); + + CFont font; + CPen pen; + CBrush brush; + + RECT cellRect; + if (FetchLocalCellFrame(inCell, cellRect) && inCell.col == 1) { + T2AdvertisePlugin *thePlugin; + GetCellData(inCell, &thePlugin); + if (thePlugin) { + DWORD theSubType = GetUserCon(); + int x = cellRect.left + 4; + int y = cellRect.bottom - 12; + + 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); + + if (theSubType == 'CFPI') { + if (IsMark(inCell.row)) { + RECT rect; + rect.left = x; + rect.top = y; + rect.right = x + 4; + rect.bottom = y + 4; + + pen.CreateStockObject(BLACK_PEN); + brush.CreateStockObject(WHITE_BRUSH); + pDC->SelectObject(&pen); + pDC->SelectObject(&brush); + + pDC->MoveTo(rect.left + 2, rect.top + 3); + pDC->LineTo((rect.right + rect.left) / 2 - 2, rect.bottom - 1); + pDC->LineTo(rect.right - 1, rect.top - 1); + } + + x = cellRect.left + 20; + y = cellRect.bottom - 12; + } + + CString text; + thePlugin->GetName(text); + pDC->TextOutA(x, y, text, strlen(text)); + } + } + + pDC->RestoreDC(save); } -void T2AdvertiseTable::ClickCell(const TableCellT&, const CPoint&) { +void T2AdvertiseTable::ClickCell(const TableCellT& inCell, const CPoint& inPt) { + T2DlgItemTable::ClickCell(inCell, inPt); + + if (IsValidCell(mSelectedCell) && mSelectedCell.col == 1) { + T2AdvertisePlugin *thePlugin; + GetCellData(mSelectedCell, &thePlugin); + if (thePlugin) + BroadcastMessage(GetDlgCtrlID(), thePlugin); + } } -int T2AdvertiseTable::IsMark(unsigned int) { +BOOL T2AdvertiseTable::IsMark(unsigned int inRow) { + void *data = NULL; + + TableCellT cell; + cell.row = inRow; + cell.col = 2; + GetCellData(cell, &data); + + return (data != NULL); } -void T2AdvertiseTable::SetMark(unsigned int, int) { +void T2AdvertiseTable::SetMark(unsigned int inRow, BOOL inValue) { + void *data = inValue ? this : NULL; + + TableCellT cell; + cell.row = inRow; + cell.col = 2; + SetCellData(cell, &data); + + InvalidateRect(NULL); } -/*virtual*/ void T2AdvertiseTable::OnT2DlgItemLButtonDown(unsigned int, CPoint) { +/*virtual*/ void T2AdvertiseTable::OnT2DlgItemLButtonDown(UINT inFlags, CPoint inPt) { + POINT pt = inPt; + ClientToView(&inPt, 1); + + TableCellT cell; + FetchCellHitBy(pt, cell); + + if (IsValidCell(cell)) + ClickCell(cell, inPt); } -/*virtual*/ int T2AdvertiseTable::OnT2DlgItemEraseBkgnd(CDC*) { +/*virtual*/ BOOL T2AdvertiseTable::OnT2DlgItemEraseBkgnd(CDC* pDC) { + T2VerticalTable::OnT2DlgItemEraseBkgnd(pDC); + + unsigned int rows, cols; + GetTableSize(rows, cols); + + for (unsigned int col = 1; col <= cols; col++) { + for (unsigned int row = 1; row <= rows; row++) { + TableCellT cell; + cell.row = row; + cell.col = col; + DrawCell(pDC, cell); + } + } + + T2DlgItemTable::HiliteCell(pDC, mSelectedCell); + return true; } -/*virtual*/ void T2AdvertiseTable::DrawCellSelf(CDC*, const TableCellT&, int) { +/*virtual*/ void T2AdvertiseTable::DrawCellSelf(CDC* pDC, const TableCellT& inCell, BOOL inSelected) { + DrawCell(pDC, inCell); } |