1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
|
#include "StdAfx.h"
#include "T2BitImage.h"
#include "T2DlgItemICheck.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
T2DlgItemICheck::T2DlgItemICheck(T2TowerDoc* inDoc, T2ImageObj* inImageObj, CPalette* inPalette)
: T2DlgItem(inDoc, inImageObj, inPalette)
{
}
/*virtual*/ BOOL T2DlgItemICheck::Create(const char* windowName, DWORD style, const RECT& inRect, CWnd* parentWnd, UINT nId) {
CRect rect = inRect;
CRect imageRect;
if (GetObjectImage(imageRect, windowName)) {
rect.right = rect.left + imageRect.Width();
rect.bottom = rect.top + imageRect.Height();
} else {
rect.right = rect.left + 20;
rect.bottom = rect.top + 20;
}
return T2DlgItem::Create(windowName, style, rect, parentWnd, nId);
}
/*virtual*/ void T2DlgItemICheck::SetValue(int inValue) {
T2DlgItem::SetValue(inValue);
if (mValue == 0)
SetPattern(0);
else if (mValue == 1)
SetPattern(100);
}
#pragma var_order(pen, imageRect, brush, clientRect, theImage, text, save)
/*virtual*/ BOOL T2DlgItemICheck::OnT2DlgItemEraseBkgnd(CDC* pDC) {
CRect clientRect;
GetClientRect(clientRect);
int save = pDC->SaveDC();
pDC->SelectPalette(mPalette, false);
pDC->RealizePalette();
CPen pen;
CBrush brush;
CString text;
GetWindowText(text);
RECT imageRect;
T2BitImage *theImage = GetObjectImage(imageRect, text, GetPattern());
if (theImage) {
theImage->CopyImage(pDC, imageRect, clientRect);
} else {
pen.CreateStockObject(BLACK_PEN);
brush.CreateStockObject(WHITE_BRUSH);
pDC->SelectObject(&pen);
pDC->SelectObject(&brush);
pDC->Rectangle(clientRect);
if (GetPattern() == 100) {
pDC->MoveTo(clientRect.left, clientRect.top);
pDC->LineTo(clientRect.right, clientRect.bottom);
pDC->MoveTo(clientRect.left, clientRect.bottom - 1);
pDC->LineTo(clientRect.right, clientRect.top - 1);
}
}
pDC->RestoreDC(save);
return true;
}
/*virtual*/ void T2DlgItemICheck::OnT2DlgItemLButtonDown(UINT, CPoint) {
SetCapture();
m74 = true;
SetValue(!mValue);
Notify(mValue ? 2 : 3, NULL);
}
/*virtual*/ void T2DlgItemICheck::OnT2DlgItemLButtonUp(UINT, CPoint) {
ReleaseCapture();
m74 = false;
}
/*virtual*/ void T2DlgItemICheck::OnT2DlgItemMouseMove(UINT, CPoint) {
}
|