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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
|
#include "T2DlgItem.h"
#include "T2ImageObj.h"
#include "T2TowerDoc.h"
#include "T2WorldDef.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
T2DlgItem::T2DlgItem() {
}
T2DlgItem::T2DlgItem(T2TowerDoc* towerDoc, T2ImageObj* imageObj, CPalette* palette) {
mTowerDoc = towerDoc;
mImageObj = imageObj;
mPalette = palette;
mPattern = 0;
m74 = 0;
mFont = NULL;
mValue = 0;
}
/*virtual*/ T2DlgItem::~T2DlgItem() {
}
BEGIN_MESSAGE_MAP(T2DlgItem, CWnd)
ON_WM_ERASEBKGND()
ON_WM_LBUTTONDOWN()
ON_WM_LBUTTONUP()
ON_WM_RBUTTONDOWN()
ON_WM_RBUTTONUP()
ON_WM_MOUSEMOVE()
ON_WM_ENABLE()
ON_WM_CREATE()
ON_WM_SIZE()
ON_WM_SETFOCUS()
ON_WM_KILLFOCUS()
ON_WM_TIMER()
ON_WM_CLOSE()
END_MESSAGE_MAP()
/*virtual*/ BOOL T2DlgItem::Create(const char* inWindowName, DWORD inStyle, const RECT& inRect, CWnd* inParentWnd, UINT inID) {
CRect crect = inRect;
CString className = AfxRegisterWndClass(
WS_EX_CLIENTEDGE,
LoadCursor(NULL, IDC_ARROW),
(HBRUSH) GetStockObject(WHITE_BRUSH),
NULL);
return CWnd::Create(className, inWindowName, inStyle, crect, inParentWnd, inID);
}
/*virtual*/ T2BitImage* T2DlgItem::GetObjectImage(RECT& outRect, const char* inName, int inPattern, int inGrade, int inSpan, int inOffset) const {
T2BitImage *theImage = NULL;
int index;
if (mImageObj) {
index = mImageObj->FindObject(inName, inPattern, inGrade, inSpan, inOffset);
if (index != -1)
theImage = mImageObj->GetObjectImage(index, outRect);
}
if (!theImage && mTowerDoc && mTowerDoc->mWorldDef) {
index = mTowerDoc->mWorldDef->mImageObj->FindObject(inName, inPattern, inGrade, inSpan, inOffset);
if (index != -1)
theImage = mTowerDoc->mWorldDef->mImageObj->GetObjectImage(index, outRect);
}
return theImage;
}
/*virtual*/ void T2DlgItem::PostNcDestroy() {
DestroySelf();
}
/*virtual*/ void T2DlgItem::DestroySelf() {
delete this;
}
/*virtual*/ BOOL T2DlgItem::OnT2DlgItemEraseBkgnd(CDC*) {
return false;
}
/*virtual*/ void T2DlgItem::OnT2DlgItemLButtonDown(UINT nFlags, CPoint pt) {
}
/*virtual*/ void T2DlgItem::OnT2DlgItemLButtonUp(UINT nFlags, CPoint pt) {
}
/*virtual*/ void T2DlgItem::OnT2DlgItemRButtonDown(UINT nFlags, CPoint pt) {
}
/*virtual*/ void T2DlgItem::OnT2DlgItemRButtonUp(UINT nFlags, CPoint pt) {
}
/*virtual*/ void T2DlgItem::OnT2DlgItemMouseMove(UINT nFlags, CPoint pt) {
}
/*virtual*/ void T2DlgItem::OnT2DlgItemEnable(int) {
Invalidate();
}
/*virtual*/ int T2DlgItem::OnT2DlgItemCreate(CREATESTRUCT*) {
return false;
}
BOOL T2DlgItem::OnEraseBkgnd(CDC* pDC) {
return OnT2DlgItemEraseBkgnd(pDC);
}
void T2DlgItem::OnLButtonDown(UINT nFlags, CPoint pt) {
OnT2DlgItemLButtonDown(nFlags, pt);
}
void T2DlgItem::OnLButtonUp(UINT nFlags, CPoint pt) {
OnT2DlgItemLButtonUp(nFlags, pt);
}
void T2DlgItem::OnRButtonDown(UINT nFlags, CPoint pt) {
OnT2DlgItemRButtonDown(nFlags, pt);
}
void T2DlgItem::OnRButtonUp(UINT nFlags, CPoint pt) {
OnT2DlgItemRButtonUp(nFlags, pt);
}
void T2DlgItem::OnMouseMove(UINT nFlags, CPoint pt) {
OnT2DlgItemMouseMove(nFlags, pt);
}
void T2DlgItem::OnEnable(int v) {
CWnd::OnEnable(v);
OnT2DlgItemEnable(v);
}
int T2DlgItem::OnCreate(CREATESTRUCT* cs) {
if (CWnd::OnCreate(cs) == -1)
return -1;
return OnT2DlgItemCreate(cs);
}
/*virtual*/ void T2DlgItem::CreateSubItem(void*) {
}
/*virtual*/ void T2DlgItem::SetFont(HFONT font) {
mFont = font;
Invalidate();
}
/*virtual*/ int T2DlgItem::GetValue() {
return mValue;
}
/*virtual*/ void T2DlgItem::SetValue(int value) {
mValue = value;
Invalidate();
}
/*virtual*/ void T2DlgItem::GetDescriptor(CString& outStr) const {
GetWindowText(outStr);
}
/*virtual*/ void T2DlgItem::SetDescriptor(const CString& str) {
SetWindowText(str);
}
void T2DlgItem::Notify(unsigned short msg, void* data) {
Notify(GetDlgCtrlID(), msg, data);
}
void T2DlgItem::Notify(unsigned short id, unsigned short msg, void* data) {
BroadcastMessage(id, data);
GetParent()->SendMessage(WM_COMMAND, id | (msg << 16), (LPARAM) m_hWnd);
}
int T2DlgItem::GetPattern() const {
return IsWindowEnabled() ? mPattern : 200;
}
void T2DlgItem::SetPattern(int pattern) {
mPattern = pattern;
}
void T2DlgItem::OnSize(UINT nType, int cx, int cy) {
CWnd::OnSize(nType, cx, cy);
OnT2Size(nType, cx, cy);
}
/*virtual*/ void T2DlgItem::OnT2Size(UINT nType, int cx, int cy) {
}
void T2DlgItem::OnSetFocus(CWnd* wnd) {
CWnd::OnSetFocus(wnd);
OnT2SetFocus(wnd);
}
void T2DlgItem::OnKillFocus(CWnd* wnd) {
CWnd::OnKillFocus(wnd);
OnT2KillFocus(wnd);
}
/*virtual*/ void T2DlgItem::OnT2SetFocus(CWnd* wnd) {
}
/*virtual*/ void T2DlgItem::OnT2KillFocus(CWnd* wnd) {
}
void T2DlgItem::OnTimer(UINT id) {
OnT2Timer(id);
CWnd::OnTimer(id);
}
/*virtual*/ void T2DlgItem::OnT2Timer(UINT id) {
}
void T2DlgItem::OnClose() {
OnT2Close();
CWnd::OnClose();
}
/*virtual*/ void T2DlgItem::OnT2Close() {
}
|