]> cygwin.com Git - cygwin-apps/setup.git/blobdiff - threebar.cc
2003-02-16 Pavel Tsekov <ptsekov@gmx.net>
[cygwin-apps/setup.git] / threebar.cc
index d2403d309c7e90fec74de713932c241b73986c7b..100056c47e400e02b60e73e69a6e7bdf3e22ee9e 100644 (file)
-/*\r
- * Copyright (c) 2001, Gary R. Van Sickle.\r
- *\r
- *     This program is free software; you can redistribute it and/or modify\r
- *     it under the terms of the GNU General Public License as published by\r
- *     the Free Software Foundation; either version 2 of the License, or\r
- *     (at your option) any later version.\r
- *\r
- *     A copy of the GNU General Public License can be found at\r
- *     http://www.gnu.org/\r
- *\r
- * Written by Gary R. Van Sickle <g.r.vansickle@worldnet.att.net>\r
- *\r
- */\r
-\r
-// This is the implementation of the ThreeBarProgressPage class.  It is a fairly generic\r
-// progress indicator property page with three progress bars.\r
-\r
-#include "win32.h"\r
-#include "commctrl.h"\r
-#include "resource.h"\r
-\r
-#include "dialog.h"\r
-#include "site.h"\r
-\r
-#include "propsheet.h"\r
-#include "threebar.h"\r
-\r
-bool\r
-ThreeBarProgressPage::Create ()\r
-{\r
-  return PropertyPage::Create (IDD_INSTATUS);\r
-}\r
-\r
-void\r
-ThreeBarProgressPage::OnInit ()\r
-{\r
-  // Get HWNDs to the dialog controls\r
-  ins_action = GetDlgItem (IDC_INS_ACTION);\r
-  ins_pkgname = GetDlgItem (IDC_INS_PKG);\r
-  ins_filename = GetDlgItem (IDC_INS_FILE);\r
-  // Bars\r
-  ins_pprogress = GetDlgItem (IDC_INS_PPROGRESS);\r
-  ins_iprogress = GetDlgItem (IDC_INS_IPROGRESS);\r
-  ins_diskfull = GetDlgItem (IDC_INS_DISKFULL);\r
-  // Bar labels\r
-  ins_bl_package = GetDlgItem (IDC_INS_BL_PACKAGE);\r
-  ins_bl_total = GetDlgItem (IDC_INS_BL_TOTAL);\r
-  ins_bl_disk = GetDlgItem (IDC_INS_BL_DISK);\r
-}\r
-\r
-void\r
-ThreeBarProgressPage::SetText1 (const TCHAR * t)\r
-{\r
-  SetWindowText (ins_action, t);\r
-}\r
-\r
-void\r
-ThreeBarProgressPage::SetText2 (const TCHAR * t)\r
-{\r
-  SetWindowText (ins_pkgname, t);\r
-}\r
-\r
-void\r
-ThreeBarProgressPage::SetText3 (const TCHAR * t)\r
-{\r
-  SetWindowText (ins_filename, t);\r
-}\r
-\r
-void\r
-ThreeBarProgressPage::SetBar1 (long progress, long max)\r
-{\r
-  int percent = (int) (100.0 * ((double) progress) / (double) max);\r
-  SendMessage (ins_pprogress, PBM_SETPOS, (WPARAM) percent, 0);\r
-}\r
-\r
-void\r
-ThreeBarProgressPage::SetBar2 (long progress, long max)\r
-{\r
-  int percent = (int) (100.0 * ((double) progress) / (double) max);\r
-  SendMessage (ins_iprogress, PBM_SETPOS, (WPARAM) percent, 0);\r
-}\r
-\r
-void\r
-ThreeBarProgressPage::SetBar3 (long progress, long max)\r
-{\r
-  int percent = (int) (100.0 * ((double) progress) / (double) max);\r
-  SendMessage (ins_diskfull, PBM_SETPOS, (WPARAM) percent, 0);\r
-}\r
-\r
-void\r
-ThreeBarProgressPage::EnableSingleBar (bool enable)\r
-{\r
-  // Switch to/from single bar mode\r
-  ShowWindow (ins_bl_total, enable ? SW_HIDE : SW_SHOW);\r
-  ShowWindow (ins_bl_disk, enable ? SW_HIDE : SW_SHOW);\r
-  ShowWindow (ins_iprogress, enable ? SW_HIDE : SW_SHOW);\r
-  ShowWindow (ins_diskfull, enable ? SW_HIDE : SW_SHOW);\r
-}\r
-\r
-void\r
-ThreeBarProgressPage::OnActivate ()\r
-{\r
-  // Disable back and next buttons\r
-  GetOwner ()->SetButtons (0);\r
-\r
-  // Set all bars to 0\r
-  SetBar1 (0);\r
-  SetBar2 (0);\r
-  SetBar3 (0);\r
-\r
-  switch (task)\r
-    {\r
-    case WM_APP_START_SITE_INFO_DOWNLOAD:\r
-    case WM_APP_START_SETUP_INI_DOWNLOAD:\r
-      // For these tasks, show only a single progress bar.\r
-      EnableSingleBar ();\r
-      break;\r
-    default:\r
-      // Show the normal 3-bar view by default\r
-      EnableSingleBar (false);\r
-      break;\r
-    }\r
-\r
-  Window::PostMessage (task);\r
-}\r
-\r
-bool\r
-ThreeBarProgressPage::OnMessageApp (UINT uMsg, WPARAM wParam, LPARAM lParam)\r
-{\r
-  switch (uMsg)\r
-    {\r
-    case WM_APP_START_DOWNLOAD:\r
-      {\r
-       // Start the package download thread.\r
-       do_download (GetInstance (), GetHWND ());\r
-       break;\r
-      }\r
-    case WM_APP_DOWNLOAD_THREAD_COMPLETE:\r
-      {\r
-       if (lParam == IDD_S_INSTALL)\r
-         {\r
-           // Download is complete and we want to go on to the install.\r
-           Window::PostMessage (WM_APP_START_INSTALL);\r
-         }\r
-       else if (lParam != 0)\r
-         {\r
-           // Download failed for some reason, go back to site selection page\r
-           GetOwner ()->SetActivePageByID (lParam);\r
-         }\r
-       else\r
-         {\r
-           // Was a download-only, and is complete or failed.\r
-           GetOwner ()->PressButton (PSBTN_CANCEL);\r
-         }\r
-       break;\r
-      }\r
-    case WM_APP_START_INSTALL:\r
-      {\r
-       // Start the install thread.\r
-       do_install (GetInstance (), GetHWND ());\r
-       break;\r
-      }\r
-    case WM_APP_INSTALL_THREAD_COMPLETE:\r
-      {\r
-       // Re-enable and "Push" the Next button\r
-       GetOwner ()->SetButtons (PSWIZB_NEXT);\r
-       GetOwner ()->PressButton (PSBTN_NEXT);\r
-       break;\r
-      }\r
-    case WM_APP_START_SITE_INFO_DOWNLOAD:\r
-      {\r
-       do_download_site_info (GetInstance (), GetHWND ());\r
-       break;\r
-      }\r
-    case WM_APP_SITE_INFO_DOWNLOAD_COMPLETE:\r
-      {\r
-       GetOwner ()->SetActivePageByID (lParam);\r
-       break;\r
-      }\r
-    case WM_APP_START_SETUP_INI_DOWNLOAD:\r
-      {\r
-       do_ini (GetInstance (), GetHWND ());\r
-       break;\r
-      }\r
-    case WM_APP_SETUP_INI_DOWNLOAD_COMPLETE:\r
-      {\r
-       if (lParam == IDD_S_FROM_CWD)\r
-         {\r
-           // There isn't actually a dialog template named this\r
-           do_fromcwd (GetInstance (), GetHWND ());\r
-         }\r
-       else\r
-         {\r
-           GetOwner ()->SetActivePageByID (lParam);\r
-         }\r
-       break;\r
-      }\r
-    default:\r
-      {\r
-       // Not handled\r
-       return false;\r
-      }\r
-    }\r
-\r
-  return true;\r
-}\r
+/*
+ * Copyright (c) 2001, Gary R. Van Sickle.
+ *
+ *     This program is free software; you can redistribute it and/or modify
+ *     it under the terms of the GNU General Public License as published by
+ *     the Free Software Foundation; either version 2 of the License, or
+ *     (at your option) any later version.
+ *
+ *     A copy of the GNU General Public License can be found at
+ *     http://www.gnu.org/
+ *
+ * Written by Gary R. Van Sickle <g.r.vansickle@worldnet.att.net>
+ *
+ */
+
+// This is the implementation of the ThreeBarProgressPage class.  It is a fairly generic
+// progress indicator property page with three progress bars.
+
+#include "win32.h"
+#include "commctrl.h"
+#include "resource.h"
+
+#include "dialog.h"
+#include "site.h"
+
+#include "propsheet.h"
+#include "threebar.h"
+#include "cistring.h"
+
+bool ThreeBarProgressPage::Create ()
+{
+  return PropertyPage::Create (IDD_INSTATUS);
+}
+
+void
+ThreeBarProgressPage::OnInit ()
+{
+  // Get HWNDs to the dialog controls
+  ins_action = GetDlgItem (IDC_INS_ACTION);
+  ins_pkgname = GetDlgItem (IDC_INS_PKG);
+  ins_filename = GetDlgItem (IDC_INS_FILE);
+  // Bars
+  ins_pprogress = GetDlgItem (IDC_INS_PPROGRESS);
+  ins_iprogress = GetDlgItem (IDC_INS_IPROGRESS);
+  ins_diskfull = GetDlgItem (IDC_INS_DISKFULL);
+  // Bar labels
+  ins_bl_package = GetDlgItem (IDC_INS_BL_PACKAGE);
+  ins_bl_total = GetDlgItem (IDC_INS_BL_TOTAL);
+  ins_bl_disk = GetDlgItem (IDC_INS_BL_DISK);
+}
+
+void
+ThreeBarProgressPage::SetText1 (const TCHAR * t)
+{
+  ::SetWindowText (ins_action, t);
+}
+
+void
+ThreeBarProgressPage::SetText2 (const TCHAR * t)
+{
+  ::SetWindowText (ins_pkgname, t);
+}
+
+void
+ThreeBarProgressPage::SetText3 (const TCHAR * t)
+{
+  ::SetWindowText (ins_filename, t);
+}
+
+void
+ThreeBarProgressPage::SetText4 (const TCHAR * t)
+{
+  ::SetWindowText (ins_bl_package, t);
+}
+
+void
+ThreeBarProgressPage::SetBar1 (long progress, long max)
+{
+  int percent = (int) (100.0 * ((double) progress) / (double) max);
+  SendMessage (ins_pprogress, PBM_SETPOS, (WPARAM) percent, 0);
+}
+
+void
+ThreeBarProgressPage::SetBar2 (long progress, long max)
+{
+  int percent = (int) (100.0 * ((double) progress) / (double) max);
+  SendMessage (ins_iprogress, PBM_SETPOS, (WPARAM) percent, 0);
+  cistring s;
+  s.Format (IDS_CYGWIN_SETUP_WITH_PROGRESS, percent);
+  GetOwner ()->SetWindowText (s.c_str ());
+}
+
+void
+ThreeBarProgressPage::SetBar3 (long progress, long max)
+{
+  int percent = (int) (100.0 * ((double) progress) / (double) max);
+  SendMessage (ins_diskfull, PBM_SETPOS, (WPARAM) percent, 0);
+}
+
+void
+ThreeBarProgressPage::EnableSingleBar (bool enable)
+{
+  // Switch to/from single bar mode
+  ShowWindow (ins_bl_total, enable ? SW_HIDE : SW_SHOW);
+  ShowWindow (ins_bl_disk, enable ? SW_HIDE : SW_SHOW);
+  ShowWindow (ins_iprogress, enable ? SW_HIDE : SW_SHOW);
+  ShowWindow (ins_diskfull, enable ? SW_HIDE : SW_SHOW);
+}
+
+void
+ThreeBarProgressPage::OnActivate ()
+{
+  // Disable back and next buttons
+  GetOwner ()->SetButtons (0);
+
+  // Set all bars to 0
+  SetBar1 (0);
+  SetBar2 (0);
+  SetBar3 (0);
+
+  switch (task)
+    {
+    case WM_APP_START_SITE_INFO_DOWNLOAD:
+    case WM_APP_START_SETUP_INI_DOWNLOAD:
+      // For these tasks, show only a single progress bar.
+      EnableSingleBar ();
+      break;
+    default:
+      // Show the normal 3-bar view by default
+      EnableSingleBar (false);
+      break;
+    }
+
+  Window::PostMessage (task);
+}
+
+bool
+  ThreeBarProgressPage::OnMessageApp (UINT uMsg, WPARAM wParam, LPARAM lParam)
+{
+  switch (uMsg)
+    {
+    case WM_APP_START_DOWNLOAD:
+      {
+       // Start the package download thread.
+       do_download (GetInstance (), GetHWND ());
+       break;
+      }
+    case WM_APP_DOWNLOAD_THREAD_COMPLETE:
+      {
+       if (lParam == IDD_S_INSTALL)
+         {
+           // Download is complete and we want to go on to the install.
+           Window::PostMessage (WM_APP_START_INSTALL);
+         }
+       else if (lParam != 0)
+         {
+           // Download failed for some reason, go back to site selection page
+           GetOwner ()->SetActivePageByID (lParam);
+         }
+       else
+         {
+           // Was a download-only, and is complete or failed.
+           GetOwner ()->PressButton (PSBTN_CANCEL);
+         }
+       break;
+      }
+    case WM_APP_START_INSTALL:
+      {
+       // Start the install thread.
+       do_install (GetInstance (), GetHWND ());
+       break;
+      }
+    case WM_APP_INSTALL_THREAD_COMPLETE:
+      {
+       // Re-enable and "Push" the Next button
+       GetOwner ()->SetButtons (PSWIZB_NEXT);
+       GetOwner ()->PressButton (PSBTN_NEXT);
+       break;
+      }
+    case WM_APP_START_SITE_INFO_DOWNLOAD:
+      {
+       do_download_site_info (GetInstance (), GetHWND ());
+       break;
+      }
+    case WM_APP_SITE_INFO_DOWNLOAD_COMPLETE:
+      {
+       GetOwner ()->SetActivePageByID (lParam);
+       break;
+      }
+    case WM_APP_START_SETUP_INI_DOWNLOAD:
+      {
+       do_ini (GetInstance (), GetHWND ());
+       break;
+      }
+    case WM_APP_SETUP_INI_DOWNLOAD_COMPLETE:
+      {
+       if (lParam == IDD_S_FROM_CWD)
+         {
+           // There isn't actually a dialog template named this
+           do_fromcwd (GetInstance (), GetHWND ());
+         }
+       else
+         {
+           GetOwner ()->SetActivePageByID (lParam);
+         }
+       break;
+      }
+    default:
+      {
+       // Not handled
+       return false;
+      }
+    }
+
+  return true;
+}
This page took 0.031742 seconds and 5 git commands to generate.