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/T2PluginInfoTable.cpp | |
parent | 37e364b2c6cc7487a1c888d256a73e5337bb7189 (diff) | |
download | t2win-c0c336500955a23e344651e5412c9d9d441ef4ee.tar.gz t2win-c0c336500955a23e344651e5412c9d9d441ef4ee.zip |
first pass of T2DLL
Diffstat (limited to '')
-rw-r--r-- | src/T2DLL/T2PluginInfoTable.cpp | 116 |
1 files changed, 109 insertions, 7 deletions
diff --git a/src/T2DLL/T2PluginInfoTable.cpp b/src/T2DLL/T2PluginInfoTable.cpp index 718bc5c..7755b47 100644 --- a/src/T2DLL/T2PluginInfoTable.cpp +++ b/src/T2DLL/T2PluginInfoTable.cpp @@ -1,25 +1,127 @@ +#include "CPluginInfo.h" +#include "LArray.h" #include "T2PluginInfoTable.h" +#include "T2PluginSpecifier.h" -/*virtual*/ int T2PluginInfoTable::Create(const char*, unsigned long, const RECT&, CWnd*, unsigned int) { +/*virtual*/ BOOL T2PluginInfoTable::Create(const char* inWindowName, DWORD inStyle, const RECT& inRect, CWnd* inParentWnd, UINT inID) { + return T2DlgItemTable::Create(inWindowName, inStyle, inRect, inParentWnd, inID); } -T2PluginInfoTable::T2PluginInfoTable(T2TowerDoc*, T2ImageObj*, CPalette*) { +T2PluginInfoTable::T2PluginInfoTable(T2TowerDoc* inDoc, T2ImageObj* inImageObj, CPalette* inPalette) + : T2DlgItemImageTable(inDoc, inImageObj, inPalette) +{ + mType = 0; + mCellData = new LArray; + InsertCols(1, 0, NULL); } /*virtual*/ T2PluginInfoTable::~T2PluginInfoTable() { } -void T2PluginInfoTable::Add(CPluginInfo*) { +void T2PluginInfoTable::Add(CPluginInfo* inInfo) { + InsertRows(1, mRows, &inInfo); + mType = 1; } -void T2PluginInfoTable::Add(T2PluginSpecifier*) { +void T2PluginInfoTable::Add(T2PluginSpecifier* inSpecifier) { + InsertRows(1, mRows, &inSpecifier); + mType = 2; } -/*virtual*/ void T2PluginInfoTable::DrawCellSelf(CDC*, const TableCellT&, int) { +/*virtual*/ void T2PluginInfoTable::DrawCellSelf(CDC* pDC, const TableCellT& inCell, BOOL inSelected) { + int saveDC = pDC->SaveDC(); + pDC->SelectPalette(mPalette, false); + pDC->RealizePalette(); + + pDC->SelectObject(mFont); + pDC->SetBkMode(TRANSPARENT); + + RECT drawRect, cellFrame, clientRect; + GetClientRect(&clientRect); + if (FetchLocalCellFrame(inCell, cellFrame)) { + if (IntersectRect(&drawRect, &cellFrame, &clientRect)) { + InflateRect(&drawRect, -1, -1); + + RECT textRect; + + if (mType == 1) { + CPluginInfo *theInfo; + GetCellData(inCell, &theInfo); + if (theInfo) { + CString name; + + textRect = cellFrame; + textRect.right = textRect.left + 156; + textRect.left += 26; + theInfo->GetName(name); + pDC->DrawText(name, &textRect, DT_SINGLELINE); + + textRect = cellFrame; + textRect.right = textRect.left + 275; + textRect.left += 156; + theInfo->GetFileName(name); + pDC->DrawText(name, &textRect, DT_SINGLELINE); + } + } else if (mType == 2) { + T2PluginSpecifier *theSpecifier; + GetCellData(inCell, &theSpecifier); + + textRect = cellFrame; + textRect.right = textRect.left + 105; + textRect.left += 26; + pDC->DrawText(theSpecifier->mPluginName, &textRect, DT_SINGLELINE); + + textRect = cellFrame; + textRect.right = textRect.left + 175; + textRect.left += 106; + pDC->DrawText(theSpecifier->mPath, &textRect, DT_SINGLELINE); + + CString str; + if (theSpecifier->mIsLoaded) + str = "Load"; + textRect = cellFrame; + textRect.left += 176; + pDC->DrawText(str, &textRect, DT_SINGLELINE); + } + + if (inSelected == 1) + pDC->InvertRect(&cellFrame); + } + } + + pDC->RestoreDC(saveDC); } -/*virtual*/ int T2PluginInfoTable::OnT2DlgItemCreate(CREATESTRUCTA*) { +/*virtual*/ BOOL T2PluginInfoTable::OnT2DlgItemCreate(CREATESTRUCT* inCreateStruct) { + T2DlgItemTable::OnT2DlgItemCreate(inCreateStruct); + return false; } -/*virtual*/ int T2PluginInfoTable::OnT2DlgItemEraseBkgnd(CDC*) { +/*virtual*/ BOOL T2PluginInfoTable::OnT2DlgItemEraseBkgnd(CDC* pDC) { + int theSave = pDC->SaveDC(); + pDC->SelectPalette(mPalette, false); + pDC->RealizePalette(); + + RECT clientArea; + GetClientRect(&clientArea); + + CBrush theBrush; + CBrush theBGBrush; + theBGBrush.CreateSolidBrush(RGB(255, 255, 255)); + pDC->FillRect(&clientArea, &theBGBrush); + + UINT height, width; + GetTableSize(height, width); + + for (UINT y = 1; y <= height; y++) { + for (UINT x = 1; x <= width; x++) { + TableCellT cell; + cell.row = y; + cell.col = x; + DrawCell(pDC, cell); + } + } + + pDC->RestoreDC(theSave); + return true; } |