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/T2DlgItemRadioText.cpp | 71 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 src/T2DLL/T2DlgItemRadioText.cpp (limited to 'src/T2DLL/T2DlgItemRadioText.cpp') diff --git a/src/T2DLL/T2DlgItemRadioText.cpp b/src/T2DLL/T2DlgItemRadioText.cpp new file mode 100644 index 0000000..bba4937 --- /dev/null +++ b/src/T2DLL/T2DlgItemRadioText.cpp @@ -0,0 +1,71 @@ +#include "T2BitImage.h" +#include "T2DlgItemRadioText.h" + +/*virtual*/ BOOL T2DlgItemRadioText::Create(const char *inWindowName, DWORD inStyle, const RECT &inRect, CWnd *inParentWnd, UINT inID) { + CRect rect = inRect; + CRect imageRect; + + strcpy(mText, inWindowName); + GetObjectImage(imageRect, "DLGITEM:TxRadio"); + + return T2DlgItem::Create("DLGITEM:TxRadio", inStyle, rect, inParentWnd, inID); +} + +T2DlgItemRadioText::T2DlgItemRadioText(T2TowerDoc *inDoc, T2ImageObj *inImageObj, CPalette *inPalette) + : T2DlgItemICheck(inDoc, inImageObj, inPalette) +{ + mText[0] = 0; +} + +/*virtual*/ T2DlgItemRadioText::~T2DlgItemRadioText() { +} + +/*virtual*/ BOOL T2DlgItemRadioText::OnT2DlgItemEraseBkgnd(CDC *pDC) { + CRect drawRect; + GetClientRect(drawRect); + + int saved = pDC->SaveDC(); + pDC->SelectPalette(mPalette, false); + pDC->RealizePalette(); + + RECT imageRect; + T2BitImage *theImage = GetObjectImage(imageRect, "DLGITEM:TxRadio", GetPattern()); + drawRect.right = (drawRect.left + imageRect.right) - imageRect.left; + drawRect.bottom = (drawRect.top + imageRect.bottom) - imageRect.top; + theImage->CopyImage(pDC, imageRect, drawRect); + + GetClientRect(drawRect); + drawRect.left += (drawRect.bottom - drawRect.top); + + char config = mText[0]; + const char *text = &mText[1]; + DWORD theFormat = DT_WORDBREAK | DT_NOPREFIX; + + if (isupper(config)) { + theFormat |= DT_VCENTER | DT_SINGLELINE; + config = tolower(config); + } + + switch (config) { + case 'c': + theFormat |= DT_CENTER; + break; + case 'l': + theFormat |= DT_LEFT; + break; + case 'r': + theFormat |= DT_RIGHT; + break; + } + + pDC->SetBkMode(TRANSPARENT); + pDC->DrawText(text, drawRect, theFormat); + + pDC->RestoreDC(saved); + return true; +} + +/*virtual*/ void T2DlgItemRadioText::OnT2DlgItemLButtonDown(UINT inFlags, CPoint inPt) { + if (!GetValue()) + T2DlgItemICheck::OnT2DlgItemLButtonDown(inFlags, inPt); +} -- cgit v1.2.3