-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathSkinProgressTestView.cpp
465 lines (393 loc) · 13.6 KB
/
SkinProgressTestView.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
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
// SkinProgressTestView.cpp : implementation of the CSkinProgressTestView class
//
#include "stdafx.h"
#include "SkinProgressTest.h"
#include "SkinProgressTestDoc.h"
#include "SkinProgressTestView.h"
#ifdef dCSP_DIALOG_PROGRESS
#include "SkinProgressTestDialog.h"
#endif // dCSP_DIALOG_PROGRESS
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CSkinProgressTestView
IMPLEMENT_DYNCREATE(CSkinProgressTestView, CFormView)
BEGIN_MESSAGE_MAP(CSkinProgressTestView, CFormView)
//{{AFX_MSG_MAP(CSkinProgressTestView)
ON_BN_CLICKED(IDC_BUTTON_TEST, OnButtonTest)
ON_BN_CLICKED(IDC_RADIO_DEFAULT, OnRadioDefault)
ON_BN_CLICKED(IDC_RADIO_AQUA, OnRadioAqua)
ON_BN_CLICKED(IDC_RADIO_LUNA, OnRadioLuna)
ON_BN_CLICKED(IDC_RADIO_PHOTON, OnRadioPhoton)
ON_WM_SIZE()
#ifdef dCSP_DIALOG_PROGRESS
ON_BN_CLICKED(IDC_BUTTON_DIALOG, OnButtonDialog)
#endif // dCSP_DIALOG_PROGRESS
ON_CBN_SELCHANGE(IDC_COMBO_PROGRESS, OnSelchangeComboProgress)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CSkinProgressTestView construction/destruction
CSkinProgressTestView::CSkinProgressTestView()
: CFormView(CSkinProgressTestView::IDD)
{
//{{AFX_DATA_INIT(CSkinProgressTestView)
m_nLimit = 30000;
m_nPane = 0;
m_nSize = 200;
m_strText = _T("This text allows to test the text wrapping");
m_bCheckReverse = FALSE;
//}}AFX_DATA_INIT
// TODO: add construction code here
m_poSkinProgress = NULL;
}
CSkinProgressTestView::~CSkinProgressTestView()
{
// if(
// (m_poSkinProgress != NULL)
// && (IsWindow(m_poSkinProgress->m_hWnd))
// )
// {
// delete m_poSkinProgress;
// m_poSkinProgress = NULL;
// }else{}
}
void CSkinProgressTestView::DoDataExchange(CDataExchange* pDX)
{
CFormView::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CSkinProgressTestView)
DDX_Control(pDX, IDC_HEAD_REVERSE, m_cHeadReverse);
DDX_Control(pDX, IDC_CHECK_REVERSE, m_cCheckReverse);
DDX_Control(pDX, IDC_BUTTON_DIALOG, m_cButtonDialog);
DDX_Control(pDX, IDC_PANE4, m_cPane4);
DDX_Control(pDX, IDC_PANE3, m_cPane3);
DDX_Control(pDX, IDC_PANE2, m_cPane2);
DDX_Control(pDX, IDC_PANE1, m_cPane1);
DDX_Control(pDX, IDC_PANE0, m_cPane0);
DDX_Control(pDX, IDC_BOTTOM_RIGHT, m_cBottomRight);
DDX_Control(pDX, IDC_COMBO_PROGRESS, m_cProgress);
DDX_Control(pDX, IDC_SPIN_SIZE, m_cSize);
DDX_Control(pDX, IDC_SPIN_PANE, m_cPane);
DDX_Control(pDX, IDC_SPIN_LIMIT, m_cLimit);
DDX_Control(pDX, IDC_BUTTON_TEST, m_cButtonTest);
DDX_Text(pDX, IDC_EDIT_LIMIT, m_nLimit);
DDV_MinMaxInt(pDX, m_nLimit, 1, 65535);
DDX_Text(pDX, IDC_EDIT_PANE, m_nPane);
DDV_MinMaxInt(pDX, m_nPane, 0, 4);
DDX_Text(pDX, IDC_EDIT_SIZE, m_nSize);
DDV_MinMaxInt(pDX, m_nSize, -1280, 1280);
DDX_Text(pDX, IDC_EDIT_TEXT, m_strText);
DDV_MaxChars(pDX, m_strText, 256);
DDX_Check(pDX, IDC_CHECK_REVERSE, m_bCheckReverse);
//}}AFX_DATA_MAP
}
BOOL CSkinProgressTestView::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs
return CFormView::PreCreateWindow(cs);
}
void CSkinProgressTestView::OnInitialUpdate()
{
// Init
// Process
CFormView::OnInitialUpdate();
GetParentFrame()->RecalcLayout();
ResizeParentToFit();
// Select AUTOSIZE
m_cProgress.SetCurSel(6);
// Select Default bitmap
CheckRadioButton(IDC_RADIO_DEFAULT, IDC_RADIO_PHOTON, IDC_RADIO_DEFAULT);
// Select Size
m_cSize.SetRange32(-1280, 1280);
m_cSize.SetPos(200);
// Select Limit
m_cLimit.SetRange32(1, 65535);
m_cLimit.SetPos(30000);
// Select Pane
m_cPane.SetRange32(0, 4);
m_cPane.SetPos(0);
// Don't reverse the bitmap
m_bCheckReverse = false;
#ifdef dCSP_DIALOG_PROGRESS
m_cButtonDialog.EnableWindow(true);
#else
m_cButtonDialog.EnableWindow(false);
#endif // dCSP_DIALOG_PROGRESS
#ifdef dCSP_SLIDERBAR_METHOD
m_cHeadReverse.EnableWindow(true);
m_cCheckReverse.EnableWindow(true);
#else
m_cHeadReverse.EnableWindow(false);
m_cCheckReverse.EnableWindow(false);
#endif // dCSP_SLIDERBAR_METHOD
// Shows pane text
m_cPane0.ShowWindow(SW_SHOW);
m_cPane1.ShowWindow(SW_SHOW);
m_cPane2.ShowWindow(SW_SHOW);
m_cPane3.ShowWindow(SW_SHOW);
m_cPane4.ShowWindow(SW_SHOW);
}
/////////////////////////////////////////////////////////////////////////////
// CSkinProgressTestView diagnostics
#ifdef _DEBUG
void CSkinProgressTestView::AssertValid() const
{
CFormView::AssertValid();
}
void CSkinProgressTestView::Dump(CDumpContext& dc) const
{
CFormView::Dump(dc);
}
CSkinProgressTestDoc* CSkinProgressTestView::GetDocument() // non-debug version is inline
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CSkinProgressTestDoc)));
return (CSkinProgressTestDoc*)m_pDocument;
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CSkinProgressTestView message handlers
void CSkinProgressTestView::OnButtonTest()
{
// TODO: Add your control notification handler code here
UpdateData(true); // Update variables
m_cButtonTest.EnableWindow(false); // Disable the 'TEST' button
CBitmap* poBitmap = NULL;
// Select the bitmap
int nCheckedRadio = GetCheckedRadioButton(IDC_RADIO_DEFAULT, IDC_RADIO_PHOTON);
switch(nCheckedRadio)
{
case IDC_RADIO_DEFAULT :
poBitmap = NULL;
break;
case IDC_RADIO_AQUA :
poBitmap = new CBitmap();
poBitmap->LoadBitmap(IDB_BMP_AQUA);
break;
case IDC_RADIO_LUNA :
poBitmap = new CBitmap();
poBitmap->LoadBitmap(IDB_BMP_LUNA);
break;
case IDC_RADIO_PHOTON :
poBitmap = new CBitmap();
poBitmap->LoadBitmap(IDB_BMP_PHOTON);
break;
default :
poBitmap = NULL;
break;
}
// m_poSkinProgress = new CSkinProgress(m_strText, m_nSize, m_nLimit, m_nPane, m_cProgress.GetCurSel(), poBitmap
//#ifdef dCSP_SLIDERBAR_METHOD
// ,m_bCheckReverse
//#endif // dCSP_SLIDERBAR_METHOD
// );
{ // Direct creation (instead of using pointer) - the CSkinProgress object only exists between the brakets
CSkinProgress SkinProgress
(
m_strText,
m_nLimit,
m_cProgress.GetCurSel() - (cSPT_EnumElements - 1),
m_nPane,
m_nSize,
poBitmap
#ifdef dCSP_SLIDERBAR_METHOD
,m_bCheckReverse
#endif // dCSP_SLIDERBAR_METHOD
);
m_poSkinProgress = &SkinProgress; // For event management, see below, [OnRadioDefault] -> [OnRadioPhoton]
/*
// dCSP_TIMED_REDRAW test purpose
SYSTEMTIME TimeIn;
FILETIME TimeOut;
ULARGE_INTEGER TimeOne;
ULARGE_INTEGER TimeTwo;
GetLocalTime(&TimeIn);
SystemTimeToFileTime(&TimeIn, &TimeOut);
TimeOne.QuadPart = TimeOut.dwHighDateTime;
TimeOne.QuadPart <<= 32;
TimeOne.QuadPart |= TimeOut.dwLowDateTime;
*/
for(int i = 0; i < m_nLimit; i += 1)
{
/*
// dCSP_TIMED_REDRAW test purpose
TimeOne.QuadPart += 5;
do
{
GetLocalTime(&TimeIn);
SystemTimeToFileTime(&TimeIn, &TimeOut);
TimeTwo.QuadPart = TimeOut.dwHighDateTime;
TimeTwo.QuadPart <<= 32;
TimeTwo.QuadPart |= TimeOut.dwLowDateTime;
}
while(TimeTwo.QuadPart < TimeOne.QuadPart);
TimeOne = TimeTwo;
*/
SkinProgress.StepIt();
#ifdef dCSP_SLIDERBAR_METHOD
// SkinProgress.SetStart(i >> 1);
#endif // dCSP_SLIDERBAR_METHOD
PeekAndPump();
}
m_poSkinProgress = NULL;
} // Here the CSkinProgress is deleted
// Use this for testing the way to make a CSkinProgress living as a pointer - CHANGE THE CSkinProgressTestView DESTRUCTOR ABOVE !!!
// if(
// (m_poSkinProgress != NULL)
// && (IsWindow(m_poSkinProgress->m_hWnd))
// )
// { // If you close the application while the bar is in progress, the objects are already deleted, so avoid to delete a deleted object
// delete m_poSkinProgress;
// m_poSkinProgress = NULL;
// }else{}
if(poBitmap != NULL)
{
delete poBitmap;
}else{}
if(IsWindow(m_cButtonTest.m_hWnd))
{ // If you close the application while the bar is in progress, the objects are already deleted, so avoid to enable a deleted object
m_cButtonTest.EnableWindow(true);
}else{}
}
void CSkinProgressTestView::OnRadioDefault()
{ // Set the Default bitmap
// CheckRadioButton(IDC_RADIO_DEFAULT, IDC_RADIO_PHOTON, IDC_RADIO_DEFAULT);
if(m_poSkinProgress != NULL)
{
m_poSkinProgress->SetBitmap(); // Default bitmap
}else{}
}
void CSkinProgressTestView::OnRadioAqua()
{ // Set the AQUA bitmap
// CheckRadioButton(IDC_RADIO_DEFAULT, IDC_RADIO_PHOTON, IDC_RADIO_AQUA);
if(m_poSkinProgress != NULL)
{
CBitmap oBitmap;
oBitmap.LoadBitmap(IDB_BMP_AQUA);
m_poSkinProgress->SetBitmap(&oBitmap);
}else{}
}
void CSkinProgressTestView::OnRadioLuna()
{ // Set the LUNA bitmap
// CheckRadioButton(IDC_RADIO_DEFAULT, IDC_RADIO_PHOTON, IDC_RADIO_LUNA);
if(m_poSkinProgress != NULL)
{
CBitmap oBitmap;
oBitmap.LoadBitmap(IDB_BMP_LUNA);
m_poSkinProgress->SetBitmap(&oBitmap);
}else{}
}
void CSkinProgressTestView::OnRadioPhoton()
{ // Set the PHOTON bitmap
// CheckRadioButton(IDC_RADIO_DEFAULT, IDC_RADIO_PHOTON, IDC_RADIO_PHOTON);
if(m_poSkinProgress != NULL)
{
CBitmap oBitmap;
oBitmap.LoadBitmap(IDB_BMP_PHOTON);
m_poSkinProgress->SetBitmap(&oBitmap);
}else{}
}
void CSkinProgressTestView::OnSize(UINT nType, int cx, int cy)
{ // On resizing
CView::OnSize(nType, cx, cy);
CWnd* pMainWnd;
CWnd* pMessageBar;
CRect rcWindow;
CRect rcPane;
CRect rcSetPane;
pMainWnd = AfxGetMainWnd();
if(pMainWnd != NULL)
{ // If the window exists
if(pMainWnd->IsKindOf(RUNTIME_CLASS(CFrameWnd)))
{ // If main window is a frame window, use normal methods
pMessageBar = ((CFrameWnd*) pMainWnd)->GetMessageBar();
// Get coordinate of the most bottom-right object
m_cBottomRight.GetWindowRect(rcWindow);
m_cPane0.GetWindowRect(rcPane);
ScreenToClient(rcWindow);
ScreenToClient(rcPane);
// Set minimal frame window size
((CMainFrame*) AfxGetMainWnd())->m_nWidth = rcWindow.right + rcWindow.Width();
((CMainFrame*) AfxGetMainWnd())->m_nHeight = rcWindow.bottom + rcWindow.Height() + rcPane.Height() + rcPane.Height() + rcPane.Height();
if(pMessageBar->IsWindowVisible())
{
// Relocate pane text 0
((CStatusBar*) pMessageBar)->GetItemRect(0, rcWindow);
rcSetPane.left = (rcWindow.left + rcWindow.right - rcPane.Width()) / 2;
rcSetPane.right = rcSetPane.left + rcPane.Width();
rcSetPane.top = cy - rcPane.Height();
rcSetPane.bottom = cy;
m_cPane0.MoveWindow(rcSetPane);
m_cPane0.ShowWindow(SW_SHOW);
// Relocate pane text 1
m_cPane1.GetWindowRect(rcPane);
ScreenToClient(rcPane);
((CStatusBar*) pMessageBar)->GetItemRect(1, rcWindow);
rcSetPane.left = (rcWindow.left + rcWindow.right - rcPane.Width()) / 2;
rcSetPane.right = rcSetPane.left + rcPane.Width();
rcSetPane.top = cy - rcPane.Height();
rcSetPane.bottom = cy;
m_cPane1.MoveWindow(rcSetPane);
m_cPane1.ShowWindow(SW_SHOW);
// Relocate pane text 2
m_cPane2.GetWindowRect(rcPane);
ScreenToClient(rcPane);
((CStatusBar*) pMessageBar)->GetItemRect(2, rcWindow);
rcSetPane.left = (rcWindow.left + rcWindow.right - rcPane.Width()) / 2;
rcSetPane.right = rcSetPane.left + rcPane.Width();
rcSetPane.top = cy - rcPane.Height();
rcSetPane.bottom = cy;
m_cPane2.MoveWindow(rcSetPane);
m_cPane2.ShowWindow(SW_SHOW);
// Relocate pane text 3
m_cPane3.GetWindowRect(rcPane);
ScreenToClient(rcPane);
((CStatusBar*) pMessageBar)->GetItemRect(3, rcWindow);
rcSetPane.left = (rcWindow.left + rcWindow.right - rcPane.Width()) / 2;
rcSetPane.right = rcSetPane.left + rcPane.Width();
rcSetPane.top = cy - rcPane.Height();
rcSetPane.bottom = cy;
m_cPane3.MoveWindow(rcSetPane);
m_cPane3.ShowWindow(SW_SHOW);
// Relocate pane text 4
m_cPane4.GetWindowRect(rcPane);
ScreenToClient(rcPane);
((CStatusBar*) pMessageBar)->GetItemRect(4, rcWindow);
rcSetPane.left = (rcWindow.left + rcWindow.right - rcPane.Width()) / 2;
rcSetPane.right = rcSetPane.left + rcPane.Width();
rcSetPane.top = cy - rcPane.Height();
rcSetPane.bottom = cy;
m_cPane4.MoveWindow(rcSetPane);
m_cPane4.ShowWindow(SW_SHOW);
}
else
{ // If status bar hidden, hide pane text
m_cPane0.ShowWindow(SW_HIDE);
m_cPane1.ShowWindow(SW_HIDE);
m_cPane2.ShowWindow(SW_HIDE);
m_cPane3.ShowWindow(SW_HIDE);
m_cPane4.ShowWindow(SW_HIDE);
}
}else{}
}else{}
}
#ifdef dCSP_DIALOG_PROGRESS
void CSkinProgressTestView::OnButtonDialog()
{
// TODO: Add your control notification handler code here
// Open the dialog
CSkinProgressTestDialog TestDialog;
TestDialog.DoModal();
}
#endif // dCSP_DIALOG_PROGRESS
void CSkinProgressTestView::OnSelchangeComboProgress()
{
// TODO: Add your control notification handler code here
if(m_poSkinProgress != NULL)
{
m_poSkinProgress->SetProgress(m_cProgress.GetCurSel() - (cSPT_EnumElements - 1));
}else{}
}