From c0c336500955a23e344651e5412c9d9d441ef4ee Mon Sep 17 00:00:00 2001 From: Ash Wolf Date: Wed, 28 Jun 2023 22:22:32 +0100 Subject: first pass of T2DLL --- src/T2DLL/T2DlgItemIButton.cpp | 65 ++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 63 insertions(+), 2 deletions(-) (limited to 'src/T2DLL/T2DlgItemIButton.cpp') 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; } -- cgit v1.2.3