Added methods to FTProgress class for creating, destroying
and intialization the progress bar controls.
git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/trunk@379 3789f03b-4d11-0410-bbf8-ca57d06f2519
diff --git a/vncviewer/FTProgress.cxx b/vncviewer/FTProgress.cxx
index 309c8cd..63b104b 100644
--- a/vncviewer/FTProgress.cxx
+++ b/vncviewer/FTProgress.cxx
@@ -26,19 +26,36 @@
using namespace rfb;
using namespace rfb::win32;
-FTProgress::FTProgress()
+FTProgress::FTProgress(HWND hwndParent)
{
+ m_bInitialized = false;
+ m_hwndParent = hwndParent;
+ m_pSingleProgress = NULL;
+ m_pGeneralProgress = NULL;
}
FTProgress::~FTProgress()
{
+
}
bool
FTProgress::initialize(DWORD64 totalMaxValue, DWORD maxValue)
{
- return false;
+ m_bInitialized = false;
+
+ m_hwndSinglePercent = GetDlgItem(m_hwndParent, IDC_FTSINGLEPERCENT);
+ m_hwndGeneralPercent = GetDlgItem(m_hwndParent, IDC_FTGENERALPERCENT);
+
+ if ((m_hwndSinglePercent == NULL) || (m_hwndGeneralPercent == NULL)) return false;
+
+ if (!createProgressBarObjects()) return false;
+
+ if (!initProgressControls(totalMaxValue, maxValue)) return false;
+
+ m_bInitialized = true;
+ return true;
}
void
@@ -51,4 +68,70 @@
FTProgress::clear()
{
+}
+
+bool
+FTProgress::createProgressBarObjects()
+{
+ if ((m_pSingleProgress != NULL) || (m_pGeneralProgress != NULL)) {
+ return false;
+ } else {
+ HWND hwndSingleProgr = GetDlgItem(m_hwndParent, IDC_FTSINGLEPROGRESS);
+ HWND hwndGeneralProgr = GetDlgItem(m_hwndParent, IDC_FTGENERALPROGRESS);
+
+ m_pSingleProgress = new ProgressControl(hwndSingleProgr);
+ if (m_pSingleProgress == NULL) return false;
+
+ m_pGeneralProgress = new ProgressControl(hwndGeneralProgr);
+ if (m_pGeneralProgress == NULL) {
+ delete m_pSingleProgress;
+ m_pSingleProgress = NULL;
+ return false;
+ }
+ }
+ return true;
+}
+
+bool
+FTProgress::destroyProgressBarObjects()
+{
+ if (m_pSingleProgress != NULL) {
+ delete m_pSingleProgress;
+ }
+
+ if (m_pGeneralProgress != NULL) {
+ delete m_pGeneralProgress;
+ }
+
+ return true;
+}
+
+bool
+FTProgress::initProgressControls(DWORD64 totalMaxValue, DWORD maxValue)
+{
+ bool bResult = true;
+
+ if ((m_pSingleProgress != NULL) && (m_pGeneralProgress != NULL)) {
+ if (!m_pSingleProgress->init(totalMaxValue, 0)) return false;
+ if (!m_pGeneralProgress->init(maxValue, 0)) return false;
+ } else {
+ return false;
+ }
+
+ setProgressText();
+ return true;
+}
+
+void
+FTProgress::setProgressText()
+{
+ char buf[16];
+
+ int percent = m_pSingleProgress->getCurrentPercent();
+ sprintf(buf, "%d%%", percent);
+ SetWindowText(m_hwndSinglePercent, buf);
+
+ percent = m_pGeneralProgress->getCurrentPercent();
+ sprintf(buf, "%d%%", percent);
+ SetWindowText(m_hwndGeneralPercent, buf);
}
\ No newline at end of file