summaryrefslogtreecommitdiff
path: root/src/T2DLL/T2DlgItemImage.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/T2DLL/T2DlgItemImage.cpp')
-rw-r--r--src/T2DLL/T2DlgItemImage.cpp49
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);
}