forked from gopa810/gcal-cpp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ConditionsView.cpp
194 lines (157 loc) · 4.52 KB
/
ConditionsView.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
// ConditionsView.cpp : implementation file
//
#include "stdafx.h"
#include "TString.h"
#include "vcal5beta.h"
#include "ConditionsView.h"
#include "locationref.h"
#include "dlggetlocation.h"
#include "CustomEvent.h"
#include "GCStrings.h"
#include "GCGlobal.h"
/////////////////////////////////////////////////////////////////////////////
// CConditionsView
CConditionsView::CConditionsView()
{
memset(&ncm, 0, sizeof(NONCLIENTMETRICS));
ncm.cbSize = sizeof(NONCLIENTMETRICS);
SystemParametersInfo(SPI_GETNONCLIENTMETRICS, 0, &ncm, 0);
}
CConditionsView::~CConditionsView()
{
}
BEGIN_MESSAGE_MAP(CConditionsView, CWnd)
//{{AFX_MSG_MAP(CConditionsView)
ON_WM_CREATE()
ON_WM_SIZE()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CConditionsView message handlers
int CConditionsView::GetProperHeight()
{
return lastYposition;
}
int CConditionsView::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
//int i, j, n;
CRect rcClient;
TString str;
int ylev = 2;
int basicHeight = ncm.iCaptionHeight;
GetClientRect(&rcClient);
if (CWnd::OnCreate(lpCreateStruct) == -1)
return -1;
m_comboFont.CreateFontIndirect(&(ncm.lfMenuFont));
m_infoFont.CreateFontIndirect(&(ncm.lfCaptionFont));
m_wnd_texts[3].Create("Text to find:", WS_CHILD | WS_VISIBLE | SS_LEFT,
CRect(4, ylev, 300, ylev + basicHeight), this);
m_wnd_texts[3].SetFont(&m_infoFont);
ylev += basicHeight + 8;
m_edits[3].Create(WS_CHILD | WS_VISIBLE | WS_BORDER | ES_LEFT,
CRect(4, ylev, 300, ylev + basicHeight), this, IDC_EDIT4);
m_edits[3].SetFont(&m_comboFont);
// button FIND
m_buttons[1].Create("Find", WS_VISIBLE | WS_CHILD | BS_FLAT,
CRect(312, ylev, 376, ylev + basicHeight), this, 131);
m_buttons[1].SetFont(&m_comboFont);
ylev += basicHeight + 20;
CRect cr;
SetFont(&m_comboFont);
const char * pszTitle;
CSize cs;
CDC * pdc = GetDC();
// row 1
// button for setting location
cr.SetRect(4, ylev, 100, ylev + basicHeight);
m_buttons[0].Create("Set Location", WS_VISIBLE | WS_CHILD | BS_FLAT, cr, this, 130);
m_buttons[0].SetFont(&m_comboFont);
// location
cr.left = 120;
cr.right = 800;
m_edits[0].Create(WS_VISIBLE | WS_CHILD | ES_READONLY, cr, this, 132);
m_edits[0].SetFont(&m_infoFont);
m_earth = (EARTHDATA)GCGlobal::lastLocation;
m_dst = GCGlobal::lastLocation.m_nDST;
GCGlobal::lastLocation.GetFullName(&str);
m_edits[0].SetWindowText(str);
ylev += basicHeight + 8;
// row 2
// start year
cr.SetRect(4, ylev, 4, ylev + basicHeight);
pszTitle = "Start Year:";
cs = pdc->GetTextExtent(pszTitle, _tcslen(pszTitle));
cr.right += cs.cx + 4;
m_wnd_texts[0].Create(pszTitle, WS_VISIBLE | WS_CHILD | SS_CENTER, cr, this);
m_wnd_texts[0].SetFont(&m_comboFont);
cr.left = cr.right;
// EDIT START YEAR
SYSTEMTIME st;
GetLocalTime(&st);
str.Format("%d", st.wYear);
cr.right = cr.left + 58;
m_edits[1].Create(WS_BORDER | WS_VISIBLE | WS_CHILD | ES_NUMBER | ES_RIGHT, cr, this, 133);
m_edits[1].SetFont(&m_comboFont);
m_edits[1].SetWindowText(str);
cr.left = cr.right + 4;
// title count....
pszTitle = "Count of Years:";
cs = pdc->GetTextExtent(pszTitle, _tcslen(pszTitle));
cr.right += cs.cx + 4;
m_wnd_texts[1].Create(pszTitle, WS_VISIBLE | WS_CHILD | SS_CENTER, cr, this);
m_wnd_texts[1].SetFont(&m_comboFont);
cr.left = cr.right;
// EDIT COUNT YEARS
cr.right = cr.left + 58;
m_edits[2].Create(WS_BORDER | WS_VISIBLE | WS_CHILD | ES_NUMBER | ES_RIGHT, cr, this, 134);
m_edits[2].SetFont(&m_comboFont);
m_edits[2].SetWindowText("2");
cr.left = cr.right + 4;
lastYposition = ylev + basicHeight + 8;
return 0;
}
BOOL CConditionsView::OnCommand(WPARAM wParam, LPARAM lParam)
{
//UINT nRow, nCol, n;
CString str;
if (HIWORD(wParam) == BN_CLICKED)
{
// stlacil tlacidlo
if (LOWORD(wParam) == 130)
{
// set location
DlgGetLocation dlg(GCStrings::getString(110));
dlg.m_bFinal = TRUE;
TString str;
if (dlg.DoModal() == IDOK)
{
m_earth = (EARTHDATA)GCGlobal::lastLocation;
m_dst = GCGlobal::lastLocation.m_nDST;
GCGlobal::lastLocation.GetFullName(&str);
m_edits[0].SetWindowText(str);
}
}
else if (LOWORD(wParam) == 131)
{
// find
GetParent()->PostMessage(WM_COMMAND, ID_EVENT_FIND);
}
}
return CWnd::OnCommand(wParam, lParam);
}
int CConditionsView::GetStartYear()
{
CString str;
m_edits[1].GetWindowText(str);
return _ttoi(str);
}
int CConditionsView::GetCountYear()
{
CString str;
m_edits[2].GetWindowText(str);
return _ttoi(str);
}
void CConditionsView::OnSize(UINT nType, int cx, int cy)
{
CWnd::OnSize(nType, cx, cy);
}