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/T2DlgItemImage.cpp | |
parent | 37e364b2c6cc7487a1c888d256a73e5337bb7189 (diff) | |
download | t2win-c0c336500955a23e344651e5412c9d9d441ef4ee.tar.gz t2win-c0c336500955a23e344651e5412c9d9d441ef4ee.zip |
first pass of T2DLL
Diffstat (limited to '')
-rw-r--r-- | src/T2DLL/T2DlgItemImage.cpp | 49 |
1 files changed, 45 insertions, 4 deletions
diff --git a/src/T2DLL/T2DlgItemImage.cpp b/src/T2DLL/T2DlgItemImage.cpp index 499e1dd..23db042 100644 --- a/src/T2DLL/T2DlgItemImage.cpp +++ b/src/T2DLL/T2DlgItemImage.cpp @@ -1,16 +1,57 @@ +#include "T2BitImage.h" #include "T2DlgItemImage.h" -T2DlgItemImage::T2DlgItemImage(T2TowerDoc*, T2ImageObj*, CPalette*) { +T2DlgItemImage::T2DlgItemImage(T2TowerDoc* inDoc, T2ImageObj* inImageObj, CPalette* inPalette) + : T2DlgItem(inDoc, inImageObj, inPalette) +{ } -/*virtual*/ int T2DlgItemImage::Create(const char*, unsigned long, const RECT&, CWnd*, unsigned int) { +/*virtual*/ int T2DlgItemImage::Create(const char* inName, DWORD inStyle, const RECT& inRect, CWnd* inParentWnd, UINT inID) { +#pragma var_order(clientRect, image, imageRect) + CRect imageRect; + mValue = -1; + T2BitImage *image = GetObjectImage(imageRect, inName, mValue); + + CRect clientRect = inRect; + if (image) { + clientRect.right = clientRect.left + imageRect.Width(); + clientRect.bottom = clientRect.top + imageRect.Height(); + } + + return T2DlgItem::Create(inName, inStyle, clientRect, inParentWnd, inID); } -/*virtual*/ int T2DlgItemImage::OnT2DlgItemEraseBkgnd(CDC*) { +/*virtual*/ BOOL T2DlgItemImage::OnT2DlgItemEraseBkgnd(CDC* pDC) { +#pragma var_order(imageRect, clientRect, image) + CRect clientRect; + CRect imageRect; + + GetClientRect(clientRect); + T2BitImage *image = GetDrawImage(imageRect); + + if (image) { + int save = pDC->SaveDC(); + pDC->SelectPalette(mPalette, false); + pDC->RealizePalette(); + + SetStretchBltMode(pDC->m_hDC, COLORONCOLOR); + StretchDIBits(pDC->m_hDC, clientRect.left, clientRect.top, clientRect.Width(), clientRect.Height(), imageRect.left, imageRect.bottom + 1, imageRect.Width(), -imageRect.Height(), image->mData, (BITMAPINFO *) &image->mBitmap, DIB_PAL_COLORS, SRCCOPY); + + pDC->RestoreDC(save); + } + + return true; } void T2DlgItemImage::AdjustSize() { + CRect imageRect; + + if (GetDrawImage(imageRect)) + SetWindowPos(NULL, 0, 0, imageRect.Width(), imageRect.Height(), SWP_NOMOVE | SWP_NOZORDER); } -T2BitImage* T2DlgItemImage::GetDrawImage(CRect&) const { +T2BitImage* T2DlgItemImage::GetDrawImage(CRect& outRect) const { + CString text; + GetDescriptor(text); + return GetObjectImage(outRect, text, mValue); } |