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/T2DlgItemIButton.cpp | |
parent | 37e364b2c6cc7487a1c888d256a73e5337bb7189 (diff) | |
download | t2win-c0c336500955a23e344651e5412c9d9d441ef4ee.tar.gz t2win-c0c336500955a23e344651e5412c9d9d441ef4ee.zip |
first pass of T2DLL
Diffstat (limited to '')
-rw-r--r-- | src/T2DLL/T2DlgItemIButton.cpp | 65 |
1 files changed, 63 insertions, 2 deletions
diff --git a/src/T2DLL/T2DlgItemIButton.cpp b/src/T2DLL/T2DlgItemIButton.cpp index e3bd91f..3aa923a 100644 --- a/src/T2DLL/T2DlgItemIButton.cpp +++ b/src/T2DLL/T2DlgItemIButton.cpp @@ -1,7 +1,68 @@ +#include "GlobalFunc.h" +#include "T2BitImage.h" #include "T2DlgItemIButton.h" -T2DlgItemIButton::T2DlgItemIButton(T2TowerDoc*, T2ImageObj*, CPalette*) { +T2DlgItemIButton::T2DlgItemIButton(T2TowerDoc* inDoc, T2ImageObj* inImageObj, CPalette* inPalette) + : T2DlgItemButtonBase(inDoc, inImageObj, inPalette) +{ } -/*virtual*/ int T2DlgItemIButton::OnT2DlgItemEraseBkgnd(CDC*) { +/*virtual*/ BOOL T2DlgItemIButton::OnT2DlgItemEraseBkgnd(CDC* pDC) { + CRect clientRect; + GetClientRect(clientRect); + + int save = pDC->SaveDC(); + pDC->SelectPalette(mPalette, false); + pDC->RealizePalette(); + DrawButtonBase(pDC, clientRect, GetPattern() == 100); + + CString text; + GetWindowText(text); + + CRect imageRect; + T2BitImage *image = GetObjectImage(imageRect, text); + + CRect rect30; + rect30.left = (clientRect.Width() - imageRect.Width()) / 2; + rect30.top = (clientRect.Height() - imageRect.Height()) / 2; + rect30.right = rect30.left + imageRect.Width(); + rect30.bottom = rect30.bottom + imageRect.Height(); + + int save2 = pDC->SaveDC(); + CRect rect74 = imageRect; + OffsetRect(&rect74, -imageRect.left, -imageRect.top); + + CDC newDC; + newDC.CreateCompatibleDC(pDC); + + int save3 = newDC.SaveDC(); + newDC.SelectPalette(mPalette, false); + newDC.RealizePalette(); + + HBITMAP hbitmap = Create256DIBitmap(newDC.m_hDC, rect74.right, rect74.bottom); + SelectObject(newDC.m_hDC, hbitmap); + + CBitmap bitmap; + CBrush brush; + image->CopyImage(&newDC, imageRect, rect74); + + if (!IsWindowEnabled()) { + bitmap.LoadBitmap(170); + brush.CreatePatternBrush(&bitmap); + pDC->SelectObject(brush); + pDC->BitBlt(rect30.left, rect30.top, rect30.Width(), rect30.Height(), &newDC, 0, 0, /*DPSDxax*/ 0xCA0749); + } else { + if (GetPattern() == 100) + rect30.OffsetRect(1, 1); + pDC->BitBlt(rect30.left, rect30.top, rect30.Width(), rect30.Height(), &newDC, 0, 0, SRCCOPY); + } + + newDC.RestoreDC(save3); + newDC.DeleteDC(); + DeleteObject(hbitmap); + + pDC->RestoreDC(save2); + pDC->RestoreDC(save); + + return true; } |