#include "T2BitImage.h" #include "T2DlgItemImage.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif T2DlgItemImage::T2DlgItemImage(T2TowerDoc* inDoc, T2ImageObj* inImageObj, CPalette* inPalette) : T2DlgItem(inDoc, inImageObj, inPalette) { } /*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*/ 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& outRect) const { CString text; GetDescriptor(text); return GetObjectImage(outRect, text, mValue); }