blob: 63b104b0cc644a4ac7f880598c461e825b35910c [file] [log] [blame]
Dennis Syrovatsky803e02c2005-11-06 05:35:27 +00001/* Copyright (C) 2005 TightVNC Team. All Rights Reserved.
2 *
3 * This is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation; either version 2 of the License, or
6 * (at your option) any later version.
7 *
8 * This software is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this software; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
16 * USA.
17 *
18 * TightVNC distribution homepage on the Web: http://www.tightvnc.com/
19 *
20 */
21
22// -=- FTProgress.cxx
23
24#include <vncviewer/FTProgress.h>
25
26using namespace rfb;
27using namespace rfb::win32;
28
Dennis Syrovatsky93196042005-11-07 08:09:54 +000029FTProgress::FTProgress(HWND hwndParent)
Dennis Syrovatsky803e02c2005-11-06 05:35:27 +000030{
Dennis Syrovatsky93196042005-11-07 08:09:54 +000031 m_bInitialized = false;
32 m_hwndParent = hwndParent;
Dennis Syrovatsky803e02c2005-11-06 05:35:27 +000033
Dennis Syrovatsky93196042005-11-07 08:09:54 +000034 m_pSingleProgress = NULL;
35 m_pGeneralProgress = NULL;
Dennis Syrovatsky803e02c2005-11-06 05:35:27 +000036}
37
38FTProgress::~FTProgress()
39{
Dennis Syrovatsky93196042005-11-07 08:09:54 +000040
Dennis Syrovatsky803e02c2005-11-06 05:35:27 +000041}
42
43bool
44FTProgress::initialize(DWORD64 totalMaxValue, DWORD maxValue)
45{
Dennis Syrovatsky93196042005-11-07 08:09:54 +000046 m_bInitialized = false;
47
48 m_hwndSinglePercent = GetDlgItem(m_hwndParent, IDC_FTSINGLEPERCENT);
49 m_hwndGeneralPercent = GetDlgItem(m_hwndParent, IDC_FTGENERALPERCENT);
50
51 if ((m_hwndSinglePercent == NULL) || (m_hwndGeneralPercent == NULL)) return false;
52
53 if (!createProgressBarObjects()) return false;
54
55 if (!initProgressControls(totalMaxValue, maxValue)) return false;
56
57 m_bInitialized = true;
58 return true;
Dennis Syrovatsky803e02c2005-11-06 05:35:27 +000059}
60
61void
62FTProgress::increase(DWORD value)
63{
64
65}
66
67void
68FTProgress::clear()
69{
70
Dennis Syrovatsky93196042005-11-07 08:09:54 +000071}
72
73bool
74FTProgress::createProgressBarObjects()
75{
76 if ((m_pSingleProgress != NULL) || (m_pGeneralProgress != NULL)) {
77 return false;
78 } else {
79 HWND hwndSingleProgr = GetDlgItem(m_hwndParent, IDC_FTSINGLEPROGRESS);
80 HWND hwndGeneralProgr = GetDlgItem(m_hwndParent, IDC_FTGENERALPROGRESS);
81
82 m_pSingleProgress = new ProgressControl(hwndSingleProgr);
83 if (m_pSingleProgress == NULL) return false;
84
85 m_pGeneralProgress = new ProgressControl(hwndGeneralProgr);
86 if (m_pGeneralProgress == NULL) {
87 delete m_pSingleProgress;
88 m_pSingleProgress = NULL;
89 return false;
90 }
91 }
92 return true;
93}
94
95bool
96FTProgress::destroyProgressBarObjects()
97{
98 if (m_pSingleProgress != NULL) {
99 delete m_pSingleProgress;
100 }
101
102 if (m_pGeneralProgress != NULL) {
103 delete m_pGeneralProgress;
104 }
105
106 return true;
107}
108
109bool
110FTProgress::initProgressControls(DWORD64 totalMaxValue, DWORD maxValue)
111{
112 bool bResult = true;
113
114 if ((m_pSingleProgress != NULL) && (m_pGeneralProgress != NULL)) {
115 if (!m_pSingleProgress->init(totalMaxValue, 0)) return false;
116 if (!m_pGeneralProgress->init(maxValue, 0)) return false;
117 } else {
118 return false;
119 }
120
121 setProgressText();
122 return true;
123}
124
125void
126FTProgress::setProgressText()
127{
128 char buf[16];
129
130 int percent = m_pSingleProgress->getCurrentPercent();
131 sprintf(buf, "%d%%", percent);
132 SetWindowText(m_hwndSinglePercent, buf);
133
134 percent = m_pGeneralProgress->getCurrentPercent();
135 sprintf(buf, "%d%%", percent);
136 SetWindowText(m_hwndGeneralPercent, buf);
Dennis Syrovatsky803e02c2005-11-06 05:35:27 +0000137}