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
94
95
96
|
#include "StdAfx.h"
#include "T2DlgItemAllPurpose.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
T2DlgItemAllPurpose::T2DlgItemAllPurpose(T2TowerDoc* inDoc, T2ImageObj* inImageObj, CPalette* inPalette)
: T2DlgItem(inDoc, inImageObj, inPalette)
{
#line 16
mDownPoint = new CPoint(-1, -1);
mUpPoint = new CPoint(-1, -1);
mButton = -1;
}
/*virtual*/ T2DlgItemAllPurpose::~T2DlgItemAllPurpose() {
delete mDownPoint;
delete mUpPoint;
}
/*virtual*/ BOOL T2DlgItemAllPurpose::OnT2DlgItemEraseBkgnd(CDC* pDC) {
CRect rect;
GetClientRect(rect);
int save = pDC->SaveDC();
pDC->SelectPalette(mPalette, false);
pDC->RealizePalette();
CPen whitePen;
whitePen.CreatePen(PS_SOLID, 0, PALETTERGB(255, 255, 255));
CPen greyPen;
greyPen.CreatePen(PS_SOLID, 0, PALETTERGB(133, 133, 133));
pDC->SelectObject(greyPen);
pDC->MoveTo(rect.right - 1, rect.top);
pDC->LineTo(rect.left, rect.top);
pDC->LineTo(rect.left, rect.bottom);
pDC->SelectObject(whitePen);
pDC->MoveTo(rect.right - 1, rect.top + 1);
pDC->LineTo(rect.right - 1, rect.bottom - 1);
pDC->LineTo(rect.left, rect.bottom - 1);
pDC->RestoreDC(save);
return true;
}
/*virtual*/ void T2DlgItemAllPurpose::OnT2DlgItemLButtonDown(UINT, CPoint inPt) {
*mDownPoint = inPt;
mButton = 0;
}
/*virtual*/ void T2DlgItemAllPurpose::OnT2DlgItemLButtonUp(UINT, CPoint inPt) {
*mUpPoint = inPt;
if (mButton == 0) {
mButton = 0;
CSize delta = *mDownPoint - *mUpPoint;
if (abs(delta.cx) < 2 && abs(delta.cy) < 2)
Notify(GetDlgCtrlID(), 0, &mButton);
} else {
mButton = 0;
}
}
/*virtual*/ void T2DlgItemAllPurpose::OnT2DlgItemRButtonDown(UINT, CPoint inPt) {
*mDownPoint = inPt;
mButton = 1;
}
/*virtual*/ void T2DlgItemAllPurpose::OnT2DlgItemRButtonUp(UINT, CPoint inPt) {
*mUpPoint = inPt;
if (mButton == 1) {
mButton = 1;
CSize delta = *mDownPoint - *mUpPoint;
if (abs(delta.cx) < 2 && abs(delta.cy) < 2)
Notify(GetDlgCtrlID(), 0, &mButton);
} else {
mButton = 1;
}
}
CPoint T2DlgItemAllPurpose::GetUpPoint() {
return *mUpPoint;
}
CPoint T2DlgItemAllPurpose::GetDownPoint() {
return *mDownPoint;
}
|