-
Notifications
You must be signed in to change notification settings - Fork 2
/
atbview.h
203 lines (167 loc) · 5.04 KB
/
atbview.h
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
#ifndef __ATBVIEW_H__
#define __ATBVIEW_H__
#include "resource.h"
#include "psdl.h"
#include "ctrls.h"
class ATL_NO_VTABLE CPropView
{
public:
virtual ~CPropView() {}
virtual HWND Create(HWND hParent) = 0;
virtual BOOL DestroyWindow() = 0;
virtual BOOL ShowWindow(int nCmdShow) = 0;
virtual BOOL DoDataExchange(BOOL bSaveAndValidate = FALSE, UINT nCtlID = (UINT) -1) = 0;
virtual BOOL IsWindow(void) = 0;
};
template <class T>
class ATL_NO_VTABLE CPropViewImpl :
public CDialogImpl<T>, public CPropView
{
public:
virtual ~CPropViewImpl() {}
virtual HWND Create(HWND hParent)
{ return CDialogImpl<T>::Create(hParent); }
virtual BOOL DestroyWindow()
{ return CDialogImpl<T>::DestroyWindow(); }
virtual BOOL ShowWindow(int nCmdShow)
{ return CDialogImpl<T>::ShowWindow(nCmdShow); }
virtual BOOL DoDataExchange(BOOL bSaveAndValidate = FALSE, UINT nCtlID = (UINT) -1)
{ return TRUE; }
BOOL IsWindow(void)
{ return CDialogImpl<T>::IsWindow(); }
void OnFinalMessage(HWND)
{ delete this; }
};
template <WORD t_wDlgTemplateID>
class CAtbView :
public CPropViewImpl<CAtbView>,
public CWinDataExchange<CAtbView>,
public CDialogResize<CAtbView>
{
public:
enum { IDD = t_wDlgTemplateID };
BEGIN_DLGRESIZE_MAP(CAtbView)
DLGRESIZE_CONTROL(IDC_INFO, DLSZ_SIZE_X | DLSZ_SIZE_Y)
END_DLGRESIZE_MAP()
BEGIN_DDX_MAP(CAtbView)
END_DDX_MAP()
BEGIN_MSG_MAP(CAtbView)
MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog)
CHAIN_MSG_MAP(CDialogResize<CAtbView>)
END_MSG_MAP()
LRESULT OnInitDialog(UINT, WPARAM, LPARAM, BOOL&)
{
SetRedraw(FALSE);
DlgResize_Init(false, false, WS_CHILD | WS_VISIBLE);
SetRedraw();
return 0;
}
};
class CRoadView :
public CPropViewImpl<CRoadView>,
public CWinDataExchange<CRoadView>,
public CDialogResize<CRoadView>
{
public:
enum { IDD = IDD_ATB_ROAD };
BEGIN_DLGRESIZE_MAP(CRoadView)
DLGRESIZE_CONTROL(IDC_LIST, DLSZ_SIZE_X | DLSZ_SIZE_Y)
END_DLGRESIZE_MAP()
BEGIN_DDX_MAP(CRoadView)
END_DDX_MAP()
BEGIN_MSG_MAP(CRoadView)
MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog)
CHAIN_MSG_MAP(CDialogResize<CRoadView>)
END_MSG_MAP()
CRoadView(psdl::attribute *pAtb)
{
m_atb = pAtb;
}
LRESULT OnInitDialog(UINT, WPARAM, LPARAM, BOOL&);
private:
CMyListBox m_list;
psdl::attribute* m_atb;
};
class CTextureView :
public CPropViewImpl<CTextureView>,
public CWinDataExchange<CTextureView>,
public CDialogResize<CTextureView>
{
public:
enum { IDD = IDD_ATB_TEXTURE };
BEGIN_DLGRESIZE_MAP(CTextureView)
DLGRESIZE_CONTROL(IDC_EDIT, DLSZ_SIZE_X)
DLGRESIZE_CONTROL(IDC_PLACEHOLDER, DLSZ_SIZE_X | DLSZ_SIZE_Y)
END_DLGRESIZE_MAP()
BEGIN_DDX_MAP(CTextureView)
DDX_TEXT(IDC_EDIT, m_textureName)
END_DDX_MAP()
BEGIN_MSG_MAP_EX(CTextureView)
MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog)
MSG_WM_DRAWITEM(OnDrawItem)
CHAIN_MSG_MAP(CDialogResize<CTextureView>)
END_MSG_MAP()
CTextureView(psdl::attribute* pAtb, psdl* pDoc) : m_pAtb(pAtb), m_pDoc(pDoc) {}
LRESULT OnInitDialog(UINT, WPARAM, LPARAM, BOOL&);
void OnDrawItem(UINT, LPDRAWITEMSTRUCT lpdis);
private:
psdl* m_pDoc;
psdl::attribute* m_pAtb;
CString m_textureName;
};
class CTunnelView :
public CPropViewImpl<CTunnelView>,
public CDialogResize<CTunnelView>,
public COwnerDraw<CTunnelView>
{
public:
enum { IDD = IDD_ATB_TUNNEL };
BEGIN_DLGRESIZE_MAP(CTunnelView)
DLGRESIZE_CONTROL(IDC_GROUP1, DLSZ_SIZE_X)
DLGRESIZE_CONTROL(IDC_GROUP2, DLSZ_SIZE_X)
DLGRESIZE_CONTROL(IDC_GROUP3, DLSZ_SIZE_X)
DLGRESIZE_CONTROL(IDC_GROUP3, DLSZ_SIZE_Y)
DLGRESIZE_CONTROL(IDC_LIST, DLSZ_SIZE_X)
DLGRESIZE_CONTROL(IDC_LIST, DLSZ_SIZE_Y)
END_DLGRESIZE_MAP()
BEGIN_MSG_MAP_EX(CTunnelView)
COMMAND_RANGE_HANDLER(IDC_RAILING, IDC_WALL, OnRadioClicked)
COMMAND_CODE_HANDLER(BN_CLICKED, OnCheckClicked)
COMMAND_RANGE_CODE_HANDLER_EX(IDC_SPIN1, IDC_SPIN2, CN_VALUECHANGED, OnEditChange)
MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog)
NOTIFY_HANDLER(IDC_LIST, NM_CLICK, OnClick)
// NOTIFY_CODE_HANDLER(UDN_DELTAPOS, OnDeltaPos)
CHAIN_MSG_MAP(CDialogResize<CTunnelView>)
CHAIN_MSG_MAP(COwnerDraw<CTunnelView>)
REFLECT_NOTIFICATIONS()
END_MSG_MAP()
CTunnelView(psdl::attribute *pAtb)
{
m_atb = static_cast<psdl::tunnel*>(pAtb);
}
void SetState(WORD wID, bool bState)
{
::SendMessage(GetDlgItem(wID), BM_SETCHECK, bState ? BST_CHECKED : BST_UNCHECKED, 0);
}
LRESULT OnCheckClicked(WORD, WORD, HWND, BOOL&);
LRESULT OnEditChange (UINT, int, HWND);
LRESULT OnRadioClicked(WORD wNotifyCode, WORD, HWND, BOOL&)
{
if (wNotifyCode == BN_CLICKED)
{
m_atb->set_flag(BIT_STYLE, BST_CHECKED == ::SendMessage(GetDlgItem(IDC_WALL), BM_GETCHECK, 0, 0));
}
return 0;
}
LRESULT OnInitDialog(UINT, WPARAM, LPARAM, BOOL&);
LRESULT OnClick (int, LPNMHDR lpnmh, BOOL&);
LRESULT OnDeltaPos (int wParam, LPNMHDR lParam, BOOL& bHandled);
void DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct);
void MeasureItem(LPMEASUREITEMSTRUCT lpMeasureItemStruct);
private:
CListViewCtrl m_list;
CNumUpDownCtrl m_ud1, m_ud2;
float fHeight1, fHeight2;
psdl::tunnel* m_atb;
};
#endif