-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDialogBarCM.cpp
More file actions
242 lines (208 loc) · 6.21 KB
/
DialogBarCM.cpp
File metadata and controls
242 lines (208 loc) · 6.21 KB
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
233
234
235
236
237
238
239
240
241
// DialogBarCM.cpp : implementation file
//
#include "stdafx.h"
#include "krs.h"
#include "MainFrm.h"
#include "DialogBarCM.h"
#include "STAGES.h"
#include "CementView.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
// CDialogBarCM
CDialogBarCM::CDialogBarCM()
{
}
CDialogBarCM::~CDialogBarCM()
{
}
void CDialogBarCM::DoDataExchange(CDataExchange* pDX)
{
CDialogBar::DoDataExchange(pDX);
DDX_Control(pDX, IDC_START_PAUSE_STAGE, m_button_start_pause_stage);
DDX_Control(pDX, IDC_FINISH_STAGE, m_button_finish_stage);
DDX_Control(pDX, IDC_RESTART_STAGE, m_button_restart_stage);
DDX_Control(pDX, IDC_LIST_PHASE, m_list_selected_stage);
DDX_Control(pDX, IDC_PANEL_KNOPKI, m_PanelKnopki);
}
BEGIN_MESSAGE_MAP(CDialogBarCM, CDialogBar)
ON_UPDATE_COMMAND_UI(IDC_START_PAUSE_STAGE, OnUpdateButtonStartPauseStage)
ON_UPDATE_COMMAND_UI(IDC_FINISH_STAGE, OnUpdateButtonFinishStage)
ON_UPDATE_COMMAND_UI(IDC_RESTART_STAGE, OnUpdateButtonRestartStage)
ON_BN_CLICKED(IDC_START_PAUSE_STAGE, OnButtonStartPauseStage)
ON_BN_CLICKED(IDC_FINISH_STAGE, OnButtonFinishStage)
ON_BN_CLICKED(IDC_RESTART_STAGE, OnButtonRestartStage)
ON_MESSAGE(WM_INITDIALOG, OnMyInitDialog)
ON_WM_SIZE()
ON_WM_PAINT()
ON_WM_LBUTTONDOWN()
ON_WM_LBUTTONUP()
ON_WM_MOUSEMOVE()
ON_WM_PAINT()
END_MESSAGE_MAP()
void CDialogBarCM::OnPaint()
{
CPaintDC dc(this);
CRect rect;
m_list_selected_stage.GetClientRect(&rect);
if (m_list_selected_stage.m_column_width != m_list_selected_stage.m_list_width)
rect.right = m_list_selected_stage.m_column_width - 1;
rect.InflateRect(1, 1);
m_list_selected_stage.ClientToScreen(&rect);
ScreenToClient(&rect);
dc.SelectStockObject(NULL_BRUSH);
dc.Rectangle(&rect);
}
void CDialogBarCM::ResizeOtherBars()
{
if(m_wndDialogPanelCement.m_hWnd == NULL) return;
m_wndDialogPanelCement.Invalidate(true);
}
// CDialogBarCM message handlers
LRESULT CDialogBarCM::OnMyInitDialog(WPARAM /*wParam*/, LPARAM /*lParam*/)
{
UpdateData(false);
GetClientRect(&m_rec_s);
ClientToScreen(&m_rec_s);
pFrm->ScreenToClient(&m_rec_s);
AdjustButtonNames();
// m_PanelKnopki.Init(STAGES_GetStagesNumber(), CSize(20,20), pApp->GetView(gt_cement));
return true;
}
void CDialogBarCM::RecalcListWidth()
{
CRect rect;
GetClientRect(&rect);
m_list_selected_stage.m_list_width = rect.Width() - 2*STAGES_zazor - 2;
m_list_selected_stage.m_column_width = m_list_selected_stage.m_list_width;
if (m_list_selected_stage.m_hWnd != NULL)
{
if (m_list_selected_stage.GetItemCount() > m_list_selected_stage.GetCountPerPage())
m_list_selected_stage.m_column_width -= 16 + STAGES_zazor;
m_list_selected_stage.SetColumnWidth(0, m_list_selected_stage.m_column_width);
}
}
void CDialogBarCM::OnUpdateLoad(CCmdUI* pCmdUi)
{
pCmdUi->Enable(STAGES_GetCurrentMode() != STAGES_MODE_EXECUTION);
}
void CDialogBarCM::OnUpdateUseAsTemplate(CCmdUI* pCmdUi)
{
pCmdUi->Enable(STAGES_GetCurrentMode() == STAGES_MODE_ARCHIVE);
}
void CDialogBarCM::OnUpdateStart(CCmdUI* pCmdUi)
{
pCmdUi->Enable(STAGES_GetCurrentMode() == STAGES_MODE_EDIT && STAGES_GetStagesNumber() > 0);
}
void CDialogBarCM::OnUpdateNext(CCmdUI* pCmdUi)
{
pCmdUi->Enable(STAGES_GetCurrentMode() == STAGES_MODE_EXECUTION && STAGES_GetExecutingStage() < STAGES_GetStagesNumber());
}
void CDialogBarCM::OnUpdateFinish(CCmdUI* pCmdUi)
{
pCmdUi->Enable(STAGES_GetCurrentMode() == STAGES_MODE_EXECUTION && STAGES_GetExecutingStage() == STAGES_GetStagesNumber());
}
void CDialogBarCM::OnUpdateBreak(CCmdUI* pCmdUi)
{
pCmdUi->Enable(STAGES_GetCurrentMode() == STAGES_MODE_EXECUTION && STAGES_GetExecutingStage() != STAGES_GetStagesNumber());
}
void CDialogBarCM::OnUpdateButtonStartPauseStage(CCmdUI* pCmdUi)
{
switch(STAGES_GetCurrentMode())
{
case STAGES_MODE_EDIT: OnUpdateStart(pCmdUi); break;
case STAGES_MODE_ARCHIVE: pCmdUi->Enable(FALSE); break;
default: pCmdUi->Enable(TRUE);
}
}
void CDialogBarCM::OnUpdateMenuBreakFinishAll(CCmdUI* pCmdUi)
{
switch(STAGES_GetCurrentMode())
{
case STAGES_MODE_EXECUTION:
case STAGES_MODE_PAUSE:
case STAGES_MODE_BREAK:
pCmdUi->Enable(TRUE); break;
default: pCmdUi->Enable(FALSE);
}
}
void CDialogBarCM::OnUpdateButtonFinishStage(CCmdUI* pCmdUi)
{
switch(STAGES_GetCurrentMode())
{
case STAGES_MODE_EXECUTION:
case STAGES_MODE_PAUSE:
pCmdUi->Enable(TRUE); break;
default: pCmdUi->Enable(FALSE);
}
}
void CDialogBarCM::OnUpdateButtonRestartStage(CCmdUI* pCmdUi)
{
switch(STAGES_GetCurrentMode())
{
case STAGES_MODE_EXECUTION:
case STAGES_MODE_PAUSE:
pCmdUi->Enable(TRUE); break;
default: pCmdUi->Enable(FALSE);
}
}
void CDialogBarCM::OnButtonStartPauseStage()
{
STAGES_StartPauseStage();
AdjustButtonNames();
}
void CDialogBarCM::OnButtonFinishStage()
{
STAGES_FinishStage();
AdjustButtonNames();
}
void CDialogBarCM::OnButtonFinishAllStages()
{
STAGES_FinishAll();
AdjustButtonNames();
}
void CDialogBarCM::OnButtonRestartStage()
{
STAGES_RestartStage();
AdjustButtonNames();
}
void CDialogBarCM::OnButtonRestartAllStages()
{
STAGES_RestartAll();
AdjustButtonNames();
}
void CDialogBarCM::AdjustButtonNames()
{
STAGES_Mode mode = STAGES_GetCurrentMode();
int stage_num = STAGES_GetExecutingStage();
CString big_button_name, menu_name;
if (mode == STAGES_MODE_BREAK || mode == STAGES_MODE_EDIT || mode == STAGES_MODE_ARCHIVE)
{
big_button_name.Format("Íà÷àòü ýòàï ¹ %d", (mode == STAGES_MODE_BREAK)?stage_num:1);
menu_name = "Íà÷àòü ýòàï";
}
else
if (mode == STAGES_MODE_EXECUTION)
{
big_button_name = "Ïàóçà";
menu_name = "Ïàóçà";
}
else
if (STAGES_MODE_PAUSE)
{
big_button_name.Format("Ïðîäîëæèòü ýòàï ¹ %d", stage_num);
menu_name = "Ïðîäîëæèòü ýòàï";
}
m_wndDialogBarCM.m_button_start_pause_stage.SetWindowText(big_button_name); // äëÿ âûçîâà èç ìåíþ
big_button_name.Format("Çàêîí÷èòü ýòàï ¹ %d", max(1, stage_num));
m_wndDialogBarCM.m_button_finish_stage.SetWindowText(big_button_name); // äëÿ âûçîâà èç ìåíþ
big_button_name.Format("Ñáðîñèòü äàííûå ýòàïà ¹ %d", max(1, stage_num));
m_wndDialogBarCM.m_button_restart_stage.SetWindowText(big_button_name); // äëÿ âûçîâà èç ìåíþ
}
void CDialogBarCM::OnSize(UINT nType, int cx, int cy)
{
CDialogBar::OnSize(nType, cx, cy);
RecalcListWidth();
}