-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathCommonKeywordPage.cpp
232 lines (191 loc) · 5.99 KB
/
CommonKeywordPage.cpp
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
224
225
226
227
228
229
230
231
232
// CommonKeywordPage.cpp : implementation file
//
// $Id$
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "phreeqci2.h"
#include "phrqtype.h" // LDBLE
#include "CommonKeywordPage.h"
#include "DDX_DDV.h"
#include "DelayUpdate.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CCommonKeywordPage property page
IMPLEMENT_DYNCREATE(CCommonKeywordPage, baseCommonKeywordPage)
CCommonKeywordPage::CCommonKeywordPage() : baseCommonKeywordPage(CCommonKeywordPage::IDD)
{
//{{AFX_DATA_INIT(CCommonKeywordPage)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
}
CCommonKeywordPage::CCommonKeywordPage(UINT nIDTemplate, UINT nIDCaption /*= 0*/)
: baseCommonKeywordPage(nIDTemplate, nIDCaption)
{
}
CCommonKeywordPage::CCommonKeywordPage(LPCTSTR lpszTemplateName, UINT nIDCaption /*= 0*/)
: baseCommonKeywordPage(lpszTemplateName, nIDCaption)
{
}
CCommonKeywordPage::~CCommonKeywordPage()
{
}
#ifdef _DEBUG
CCommonKeywordSheet* CCommonKeywordPage::GetSheet() // non-debug version is inline
{
CCommonKeywordSheet* pSheet = (CCommonKeywordSheet*)GetParent();
ASSERT_KINDOF(CCommonKeywordSheet, pSheet);
return pSheet;
}
#endif
void CCommonKeywordPage::DoDataExchange(CDataExchange* pDX)
{
baseCommonKeywordPage::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CCommonKeywordPage)
DDX_Control(pDX, IDC_S_DESC_INPUT, m_btnInputDesc);
DDX_Control(pDX, IDC_E_DESC_INPUT, m_eInputDesc);
DDX_Control(pDX, IDC_MSHFG_NUM_DESC, m_egNumDesc);
//}}AFX_DATA_MAP
DDX_NumDesc(pDX, IDC_MSHFG_NUM_DESC);
}
void CCommonKeywordPage::DDX_NumDesc(CDataExchange *pDX, int nIDC)
{
ASSERT(nIDC == IDC_MSHFG_NUM_DESC);
// avoid flashing grid
CDelayUpdate update(this, nIDC);
if (m_bFirstSetActive)
{
InitNumDesc();
}
long nCol = 1;
if (pDX->m_bSaveAndValidate)
{
CString strValue;
// lower range (m_n_user)
DDX_GridText(pDX, nIDC, 0, nCol, strValue);
if (strValue.IsEmpty())
{
GetSheet()->m_n_user = 1;
}
else
{
DDX_GridText(pDX, nIDC, 0, nCol, GetSheet()->m_n_user);
// Please enter an integer greater than or equal to %1.
// DDV_MinEqualInt(pDX, GetSheet()->m_n_user, 0);
// The starting number must be an integer greater than or equal to zero.
DDV_MinEqualInt(pDX, GetSheet()->m_n_user, 0, IDS_STRING139);
}
// upper range (m_n_user_end)
DDX_GridText(pDX, nIDC, 1, nCol, strValue);
if (strValue.IsEmpty())
{
GetSheet()->m_n_user_end = CCommonKeywordSheet::N_EMPTY;
}
else
{
DDX_GridText(pDX, nIDC, 1, nCol, GetSheet()->m_n_user_end);
// Please enter an integer greater than or equal to %1.
// DDV_MinEqualInt(pDX, GetSheet()->m_n_user_end, GetSheet()->m_n_user);
// The ending number must be an integer greater than or equal to the starting number.
DDV_MinEqualInt(pDX, GetSheet()->m_n_user_end, GetSheet()->m_n_user, IDS_STRING138);
}
}
else
{
CString strEmpty(_T(""));
// lower range (m_n_user)
if (GetSheet()->m_n_user != CCommonKeywordSheet::N_EMPTY)
{
DDX_GridText(pDX, nIDC, 0, nCol, GetSheet()->m_n_user);
}
else
{
DDX_GridText(pDX, nIDC, 0, nCol, strEmpty);
}
// upper range (m_n_user_end)
if (GetSheet()->m_n_user_end != CCommonKeywordSheet::N_EMPTY
&&
GetSheet()->m_n_user != GetSheet()->m_n_user_end)
{
DDX_GridText(pDX, nIDC, 1, nCol, GetSheet()->m_n_user_end);
}
else
{
DDX_GridText(pDX, nIDC, 1, nCol, strEmpty);
}
// set intitial starting position
// COMMENT: {10/8/2009 11:24:32 PM} CMSHFlexGrid* pWnd = (CMSHFlexGrid*)pDX->PrepareOleCtrl(nIDC);
CMSHFlexGrid* pWnd = (CMSHFlexGrid*)::PrepareEditGridCtrl(pDX, nIDC);
ASSERT_KINDOF(CMSHFlexGrid, pWnd);
pWnd->SetRow(0);
pWnd->SetCol(nCol);
}
// description (m_strDesc)
DDX_GridText(pDX, nIDC, 2, nCol, GetSheet()->m_strDesc);
}
void CCommonKeywordPage::InitNumDesc()
{
ASSERT( m_egNumDesc.GetSafeHwnd() != NULL );
// set title column widths
const long nCol1 = 1500;
m_egNumDesc.SetColWidth(0, 0, nCol1);
// set edit column width
CRect rect;
CDC* pDC = GetDC();
int nLogX = pDC->GetDeviceCaps(LOGPIXELSX);
m_egNumDesc.GetClientRect(&rect);
m_egNumDesc.SetColWidth(1, 0, MulDiv(rect.right, TWIPS_PER_INCH, nLogX) - nCol1);
// set grid titles
m_egNumDesc.SetTextMatrix(0, 0, _T("Starting number"));
m_egNumDesc.SetTextMatrix(1, 0, _T("Ending number"));
m_egNumDesc.SetTextMatrix(2, 0, _T("Description"));
// set bold titles
m_egNumDesc.SetRow(0), m_egNumDesc.SetCol(0);
m_egNumDesc.SetCellFontBold(TRUE);
}
BEGIN_MESSAGE_MAP(CCommonKeywordPage, baseCommonKeywordPage)
//{{AFX_MSG_MAP(CCommonKeywordPage)
ON_WM_SIZE()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CCommonKeywordPage message handlers
void CCommonKeywordPage::OnSize(UINT nType, int cx, int cy)
{
baseCommonKeywordPage::OnSize(nType, cx, cy);
// resize the columns within the num desc grid
if (m_egNumDesc.GetSafeHwnd())
{
long nCol0 = m_egNumDesc.GetColWidth(0, 0);
CRect rect;
CDC* pDC = GetDC();
int nLogX = pDC->GetDeviceCaps(LOGPIXELSX);
m_egNumDesc.GetClientRect(&rect);
m_egNumDesc.SetColWidth(1, 0, MulDiv(rect.right, TWIPS_PER_INCH, nLogX) - nCol0);
}
}
BEGIN_EVENTSINK_MAP(CCommonKeywordPage, baseCommonKeywordPage)
//{{AFX_EVENTSINK_MAP(CCommonKeywordPage)
ON_EVENT(CCommonKeywordPage, IDC_MSHFG_NUM_DESC, -602 /* KeyDown */, OnKeyDownMshfgNumDesc, VTS_PI2 VTS_I2)
//}}AFX_EVENTSINK_MAP
END_EVENTSINK_MAP()
/////////////////////////////////////////////////////////////////////////////
// CCommonKeywordPage event handlers
void CCommonKeywordPage::OnKeyDownMshfgNumDesc(short FAR* KeyCode, short Shift)
{
UNUSED(Shift);
switch (*KeyCode)
{
case VK_DELETE :
// just fill with empty strings
m_egNumDesc.SetRedraw(FALSE);
m_egNumDesc.SetFillStyle(flexFillRepeat);
m_egNumDesc.SetText(_T(""));
m_egNumDesc.SetFillStyle(flexFillSingle);
m_egNumDesc.SetRedraw(TRUE);
break;
}
}