From b7301c430e1dac12cf53d75aa90b78049c0823e4 Mon Sep 17 00:00:00 2001 From: Robert Collins Date: Thu, 3 Jan 2002 11:27:11 +0000 Subject: [PATCH] 2001-01-04 Gary R. Van Sickle * cistring.cc: Run d2u. * cistring.h: Run d2u. * desktop.cc (etc_profile): Remove "test -f ./.bashrc && . ./.bashrc" from the generated /etc/profile. Bash will source this file automatically, and having this here merely results in .bashrc being executed twice. Run d2u. * desktop.h: Run d2u. * propsheet.cc: Run d2u. (PropSheetProc): New function. Add minimize box here instead of in PropertyPage::DialogProc. (PropSheet::Create): Change to use creation callback PropSheetProc. (DLGTEMPLATEEX): Add 'hidden' Windows struct definition. * propsheet.h: Run indent, d2u. * proppage.h: Run indent, d2u. * proppage.cc: Run d2u. (PropertyPage::DialogProc): Remove minimize-box-adding functionality. Remove commented-out "PropSheet_SetWizButtons" calls. Add support for calling virtual OnMessageCmd. Add setting of fonts in WM_INITDIALOG handler. (resource.h): New include for resource IDs. * res.rc: Resize and rearrange property page dialog templates to bring them in line with "Microsoft's Backward Compatible Wizard 97" specification. Run d2u. (IDD_SITE): Add an edit control and an "Add" button in order to combine the IDD_SITE and IDD_OTHER_URL functionality onto one page. (IDD_OTHER_URL): Remove dialog template. (IDD_DLSTATUS): Remove dialog template. * site.cc: Run d2u. (SitePage::OnBack): Remove NEXT() macro invocation. (SitePage::OnActivate): New member function. (load_dialog): Remove. Functionality subsumed into SitePage::OnActivate. (save_dialog): Change to support both list and user URLs. Remove OTHER_IDX and mirror_idx logic. (SitePage::PopulateListBox): New member function. (SitePage::CheckControlsAndDisableAccordingly): New member function. (SitePage::OnMessageCmd): New override. (check_if_enable_next): Remove. (dialog_cmd): Remove. (do_download_site_info_thread): Remove calls to NEXT() macro. (SitePage::Create): Call the single-param PropertyPage::Create overload. (other_url): New static taken from other.cc. (SitePage::OnNext): Remove mirror_idx logic. (SitePage::OnInit): Remove "Other URL" entry from list box. Remove list box populating code, now handled in SitePage::PopulateListBox. (mirror_idx, NO_IDX, OTHER_IDX): Remove. (save_site_url): Fix potential buffer overflow problem. Switched to TCHAR in grossly premature preparation for multilingual support. * site.h: Run d2u. (SitePage::OnActivate): New member function. (SitePage::CheckControlsAndDisableAccordingly) New member. (SitePage::OnMessageCmd): New override. (do_download_site_info_thread): Add MessageBox call on failure to download site list. * splash.cc: Run d2u. (SplashPage::OnInit): Set the font for the title. * splash.h: Run d2u. * threebar.cc: Run d2u. * threebar.h: Run d2u. * window.h: Run d2u. (Window::IsButtonChecked): New member function declaration. (Window::OnMessageCmd): New member function. (Window::SetDlgItemFont): New member function declaration. (Window::MAXFONTS, Window::Fonts, Window::FontCounter): New data members. * window.cc: Run d2u. (Window::IsButtonChecked): New member function definition. (Window::SetDlgItemFont): New member function definition. (Window::Window): Add initialization for FontCounter. (Window::~Window): Delete any fonts we created. * geturl.cc: Run d2u. (progress): Remove the "3" field width from the "%3d" percent-complete format indicator. Causes line to not start at beginning of text box, and does little to help with "jumping", since the "bytes downloaded so far" field is variable-width anyway. Change kb/s format field to "%03.1" to 0-pad the kb/s number in the event of painfully slow connections, or temporary slowdowns in faster connections should such more-instantaneous functionality become available. * net.h: Run d2u. (NetPage::OnMessageCmd): New member function declaration. (NetPage::CheckIfEnableNext): New member function declaration. * net.cc: Run d2u. (NetPage::OnMessageCmd): New member function definition. (dialog_cmd): Remove, subsumed into NetPage::OnMessageCmd. (check_if_enable_next): Remove. (NetPage::CheckIfEnableNext): New member function, subsumes check_if_enable_next. (propsheet.h): Add include. (NetPage::Init): Add call to CheckIfEnableNext. (load_dialog): Remove call to check_if_enable_next. (NetPage::Create): Call single-template-ID-parameter overload of PropertyPage::Create instead of three-parameter one. * Makefile.in (OBJS): Remove other.o. * other.cc: Remove file. --- ChangeLog | 111 ++++++++++++++ cistring.cc | 104 ++++++------- cistring.h | 82 +++++----- desktop.cc | 2 - desktop.h | 82 +++++----- geturl.cc | 2 +- localdir.h | 88 +++++------ net.cc | 66 ++++---- net.h | 88 +++++------ other.cc | 114 -------------- proppage.cc | 38 +++-- proppage.h | 234 ++++++++++++++--------------- propsheet.cc | 57 ++++++- propsheet.h | 118 +++++++-------- res.rc | 274 ++++++++++++++++++++-------------- resource.h | 8 +- root.h | 46 +++--- site.cc | 231 +++++++++++++++++----------- site.h | 6 + source.h | 86 +++++------ splash.cc | 3 + splash.h | 76 +++++----- threebar.cc | 414 +++++++++++++++++++++++++-------------------------- threebar.h | 162 ++++++++++---------- window.cc | 55 +++++++ window.h | 15 ++ 26 files changed, 1405 insertions(+), 1157 deletions(-) delete mode 100644 other.cc diff --git a/ChangeLog b/ChangeLog index bbd608b6..5945c9ed 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,114 @@ +2001-01-04 Gary R. Van Sickle + + * cistring.cc: Run d2u. + * cistring.h: Run d2u. + + * desktop.cc (etc_profile): Remove "test -f ./.bashrc && . ./.bashrc" + from the generated /etc/profile. Bash will source this file + automatically, and having this here merely results in .bashrc being + executed twice. Run d2u. + * desktop.h: Run d2u. + + * propsheet.cc: Run d2u. + (PropSheetProc): New function. Add minimize box here instead of in + PropertyPage::DialogProc. + (PropSheet::Create): Change to use creation callback PropSheetProc. + (DLGTEMPLATEEX): Add 'hidden' Windows struct definition. + + * propsheet.h: Run indent, d2u. + * proppage.h: Run indent, d2u. + + * proppage.cc: Run d2u. + (PropertyPage::DialogProc): Remove minimize-box-adding + functionality. Remove commented-out "PropSheet_SetWizButtons" calls. + Add support for calling virtual OnMessageCmd. Add setting of fonts in + WM_INITDIALOG handler. + (resource.h): New include for resource IDs. + + * res.rc: Resize and rearrange property page dialog templates + to bring them in line with "Microsoft's Backward Compatible Wizard 97" + specification. Run d2u. + (IDD_SITE): Add an edit control and an "Add" button in order to + combine the IDD_SITE and IDD_OTHER_URL functionality onto one page. + (IDD_OTHER_URL): Remove dialog template. + (IDD_DLSTATUS): Remove dialog template. + + * site.cc: Run d2u. + (SitePage::OnBack): Remove NEXT() macro invocation. + (SitePage::OnActivate): New member function. + (load_dialog): Remove. Functionality subsumed into + SitePage::OnActivate. + (save_dialog): Change to support both list and user URLs. Remove + OTHER_IDX and mirror_idx logic. + (SitePage::PopulateListBox): New member function. + (SitePage::CheckControlsAndDisableAccordingly): New member function. + (SitePage::OnMessageCmd): New override. + (check_if_enable_next): Remove. + (dialog_cmd): Remove. + (do_download_site_info_thread): Remove calls to NEXT() macro. + (SitePage::Create): Call the single-param PropertyPage::Create + overload. + (other_url): New static taken from other.cc. + (SitePage::OnNext): Remove mirror_idx logic. + (SitePage::OnInit): Remove "Other URL" entry from list box. Remove + list box populating code, now handled in SitePage::PopulateListBox. + (mirror_idx, NO_IDX, OTHER_IDX): Remove. + (save_site_url): Fix potential buffer overflow problem. Switched to + TCHAR in grossly premature preparation for multilingual support. + * site.h: Run d2u. + (SitePage::OnActivate): New member function. + (SitePage::CheckControlsAndDisableAccordingly) New member. + (SitePage::OnMessageCmd): New override. + (do_download_site_info_thread): Add MessageBox call on failure to + download site list. + + * splash.cc: Run d2u. + (SplashPage::OnInit): Set the font for the title. + * splash.h: Run d2u. + + * threebar.cc: Run d2u. + * threebar.h: Run d2u. + + * window.h: Run d2u. + (Window::IsButtonChecked): New member function declaration. + (Window::OnMessageCmd): New member function. + (Window::SetDlgItemFont): New member function declaration. + (Window::MAXFONTS, Window::Fonts, Window::FontCounter): New data + members. + * window.cc: Run d2u. + (Window::IsButtonChecked): New member function definition. + (Window::SetDlgItemFont): New member function definition. + (Window::Window): Add initialization for FontCounter. + (Window::~Window): Delete any fonts we created. + + * geturl.cc: Run d2u. + (progress): Remove the "3" field width from the "%3d" + percent-complete format indicator. Causes line to not start at + beginning of text box, and does little to help with "jumping", since + the "bytes downloaded so far" field is variable-width anyway. Change + kb/s format field to "%03.1" to 0-pad the kb/s number in the event of + painfully slow connections, or temporary slowdowns in faster + connections should such more-instantaneous functionality become + available. + + * net.h: Run d2u. + (NetPage::OnMessageCmd): New member function declaration. + (NetPage::CheckIfEnableNext): New member function declaration. + * net.cc: Run d2u. + (NetPage::OnMessageCmd): New member function definition. + (dialog_cmd): Remove, subsumed into NetPage::OnMessageCmd. + (check_if_enable_next): Remove. + (NetPage::CheckIfEnableNext): New member function, subsumes + check_if_enable_next. + (propsheet.h): Add include. + (NetPage::Init): Add call to CheckIfEnableNext. + (load_dialog): Remove call to check_if_enable_next. + (NetPage::Create): Call single-template-ID-parameter overload of + PropertyPage::Create instead of three-parameter one. + + * Makefile.in (OBJS): Remove other.o. + * other.cc: Remove file. + 2002-01-01 Robert Collins * README: Update TODO's. diff --git a/cistring.cc b/cistring.cc index de824782..0ce78583 100644 --- a/cistring.cc +++ b/cistring.cc @@ -1,52 +1,52 @@ -/* - * 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 - * - */ - -// Yep, another string class - -#include "cistring.h" -#include - -DWORD -cistring::Format (UINT i, ...) -{ - TCHAR FormatStringBuffer[256]; - TCHAR *Buff; - va_list arglist; - DWORD numchars; - - // Get the string from the stringtable (FormatMessage() can only work with - // literal strings or *message*table entries, which are different for some - // inexplicable reason). - LoadString (GetModuleHandle (NULL), i, FormatStringBuffer, 256); - - va_start (arglist, i); - numchars =:: - FormatMessage (FORMAT_MESSAGE_ALLOCATE_BUFFER | - FORMAT_MESSAGE_FROM_STRING, FormatStringBuffer, i, 0, - (LPTSTR) & Buff, 0, &arglist); - va_end (arglist); - - if (numchars == 0) - { - // Something went wrong. - return 0; - } - - buffer = new TCHAR[(numchars + 1) * sizeof (TCHAR)]; - memcpy (buffer, Buff, (numchars + 1) * sizeof (TCHAR)); - LocalFree (Buff); - - return numchars; -} +/* + * 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 + * + */ + +// Yep, another string class + +#include "cistring.h" +#include + +DWORD +cistring::Format (UINT i, ...) +{ + TCHAR FormatStringBuffer[256]; + TCHAR *Buff; + va_list arglist; + DWORD numchars; + + // Get the string from the stringtable (FormatMessage() can only work with + // literal strings or *message*table entries, which are different for some + // inexplicable reason). + LoadString (GetModuleHandle (NULL), i, FormatStringBuffer, 256); + + va_start (arglist, i); + numchars =:: + FormatMessage (FORMAT_MESSAGE_ALLOCATE_BUFFER | + FORMAT_MESSAGE_FROM_STRING, FormatStringBuffer, i, 0, + (LPTSTR) & Buff, 0, &arglist); + va_end (arglist); + + if (numchars == 0) + { + // Something went wrong. + return 0; + } + + buffer = new TCHAR[(numchars + 1) * sizeof (TCHAR)]; + memcpy (buffer, Buff, (numchars + 1) * sizeof (TCHAR)); + LocalFree (Buff); + + return numchars; +} diff --git a/cistring.h b/cistring.h index 2873e28d..72ca49b5 100644 --- a/cistring.h +++ b/cistring.h @@ -1,41 +1,41 @@ -/* - * 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 - * - */ - -// Yep, another string class - -#include - -class cistring -{ - TCHAR *buffer; -public: - cistring () - { - buffer = NULL; - }; - cistring (const TCHAR * s); - ~cistring () - { - if (buffer != NULL) - delete[]buffer; - }; - - const TCHAR *c_str () - { - return buffer; - }; - - DWORD Format (UINT i, ...); -}; +/* + * 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 + * + */ + +// Yep, another string class + +#include + +class cistring +{ + TCHAR *buffer; +public: + cistring () + { + buffer = NULL; + }; + cistring (const TCHAR * s); + ~cistring () + { + if (buffer != NULL) + delete[]buffer; + }; + + const TCHAR *c_str () + { + return buffer; + }; + + DWORD Format (UINT i, ...); +}; diff --git a/desktop.cc b/desktop.cc index 37d95a3b..89051267 100644 --- a/desktop.cc +++ b/desktop.cc @@ -88,8 +88,6 @@ static const char *etc_profile[] = { "$ '", "", "cd \"$HOME\"", - "", - "test -f ./.bashrc && . ./.bashrc", 0 }; diff --git a/desktop.h b/desktop.h index 8c14a1d6..b6dda19c 100644 --- a/desktop.h +++ b/desktop.h @@ -1,41 +1,41 @@ -#ifndef CINSTALL_DESKTOP_H -#define CINSTALL_DESKTOP_H - -/* - * 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 - * - */ - -// This is the header for the DesktopSetupPage class. Allows selection -// of "create desktop icon" and "add to start menu". - -#include "proppage.h" - -class DesktopSetupPage:public PropertyPage -{ -public: - DesktopSetupPage () - { - }; - virtual ~ DesktopSetupPage () - { - }; - - bool Create (); - - virtual void OnInit (); - virtual bool OnFinish (); - virtual long OnBack (); -}; - -#endif // CINSTALL_DESKTOP_H +#ifndef CINSTALL_DESKTOP_H +#define CINSTALL_DESKTOP_H + +/* + * 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 + * + */ + +// This is the header for the DesktopSetupPage class. Allows selection +// of "create desktop icon" and "add to start menu". + +#include "proppage.h" + +class DesktopSetupPage:public PropertyPage +{ +public: + DesktopSetupPage () + { + }; + virtual ~ DesktopSetupPage () + { + }; + + bool Create (); + + virtual void OnInit (); + virtual bool OnFinish (); + virtual long OnBack (); +}; + +#endif // CINSTALL_DESKTOP_H diff --git a/geturl.cc b/geturl.cc index 4fd44c25..d6ef257e 100644 --- a/geturl.cc +++ b/geturl.cc @@ -94,7 +94,7 @@ progress (int bytes) { int perc = (int)(100.0 * ((double)bytes) / (double)max_bytes); Progress.SetBar1(bytes, max_bytes); - sprintf (buf, "%3d %% (%dk/%dk) %2.1f kb/s\n", + sprintf (buf, "%d %% (%dk/%dk) %03.1f kb/s\n", perc, bytes / 1000, max_bytes / 1000, kbps); if (total_download_bytes > 0) { diff --git a/localdir.h b/localdir.h index af0adccd..5795f201 100644 --- a/localdir.h +++ b/localdir.h @@ -1,44 +1,44 @@ -#ifndef CINSTALL_LOCALDIR_H -#define CINSTALL_LOCALDIR_H - -/* - * 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 - * - */ - -// This is the header for the LocalDirPage class. Allows the user to select -// the local package directory (i.e. where downloaded packages are stored). - - -#include "proppage.h" - -class LocalDirPage:public PropertyPage -{ -public: - LocalDirPage () - { - }; - virtual ~ LocalDirPage () - { - }; - - bool Create (); - - virtual void OnActivate (); - virtual void OnInit (); - virtual long OnNext (); - virtual long OnBack (); -}; - - -#endif +#ifndef CINSTALL_LOCALDIR_H +#define CINSTALL_LOCALDIR_H + +/* + * 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 + * + */ + +// This is the header for the LocalDirPage class. Allows the user to select +// the local package directory (i.e. where downloaded packages are stored). + + +#include "proppage.h" + +class LocalDirPage:public PropertyPage +{ +public: + LocalDirPage () + { + }; + virtual ~ LocalDirPage () + { + }; + + bool Create (); + + virtual void OnActivate (); + virtual void OnInit (); + virtual long OnNext (); + virtual long OnBack (); +}; + + +#endif diff --git a/net.cc b/net.cc index a47d438d..96aaa877 100644 --- a/net.cc +++ b/net.cc @@ -31,16 +31,18 @@ static const char *cvsid = #include "log.h" #include "net.h" - +#include "propsheet.h" #include "threebar.h" extern ThreeBarProgressPage Progress; static int rb[] = { IDC_NET_IE5, IDC_NET_DIRECT, IDC_NET_PROXY, 0 }; -static void -check_if_enable_next (HWND h) +void +NetPage::CheckIfEnableNext () { int e = 0, p = 0, pu = 0; + DWORD ButtonFlags = PSWIZB_BACK; + if (net_method == IDC_NET_IE5) pu = 1; if (net_method == IDC_NET_IE5 || net_method == IDC_NET_DIRECT) @@ -51,9 +53,16 @@ check_if_enable_next (HWND h) if (net_proxy_host && net_proxy_port) e = 1; } - EnableWindow (GetDlgItem (h, IDOK), e); - EnableWindow (GetDlgItem (h, IDC_PROXY_HOST), p); - EnableWindow (GetDlgItem (h, IDC_PROXY_PORT), p); + if (e) + { + // There's something in the proxy and port boxes, enable "Next". + ButtonFlags |= PSWIZB_NEXT; + } + + GetOwner ()->SetButtons (ButtonFlags); + + EnableWindow (GetDlgItem (IDC_PROXY_HOST), p); + EnableWindow (GetDlgItem (IDC_PROXY_PORT), p); } static void @@ -64,7 +73,6 @@ load_dialog (HWND h) if (net_proxy_port == 0) net_proxy_port = 80; eset (h, IDC_PROXY_PORT, net_proxy_port); - check_if_enable_next (h); } static void @@ -75,28 +83,10 @@ save_dialog (HWND h) net_proxy_port = eget (h, IDC_PROXY_PORT); } -static BOOL -dialog_cmd (HWND h, int id, HWND hwndctl, UINT code) -{ - switch (id) - { - - case IDC_NET_IE5: - case IDC_NET_DIRECT: - case IDC_NET_PROXY: - case IDC_PROXY_HOST: - case IDC_PROXY_PORT: - save_dialog (h); - check_if_enable_next (h); - break; - } - return 0; -} - bool NetPage::Create () { - return PropertyPage::Create (NULL, dialog_cmd, IDD_NET); + return PropertyPage::Create (IDD_NET); } void @@ -106,6 +96,7 @@ NetPage::OnInit () net_method = IDC_NET_DIRECT; load_dialog (h); + CheckIfEnableNext(); // Check to see if any radio buttons are selected. If not, select a default. if ((!SendMessage (GetDlgItem (IDC_NET_IE5), BM_GETCHECK, 0, 0) == @@ -136,3 +127,26 @@ NetPage::OnBack () save_dialog (GetHWND ()); return 0; } + +bool +NetPage::OnMessageCmd (int id, HWND hwndctl, UINT code) +{ + switch (id) + { + case IDC_NET_IE5: + case IDC_NET_DIRECT: + case IDC_NET_PROXY: + case IDC_PROXY_HOST: + case IDC_PROXY_PORT: + save_dialog (GetHWND()); + CheckIfEnableNext (); + break; + + default: + // Wasn't recognized or handled. + return false; + } + + // Was handled since we never got to default above. + return true; +} diff --git a/net.h b/net.h index c08c7855..2928330a 100644 --- a/net.h +++ b/net.h @@ -1,42 +1,46 @@ -#ifndef CINSTALL_NET_H -#define CINSTALL_NET_H - -/* - * 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 - * - */ - -// This is the header for the NetPage class. It allows the user to select -// a proxy etc. - - -#include "proppage.h" - -class NetPage:public PropertyPage -{ -public: - NetPage () - { - }; - virtual ~ NetPage () - { - }; - - bool Create (); - - virtual void OnInit (); - virtual long OnNext (); - virtual long OnBack (); -}; - -#endif // CINSTALL_NET_H +#ifndef CINSTALL_NET_H +#define CINSTALL_NET_H + +/* + * 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 + * + */ + +// This is the header for the NetPage class. It allows the user to select +// a proxy etc. + + +#include "proppage.h" + +class NetPage:public PropertyPage +{ + void CheckIfEnableNext (); + +public: + NetPage () + { + }; + virtual ~ NetPage () + { + }; + + bool Create (); + + virtual void OnInit (); + virtual long OnNext (); + virtual long OnBack (); + + virtual bool OnMessageCmd (int id, HWND hwndctl, UINT code); +}; + +#endif // CINSTALL_NET_H diff --git a/other.cc b/other.cc deleted file mode 100644 index 686a3df1..00000000 --- a/other.cc +++ /dev/null @@ -1,114 +0,0 @@ -/* - * Copyright (c) 2000, Red Hat, Inc. - * - * 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 DJ Delorie - * - */ - -/* This handles the "other URL" option from the mirror site - selection. */ - -#if 0 -static const char *cvsid = - "\n%%% $Id$\n"; -#endif - -#include "win32.h" -#include -#include -#include -#include "dialog.h" -#include "resource.h" -#include "state.h" -#include "msg.h" -#include "log.h" -#include "site.h" - -static char * other_url = 0; - -static void -check_if_enable_next (HWND h) -{ - EnableWindow (GetDlgItem (h, IDOK), other_url ? 1 : 0); -} - -static void -load_dialog (HWND h) -{ - eset (h, IDC_OTHER_URL, other_url); - check_if_enable_next (h); -} - -static void -save_dialog (HWND h) -{ - other_url = eget (h, IDC_OTHER_URL, other_url); - site_list_type *newsite = new site_list_type (other_url); - site_list_type &listobj = all_site_list.registerbyobject (*newsite); - if (&listobj != newsite) - /* That site was already registered */ - delete newsite; - site_list.registerbyobject (listobj); -} - -static BOOL -dialog_cmd (HWND h, int id, HWND hwndctl, UINT code) -{ - switch (id) - { - - case IDC_OTHER_URL: - other_url = eget (h, IDC_OTHER_URL, other_url); - check_if_enable_next (h); - break; - - case IDOK: - save_dialog (h); - save_site_url (); - NEXT (IDD_S_LOAD_INI); - break; - - case IDC_BACK: - save_dialog (h); - NEXT (IDD_SITE); - break; - - case IDCANCEL: - NEXT (0); - break; - } - return 0; -} - -static BOOL CALLBACK -dialog_proc (HWND h, UINT message, WPARAM wParam, LPARAM lParam) -{ - switch (message) - { - case WM_INITDIALOG: - load_dialog (h); - return FALSE; - case WM_COMMAND: - return HANDLE_WM_COMMAND (h, wParam, lParam, dialog_cmd); - } - return FALSE; -} - -void -do_other (HINSTANCE h, HWND owner) -{ - int rv = 0; - rv = DialogBox (h, MAKEINTRESOURCE (IDD_OTHER_URL), owner, dialog_proc); - if (rv == -1) - fatal (owner, IDS_DIALOG_FAILED); - - log (0, "site: %s", other_url); -} diff --git a/proppage.cc b/proppage.cc index db18137d..c9d98433 100644 --- a/proppage.cc +++ b/proppage.cc @@ -19,6 +19,7 @@ #include "proppage.h" #include "propsheet.h" #include "win32.h" +#include "resource.h" bool PropertyPage::DoOnceForSheet = true; @@ -111,6 +112,11 @@ PropertyPage::DialogProc (UINT message, WPARAM wParam, LPARAM lParam) case WM_INITDIALOG: { OnInit (); + + // Set header title font of each internal page to MS Sans Serif, Bold, 8 Pt. + // This will just silently fail on the first and last pages. + SetDlgItemFont(IDC_STATIC_HEADER_TITLE, "MS Sans Serif", 8, FW_BOLD); + // TRUE = Set focus to default control (in wParam). return TRUE; break; @@ -130,13 +136,6 @@ PropertyPage::DialogProc (UINT message, WPARAM wParam, LPARAM lParam) GetOwner ()->SetHWNDFromPage (((NMHDR FAR *) lParam)-> hwndFrom); GetOwner ()->CenterWindow (); - // Add a minimize box to the parent property sheet. We do this here - // instead of in the sheet class mainly because it will work with either - // modal or modeless sheets. - LONG style =::GetWindowLong (((NMHDR FAR *) lParam)->hwndFrom, - GWL_STYLE); - ::SetWindowLong (((NMHDR FAR *) lParam)->hwndFrom, GWL_STYLE, - style | WS_MINIMIZEBOX); DoOnceForSheet = false; } @@ -145,19 +144,16 @@ PropertyPage::DialogProc (UINT message, WPARAM wParam, LPARAM lParam) { // Disable "Back" on first page. GetOwner ()->SetButtons (PSWIZB_NEXT); - //::PropSheet_SetWizButtons(((NMHDR FAR *) lParam)->hwndFrom, PSWIZB_NEXT); } else if (IsLast) { // Disable "Next", enable "Finish" on last page GetOwner ()->SetButtons (PSWIZB_BACK | PSWIZB_FINISH); - //::PropSheet_SetWizButtons(((NMHDR FAR *) lParam)->hwndFrom, PSWIZB_BACK | PSWIZB_FINISH); } else { // Middle page, enable both "Next" and "Back" buttons GetOwner ()->SetButtons (PSWIZB_BACK | PSWIZB_NEXT); - //::PropSheet_SetWizButtons(((NMHDR FAR *) lParam)->hwndFrom, PSWIZB_BACK | PSWIZB_NEXT); } OnActivate (); @@ -202,11 +198,23 @@ PropertyPage::DialogProc (UINT message, WPARAM wParam, LPARAM lParam) } break; case WM_COMMAND: - if (cmdproc != NULL) - { - return HANDLE_WM_COMMAND (GetHWND (), wParam, lParam, cmdproc); - } - break; + { + bool retval; + + retval = + OnMessageCmd (LOWORD (wParam), (HWND) lParam, HIWORD (wParam)); + if (retval == true) + { + // Handled, return 0 + SetWindowLong (GetHWND (), DWL_MSGRESULT, 0); + return TRUE; + } + else if (cmdproc != NULL) + { + return HANDLE_WM_COMMAND (GetHWND (), wParam, lParam, cmdproc); + } + break; + } default: break; } diff --git a/proppage.h b/proppage.h index ce94ce11..29f3b151 100644 --- a/proppage.h +++ b/proppage.h @@ -1,117 +1,117 @@ -#ifndef CINSTALL_PROPPAGE_H -#define CINSTALL_PROPPAGE_H - -/* - * 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 - * - */ - -// This is the header for the PropertyPage class. It works closely with the -// PropSheet class to implement a single page of the property sheet. - - -#include -#include - -#include "window.h" - -class PropSheet; - -class PropertyPage:public Window -{ - static bool DoOnceForSheet; - PROPSHEETPAGE psp; - DLGPROC proc; - BOOL (*cmdproc) (HWND h, int id, HWND hwndctl, UINT code); - - // The sheet that owns this page. - PropSheet *OurSheet; - - // For setting the back/finish buttons properly. - bool IsFirst, IsLast; - - static BOOL CALLBACK FirstDialogProcReflector (HWND hwnd, UINT message, - WPARAM wParam, - LPARAM lParam); - static BOOL CALLBACK DialogProcReflector (HWND hwnd, UINT message, - WPARAM wParam, LPARAM lParam); - -protected: - virtual BOOL CALLBACK DialogProc (UINT message, WPARAM wParam, - LPARAM lParam); - -public: - PropertyPage (); - virtual ~ PropertyPage (); - - PROPSHEETPAGE *GetPROPSHEETPAGEPtr () - { - return &psp; - }; - - // FIXME: These should be private and friended to PropSheet. - void YouAreBeingAddedToASheet (PropSheet * ps) - { - OurSheet = ps; - }; - void YouAreFirst () - { - IsFirst = true; - IsLast = false; - }; - void YouAreLast () - { - IsFirst = false; - IsLast = true; - }; - void YouAreMiddle () - { - IsFirst = false; - IsLast = false; - }; - - virtual bool Create (int TemplateID); - virtual bool Create (DLGPROC dlgproc, int TemplateID); - virtual bool Create (DLGPROC dlgproc, - BOOL (*cmdproc) (HWND h, int id, HWND hwndctl, - UINT code), int TemplateID); - - virtual void OnInit () - { - }; - virtual void OnActivate () - { - }; - virtual void OnDeactivate () - { - }; - virtual long OnNext () - { - return 0; - }; - virtual long OnBack () - { - return 0; - }; - virtual bool OnFinish () - { - return true; - }; - - PropSheet *GetOwner () const - { - return OurSheet; - }; -}; - -#endif // CINSTALL_PROPPAGE_H +#ifndef CINSTALL_PROPPAGE_H +#define CINSTALL_PROPPAGE_H + +/* + * 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 + * + */ + +// This is the header for the PropertyPage class. It works closely with the +// PropSheet class to implement a single page of the property sheet. + + +#include +#include + +#include "window.h" + +class PropSheet; + +class PropertyPage:public Window +{ + static bool DoOnceForSheet; + PROPSHEETPAGE psp; + DLGPROC proc; + BOOL (*cmdproc) (HWND h, int id, HWND hwndctl, UINT code); + + // The sheet that owns this page. + PropSheet *OurSheet; + + // For setting the back/finish buttons properly. + bool IsFirst, IsLast; + + static BOOL CALLBACK FirstDialogProcReflector (HWND hwnd, UINT message, + WPARAM wParam, + LPARAM lParam); + static BOOL CALLBACK DialogProcReflector (HWND hwnd, UINT message, + WPARAM wParam, LPARAM lParam); + +protected: + virtual BOOL CALLBACK DialogProc (UINT message, WPARAM wParam, + LPARAM lParam); + +public: + PropertyPage (); + virtual ~ PropertyPage (); + + PROPSHEETPAGE *GetPROPSHEETPAGEPtr () + { + return &psp; + }; + + // FIXME: These should be private and friended to PropSheet. + void YouAreBeingAddedToASheet (PropSheet * ps) + { + OurSheet = ps; + }; + void YouAreFirst () + { + IsFirst = true; + IsLast = false; + }; + void YouAreLast () + { + IsFirst = false; + IsLast = true; + }; + void YouAreMiddle () + { + IsFirst = false; + IsLast = false; + }; + + virtual bool Create (int TemplateID); + virtual bool Create (DLGPROC dlgproc, int TemplateID); + virtual bool Create (DLGPROC dlgproc, + BOOL (*cmdproc) (HWND h, int id, HWND hwndctl, + UINT code), int TemplateID); + + virtual void OnInit () + { + }; + virtual void OnActivate () + { + }; + virtual void OnDeactivate () + { + }; + virtual long OnNext () + { + return 0; + }; + virtual long OnBack () + { + return 0; + }; + virtual bool OnFinish () + { + return true; + }; + + PropSheet *GetOwner () const + { + return OurSheet; + }; +}; + +#endif // CINSTALL_PROPPAGE_H diff --git a/propsheet.cc b/propsheet.cc index ca5da958..91b58c0d 100644 --- a/propsheet.cc +++ b/propsheet.cc @@ -35,7 +35,23 @@ DLLVERSIONINFO; typedef HRESULT CALLBACK (*DLLGETVERSIONPROC) (DLLVERSIONINFO * pdvi); #define PROPSHEETHEADER_V1_SIZE 40 - +// Sort of a "hidden" Windows structure. Used in the PropSheetCallback. +#include +typedef struct DLGTEMPLATEEX +{ + WORD dlgVer; + WORD signature; + DWORD helpID; + DWORD exStyle; + DWORD style; + WORD cDlgItems; + short x; + short y; + short cx; + short cy; +} +DLGTEMPLATEEX, *LPDLGTEMPLATEEX; +#include PropSheet::PropSheet () { @@ -83,6 +99,28 @@ PropSheet::CreatePages () return retarray; } +static int CALLBACK +PropSheetProc (HWND hwndDlg, UINT uMsg, LPARAM lParam) +{ + switch (uMsg) + { + case PSCB_PRECREATE: + { + // Add a minimize box to the sheet/wizard. + if (((LPDLGTEMPLATEEX) lParam)->signature == 0xFFFF) + { + ((LPDLGTEMPLATEEX) lParam)->style |= WS_MINIMIZEBOX; + } + else + { + ((LPDLGTEMPLATE) lParam)->style |= WS_MINIMIZEBOX; + } + } + return TRUE; + } + return TRUE; +} + static DWORD GetPROPSHEETHEADERSize () { @@ -126,15 +164,16 @@ GetPROPSHEETHEADERSize () return retval; } -bool PropSheet::Create (const Window * Parent, DWORD Style) +bool +PropSheet::Create (const Window * Parent, DWORD Style) { - PROPSHEETHEADER - p; + PROPSHEETHEADER p; PageHandles = CreatePages (); p.dwSize = GetPROPSHEETHEADERSize (); - p.dwFlags = PSH_NOAPPLYNOW | PSH_WIZARD /*| PSH_MODELESS */ ; + p.dwFlags = + PSH_NOAPPLYNOW | PSH_WIZARD | PSH_USECALLBACK /*| PSH_MODELESS */ ; if (Parent != NULL) { p.hwndParent = Parent->GetHWND (); @@ -147,7 +186,7 @@ bool PropSheet::Create (const Window * Parent, DWORD Style) p.nPages = NumPropPages; p.nStartPage = 0; p.phpage = PageHandles; - p.pfnCallback = NULL; + p.pfnCallback = PropSheetProc; PropertySheet (&p); @@ -188,13 +227,15 @@ PropSheet::AddPage (PropertyPage * p) NumPropPages++; } -bool PropSheet::SetActivePage (int i) +bool +PropSheet::SetActivePage (int i) { // Posts a message to the message queue, so this won't block return static_cast < bool > (::PropSheet_SetCurSel (GetHWND (), NULL, i)); } -bool PropSheet::SetActivePageByID (int resource_id) +bool +PropSheet::SetActivePageByID (int resource_id) { // Posts a message to the message queue, so this won't block return static_cast < bool > diff --git a/propsheet.h b/propsheet.h index 044a5cc8..d97ba053 100644 --- a/propsheet.h +++ b/propsheet.h @@ -1,59 +1,59 @@ -#ifndef CINSTALL_PROPSHEET_H -#define CINSTALL_PROPSHEET_H - -/* - * 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 - * - */ - -// This is the header for the PropSheet class. This class encapsulates -// a Windows property sheet / wizard and interfaces with the PropertyPage class. -// It's named PropSheet instead of PropertySheet because the latter conflicts with -// the Windows function of the same name. - - -#include -#include - -#include "window.h" - -class PropertyPage; - -class PropSheet:public Window -{ - PropertyPage *PropertyPages[MAXPROPPAGES]; - int NumPropPages; - - HPROPSHEETPAGE *PageHandles; - HPROPSHEETPAGE *CreatePages (); - -public: - PropSheet (); - virtual ~ PropSheet (); - - // Should be private and friended to PropertyPage - void SetHWNDFromPage (HWND h); - - virtual bool Create (const Window * Parent = NULL, - DWORD Style = - WS_OVERLAPPEDWINDOW | WS_VISIBLE | WS_CLIPCHILDREN); - - void AddPage (PropertyPage * p); - - bool SetActivePage (int i); - bool SetActivePageByID (int resource_id); - void SetButtons (DWORD flags); - void PressButton (int button); -}; - -#endif // CINSTALL_PROPSHEET_H +#ifndef CINSTALL_PROPSHEET_H +#define CINSTALL_PROPSHEET_H + +/* + * 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 + * + */ + +// This is the header for the PropSheet class. This class encapsulates +// a Windows property sheet / wizard and interfaces with the PropertyPage class. +// It's named PropSheet instead of PropertySheet because the latter conflicts with +// the Windows function of the same name. + + +#include +#include + +#include "window.h" + +class PropertyPage; + +class PropSheet:public Window +{ + PropertyPage *PropertyPages[MAXPROPPAGES]; + int NumPropPages; + + HPROPSHEETPAGE *PageHandles; + HPROPSHEETPAGE *CreatePages (); + +public: + PropSheet (); + virtual ~ PropSheet (); + + // Should be private and friended to PropertyPage + void SetHWNDFromPage (HWND h); + + virtual bool Create (const Window * Parent = NULL, + DWORD Style = + WS_OVERLAPPEDWINDOW | WS_VISIBLE | WS_CLIPCHILDREN); + + void AddPage (PropertyPage * p); + + bool SetActivePage (int i); + bool SetActivePageByID (int resource_id); + void SetButtons (DWORD flags); + void PressButton (int button); +}; + +#endif // CINSTALL_PROPSHEET_H diff --git a/res.rc b/res.rc index 8ce141e2..5844c28a 100644 --- a/res.rc +++ b/res.rc @@ -28,139 +28,149 @@ LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US // Dialog // -IDD_SOURCE DIALOG DISCARDABLE 0, 0, 215, 95 +IDD_SOURCE DIALOG DISCARDABLE 0, 0, 317, 179 STYLE DS_MODALFRAME | DS_CENTER | WS_CHILD | WS_CAPTION | WS_SYSMENU CAPTION "Cygwin Setup" FONT 8, "MS Sans Serif" BEGIN - ICON IDI_CYGWIN,-1,5,5,20,20 CONTROL "&Install from Internet",IDC_SOURCE_NETINST,"Button", - BS_AUTORADIOBUTTON,55,15,75,10 + BS_AUTORADIOBUTTON | WS_GROUP | WS_TABSTOP,101,69,115,10 CONTROL "&Download from Internet",IDC_SOURCE_DOWNLOAD,"Button", - BS_AUTORADIOBUTTON,55,30,89,10 + BS_AUTORADIOBUTTON | WS_TABSTOP,101,84,115,10 CONTROL "Install from &Local Directory",IDC_SOURCE_CWD,"Button", - BS_AUTORADIOBUTTON,55,45,99,10 + BS_AUTORADIOBUTTON | WS_TABSTOP,101,99,115,10 + ICON IDI_CYGWIN,IDC_STATIC,290,0,21,20 + CONTROL "",IDC_STATIC,"Static",SS_BLACKFRAME | SS_SUNKEN,0,28, + 317,1 + LTEXT "Choose A Download Source",IDC_STATIC_HEADER_TITLE,7,0, + 131,8,NOT WS_GROUP + LTEXT "Choose whether to install or download from the internet, or install from files in a local directory.", + IDC_STATIC,21,9,239,16,NOT WS_GROUP END -IDD_LOCAL_DIR DIALOG DISCARDABLE 0, 0, 227, 94 +IDD_LOCAL_DIR DIALOG DISCARDABLE 0, 0, 317, 179 STYLE DS_MODALFRAME | DS_CENTER | WS_CHILD | WS_CAPTION | WS_SYSMENU CAPTION "Cygwin Setup" FONT 8, "MS Sans Serif" BEGIN - ICON IDI_CYGWIN,IDC_STATIC,5,5,20,20 - PUSHBUTTON "B&rowse...",IDC_LOCAL_DIR_BROWSE,185,30,34,14 - LTEXT "Local Package &Directory",IDC_STATIC,55,15,85,11 - EDITTEXT IDC_LOCAL_DIR,55,30,127,15,ES_AUTOHSCROLL -END - -IDD_ROOT DIALOG DISCARDABLE 0, 0, 215, 95 -STYLE DS_MODALFRAME | DS_CENTER | WS_CHILD | WS_CAPTION | WS_SYSMENU -CAPTION "Cygwin Setup" -FONT 8, "MS Sans Serif" -BEGIN - ICON IDI_CYGWIN,IDC_STATIC,5,5,20,20 - PUSHBUTTON "B&rowse...",IDC_ROOT_BROWSE,150,10,34,14 - LTEXT "Select install root &directory",IDC_STATIC,55,15,85,11 - EDITTEXT IDC_ROOT_DIR,55,25,127,12,ES_AUTOHSCROLL - RTEXT "Default &Text File Type :",IDC_STATIC,20,45,100,8 - CONTROL "D&OS",IDC_ROOT_TEXT,"Button",BS_AUTORADIOBUTTON,125,45, - 31,8 - CONTROL "&Unix",IDC_ROOT_BINARY,"Button",BS_AUTORADIOBUTTON,160, - 45,30,8 - RTEXT "&Install For :",IDC_STATIC,55,60,65,8 - CONTROL "&All",IDC_ROOT_SYSTEM,"Button",BS_AUTORADIOBUTTON | - WS_GROUP,125,60,25,8 - CONTROL "Just &Me",IDC_ROOT_USER,"Button",BS_AUTORADIOBUTTON,160, - 60,50,8 + EDITTEXT IDC_LOCAL_DIR,58,83,165,15,ES_AUTOHSCROLL | WS_GROUP + PUSHBUTTON "B&rowse...",IDC_LOCAL_DIR_BROWSE,223,83,34,14 + GROUPBOX "Local Package Directory",IDC_STATIC,53,67,210,45 + ICON IDI_CYGWIN,IDC_STATIC,290,0,21,20 + CONTROL "",IDC_STATIC,"Static",SS_BLACKFRAME | SS_SUNKEN,0,28, + 317,1 + LTEXT "Select a directory where you want Setup to store the installation files it dowloads. The directory will be created if it does not already exist.", + IDC_STATIC,21,9,248,16,NOT WS_GROUP + LTEXT "Select Local Package Directory",IDC_STATIC_HEADER_TITLE, + 7,0,258,8,NOT WS_GROUP END -IDD_SITE DIALOG DISCARDABLE 0, 0, 247, 94 +IDD_ROOT DIALOG DISCARDABLE 0, 0, 317, 179 STYLE DS_MODALFRAME | DS_CENTER | WS_CHILD | WS_CAPTION | WS_SYSMENU CAPTION "Cygwin Setup" FONT 8, "MS Sans Serif" BEGIN - ICON IDI_CYGWIN,IDC_STATIC,5,5,20,20 - LTEXT "Select Download &Site",IDC_STATIC,55,5,135,11 - LISTBOX IDC_URL_LIST,55,20,185,65,LBS_NOINTEGRALHEIGHT | - LBS_EXTENDEDSEL | WS_VSCROLL | WS_HSCROLL | WS_TABSTOP + GROUPBOX "Root Directory",IDC_STATIC,5,50,305,40,WS_TABSTOP + GROUPBOX "Install For",IDC_STATIC,5,105,150,50,WS_TABSTOP + GROUPBOX "Default Text File Type",IDC_STATIC,160,105,150,50 + EDITTEXT IDC_ROOT_DIR,15,65,245,15,ES_AUTOHSCROLL | WS_GROUP + PUSHBUTTON "B&rowse...",IDC_ROOT_BROWSE,260,65,44,14 + CONTROL "&All Users",IDC_ROOT_SYSTEM,"Button",BS_AUTORADIOBUTTON | + WS_GROUP | WS_TABSTOP,15,120,85,8 + CONTROL "Just &Me",IDC_ROOT_USER,"Button",BS_AUTORADIOBUTTON | + WS_TABSTOP,15,135,85,8 + CONTROL "D&OS",IDC_ROOT_TEXT,"Button",BS_AUTORADIOBUTTON | + WS_GROUP | WS_TABSTOP,170,120,90,8 + CONTROL "&Unix",IDC_ROOT_BINARY,"Button",BS_AUTORADIOBUTTON | + WS_TABSTOP,170,135,90,8 + ICON IDI_CYGWIN,IDC_STATIC,290,0,20,20 + CONTROL "",IDC_STATIC,"Static",SS_BLACKFRAME | SS_SUNKEN,0,28, + 317,1 + LTEXT "Select the directory where you want to install Cygwin. Also choose a few installation parameters.", + IDC_STATIC,21,9,239,16,NOT WS_GROUP + LTEXT "Select Root Install Directory",IDC_STATIC_HEADER_TITLE, + 7,0,258,8,NOT WS_GROUP END -IDD_OTHER_URL DIALOG DISCARDABLE 0, 0, 215, 95 -STYLE DS_MODALFRAME | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU +IDD_SITE DIALOG DISCARDABLE 0, 0, 317, 179 +STYLE DS_MODALFRAME | DS_3DLOOK | DS_CENTER | WS_CHILD | WS_VISIBLE | + WS_CAPTION | WS_SYSMENU +EXSTYLE WS_EX_CONTROLPARENT CAPTION "Cygwin Setup" FONT 8, "MS Sans Serif" BEGIN - ICON IDI_CYGWIN,IDC_STATIC,5,5,20,20 - LTEXT "Select &URL to download from",IDC_STATIC,55,15,135,11 - EDITTEXT IDC_OTHER_URL,55,25,127,12,ES_AUTOHSCROLL - DEFPUSHBUTTON "&Next -->",IDOK,100,75,45,15 - PUSHBUTTON "Cancel",IDCANCEL,165,75,45,15 - PUSHBUTTON "<-- &Back",IDC_BACK,55,75,45,15 + ICON IDI_CYGWIN,IDC_STATIC,290,0,20,20 + LISTBOX IDC_URL_LIST,66,45,185,110,LBS_NOINTEGRALHEIGHT | + LBS_EXTENDEDSEL | WS_VSCROLL | WS_HSCROLL | WS_GROUP | + WS_TABSTOP + LTEXT "Available Download Sites:",IDC_STATIC,66,34,183,8,NOT + WS_GROUP + CONTROL "",IDC_STATIC,"Static",SS_BLACKFRAME | SS_SUNKEN,0,28, + 317,1 + LTEXT "Choose a site from this list, or add your own sites to the list", + IDC_STATIC,21,9,239,16,NOT WS_GROUP + LTEXT "Choose A Download Site",IDC_STATIC_HEADER_TITLE,7,0,258, + 8,NOT WS_GROUP + EDITTEXT IDC_EDIT_USER_URL,65,160,185,14,ES_AUTOHSCROLL | + WS_GROUP + LTEXT "User URL:",IDC_STATIC,15,162,45,8,NOT WS_GROUP + PUSHBUTTON "Add",IDC_BUTTON_ADD_URL,250,160,50,14 END -IDD_NET DIALOG DISCARDABLE 0, 0, 247, 106 +IDD_NET DIALOG DISCARDABLE 0, 0, 317, 179 STYLE DS_MODALFRAME | DS_CENTER | WS_CHILD | WS_CAPTION | WS_SYSMENU CAPTION "Cygwin Setup" FONT 8, "MS Sans Serif" BEGIN CONTROL "&Direct Connection",IDC_NET_DIRECT,"Button", - BS_AUTORADIOBUTTON | WS_GROUP | WS_TABSTOP,55,10,73,10 + BS_AUTORADIOBUTTON | WS_GROUP | WS_TABSTOP,60,55,73,10 CONTROL "Use &IE5 Settings",IDC_NET_IE5,"Button", - BS_AUTORADIOBUTTON | WS_TABSTOP,55,25,69,10 + BS_AUTORADIOBUTTON | WS_TABSTOP,60,70,69,10 CONTROL "Use HTTP/FTP &Proxy:",IDC_NET_PROXY,"Button", - BS_AUTORADIOBUTTON | WS_TABSTOP,55,40,88,10 - EDITTEXT IDC_PROXY_HOST,115,60,120,12,ES_AUTOHSCROLL | + BS_AUTORADIOBUTTON | WS_TABSTOP,60,85,88,10 + EDITTEXT IDC_PROXY_HOST,120,105,120,12,ES_AUTOHSCROLL | WS_DISABLED | WS_GROUP - EDITTEXT IDC_PROXY_PORT,115,80,30,12,ES_AUTOHSCROLL | WS_DISABLED - GROUPBOX "",IDC_STATIC,55,50,185,50 - ICON IDI_CYGWIN,IDC_STATIC,5,5,21,20 - RTEXT "Proxy &Host",IDC_STATIC,60,60,50,12,SS_CENTERIMAGE | + EDITTEXT IDC_PROXY_PORT,120,125,30,12,ES_AUTOHSCROLL | + WS_DISABLED + GROUPBOX "",IDC_STATIC,60,95,185,50 + RTEXT "Proxy &Host",IDC_STATIC,65,105,50,12,SS_CENTERIMAGE | NOT WS_GROUP - RTEXT "Por&t",IDC_STATIC,80,80,30,12,SS_CENTERIMAGE | NOT + RTEXT "Por&t",IDC_STATIC,85,125,30,12,SS_CENTERIMAGE | NOT WS_GROUP + ICON IDI_CYGWIN,IDC_STATIC,290,0,21,20 + CONTROL "",IDC_STATIC,"Static",SS_BLACKFRAME | SS_SUNKEN,0,28, + 317,1 + LTEXT "Setup needs to know how you want it to connect to the internet. Choose the appropriate settings below.", + IDC_STATIC,21,9,239,16,NOT WS_GROUP + LTEXT "Select Your Internet Connection", + IDC_STATIC_HEADER_TITLE,7,0,258,8,NOT WS_GROUP END -IDD_DLSTATUS DIALOG DISCARDABLE 0, 0, 215, 95 +IDD_INSTATUS DIALOG DISCARDABLE 0, 0, 317, 179 STYLE DS_MODALFRAME | DS_CENTER | WS_CHILD | WS_VISIBLE | WS_CAPTION | WS_SYSMENU CAPTION "Cygwin Setup" FONT 8, "MS Sans Serif" BEGIN - ICON IDI_CYGWIN,IDC_STATIC,5,5,20,20 - PUSHBUTTON "Cancel",IDCANCEL,165,75,45,15 - LTEXT "Downloading...",IDC_STATIC,55,5,135,8 - LTEXT "(URL)",IDC_DLS_URL,55,15,150,8 - LTEXT "(RATE)",IDC_DLS_RATE,55,25,155,8 - CONTROL "Progress1",IDC_DLS_PROGRESS,"msctls_progress32", - PBS_SMOOTH | WS_BORDER,55,40,155,10 - CONTROL "Progress1",IDC_DLS_PPROGRESS,"msctls_progress32", - PBS_SMOOTH | WS_BORDER,55,50,155,10 - CONTROL "Progress1",IDC_DLS_IPROGRESS,"msctls_progress32", - PBS_SMOOTH | WS_BORDER,55,60,155,10 - RTEXT "Package",IDC_DLS_PROGRESS_TEXT,5,40,45,8 - RTEXT "Total",IDC_DLS_PPROGRESS_TEXT,10,50,40,8 - RTEXT "Disk",IDC_DLS_IPROGRESS_TEXT,5,60,45,8 -END - -IDD_INSTATUS DIALOG DISCARDABLE 0, 0, 252, 94 -STYLE DS_MODALFRAME | DS_CENTER | WS_CHILD | WS_VISIBLE | WS_CAPTION | - WS_SYSMENU -CAPTION "Cygwin Setup" -FONT 8, "MS Sans Serif" -BEGIN - ICON IDI_CYGWIN,IDC_STATIC,5,5,21,20 - LTEXT "Installing...",IDC_INS_ACTION,55,5,135,8 - LTEXT "(PKG)",IDC_INS_PKG,55,15,150,8 - LTEXT "(FILE)",IDC_INS_FILE,55,25,155,8 + LTEXT "Installing...",IDC_INS_ACTION,45,55,205,8,NOT WS_GROUP + LTEXT "(PKG)",IDC_INS_PKG,45,70,205,8,NOT WS_GROUP + LTEXT "(FILE)",IDC_INS_FILE,45,85,205,8,NOT WS_GROUP CONTROL "Progress1",IDC_INS_DISKFULL,"msctls_progress32", - PBS_SMOOTH | WS_BORDER,90,60,155,10 + PBS_SMOOTH | WS_BORDER,95,130,155,10 CONTROL "Progress1",IDC_INS_IPROGRESS,"msctls_progress32", - PBS_SMOOTH | WS_BORDER,90,50,155,10 + PBS_SMOOTH | WS_BORDER,95,115,155,10 CONTROL "Progress1",IDC_INS_PPROGRESS,"msctls_progress32", - PBS_SMOOTH | WS_BORDER,90,40,155,10 - RTEXT "Package",IDC_INS_BL_PACKAGE,40,40,45,8 - RTEXT "Total",IDC_INS_BL_TOTAL,45,50,40,8 - RTEXT "Disk",IDC_INS_BL_DISK,40,60,45,8 + PBS_SMOOTH | WS_BORDER,95,100,155,10 + LTEXT "Package:",IDC_INS_BL_PACKAGE,45,100,47,8,NOT WS_GROUP + LTEXT "Total:",IDC_INS_BL_TOTAL,45,115,48,8,NOT WS_GROUP + LTEXT "Disk:",IDC_INS_BL_DISK,45,130,47,8,NOT WS_GROUP + ICON IDI_CYGWIN,IDC_STATIC,290,0,20,20 + CONTROL "",IDC_STATIC,"Static",SS_BLACKFRAME | SS_SUNKEN,0,28, + 317,1 + LTEXT "This page displays the progress of the download or installation.", + IDC_STATIC,21,9,239,16,NOT WS_GROUP + LTEXT "Progress",IDC_STATIC_HEADER_TITLE,7,0,253,8,NOT + WS_GROUP END IDD_PROXY_AUTH DIALOG DISCARDABLE 0, 0, 215, 95 @@ -197,23 +207,26 @@ BEGIN PUSHBUTTON "Cancel",IDCANCEL,165,75,45,15 END -IDD_SPLASH DIALOG DISCARDABLE 0, 0, 216, 94 +IDD_SPLASH DIALOG DISCARDABLE 0, 0, 317, 179 STYLE DS_MODALFRAME | DS_3DLOOK | DS_CENTER | WS_CHILD | WS_VISIBLE | WS_CAPTION | WS_SYSMENU CAPTION "Cygwin Setup" FONT 8, "MS Sans Serif" BEGIN - ICON IDI_CYGWIN,IDC_STATIC,5,5,20,20 - LTEXT "Cygwin Net Release Setup Program",IDC_STATIC,55,10,114, - 8 - LTEXT "Version (unknown)",IDC_VERSION,55,25,120,10 - LTEXT "Copyright 2000, 2001 Red Hat Inc.",IDC_STATIC,55,35,120, - 8 - LTEXT "http://sources.redhat.com/cygwin/",IDC_STATIC,55,50,112, - 8 + ICON IDI_CYGWIN,IDC_STATIC,113,112,21,20,WS_GROUP + CONTROL "",IDC_STATIC,"Static",SS_WHITERECT,0,0,95,178 + LTEXT "Version (unknown)",IDC_VERSION,115,137,195,10 + LTEXT "Cygwin Net Release Setup Program", + IDC_STATIC_WELCOME_TITLE,115,1,195,24 + LTEXT "Copyright 2000, 2001 Red Hat Inc.",IDC_STATIC,115,150, + 195,8 + LTEXT "http://sources.redhat.com/cygwin/",IDC_STATIC,115,162, + 195,8 + LTEXT "This wizard will guide you through the installation and updating of the Cygwin environment and a plethora of GNU packages.", + IDC_STATIC,115,33,195,54 END -IDD_CHOOSE DIALOGEX 0, 0, 430, 266 +IDD_CHOOSE DIALOG DISCARDABLE 0, 0, 430, 266 STYLE DS_MODALFRAME | DS_3DLOOK | DS_CENTER | WS_CHILD | WS_VISIBLE | WS_CAPTION | WS_SYSMENU EXSTYLE WS_EX_CONTROLPARENT @@ -241,17 +254,23 @@ BEGIN LTEXT "",IDC_CHOOSE_VIEWCAPTION,390,5,30,10 END -IDD_DESKTOP DIALOG DISCARDABLE 0, 0, 215, 95 +IDD_DESKTOP DIALOG DISCARDABLE 0, 0, 317, 179 STYLE DS_MODALFRAME | DS_3DLOOK | DS_CENTER | WS_CHILD | WS_VISIBLE | WS_CAPTION | WS_SYSMENU CAPTION "Cygwin Setup" FONT 8, "MS Sans Serif" BEGIN - ICON IDI_CYGWIN,IDC_STATIC,5,5,20,20 - CONTROL "Create Desktop &Icon",IDC_ROOT_DESKTOP,"Button", - BS_AUTOCHECKBOX,55,25,100,8 - CONTROL "Add to &Start Menu",IDC_ROOT_MENU,"Button", - BS_AUTOCHECKBOX,55,40,100,8 + CONTROL "Create icon on &Desktop",IDC_ROOT_DESKTOP,"Button", + BS_AUTOCHECKBOX,108,78,100,8 + CONTROL "Add icon to &Start Menu",IDC_ROOT_MENU,"Button", + BS_AUTOCHECKBOX,108,93,100,8 + ICON IDI_CYGWIN,IDC_STATIC,290,0,21,20 + CONTROL "",IDC_STATIC,"Static",SS_BLACKFRAME | SS_SUNKEN,0,28, + 317,1 + LTEXT "Tell setup if you want it to create a few icons for convenient access to the Cygwin environment.", + IDC_STATIC,21,9,239,16,NOT WS_GROUP + LTEXT "Create Icons",IDC_STATIC_HEADER_TITLE,7,0,258,8,NOT + WS_GROUP END IDD_FTP_AUTH DIALOG DISCARDABLE 0, 0, 215, 95 @@ -271,13 +290,14 @@ BEGIN PUSHBUTTON "Cancel",IDCANCEL,165,75,45,15 END -IDD_CHOOSER DIALOG DISCARDABLE 0, 0, 186, 90 +IDD_CHOOSER DIALOG DISCARDABLE 0, 0, 247, 116 STYLE DS_MODALFRAME | DS_3DLOOK | WS_CHILD | WS_VISIBLE | WS_CAPTION | WS_SYSMENU CAPTION "Cygwin Setup" FONT 8, "MS Sans Serif" BEGIN - LTEXT "Don't look here",IDC_STATIC,25,38,134,8 + CTEXT "This space intentionally left blank",IDC_STATIC,57,45, + 134,8 END @@ -333,21 +353,39 @@ CYGWIN.ICON FILE DISCARDABLE "cygwin.ico" #ifdef APSTUDIO_INVOKED GUIDELINES DESIGNINFO DISCARDABLE BEGIN + IDD_SOURCE, DIALOG + BEGIN + RIGHTMARGIN, 285 + BOTTOMMARGIN, 158 + END + IDD_LOCAL_DIR, DIALOG BEGIN - RIGHTMARGIN, 215 + RIGHTMARGIN, 305 + BOTTOMMARGIN, 157 + END + + IDD_ROOT, DIALOG + BEGIN + RIGHTMARGIN, 285 + BOTTOMMARGIN, 158 END IDD_SITE, DIALOG BEGIN - RIGHTMARGIN, 215 - BOTTOMMARGIN, 93 + BOTTOMMARGIN, 178 END IDD_NET, DIALOG BEGIN - RIGHTMARGIN, 215 - BOTTOMMARGIN, 60 + RIGHTMARGIN, 285 + BOTTOMMARGIN, 133 + END + + IDD_INSTATUS, DIALOG + BEGIN + RIGHTMARGIN, 252 + BOTTOMMARGIN, 157 END IDD_PROXY_AUTH, DIALOG @@ -360,11 +398,23 @@ BEGIN BOTTOMMARGIN, 49 END + IDD_SPLASH, DIALOG + BEGIN + RIGHTMARGIN, 247 + BOTTOMMARGIN, 116 + END + IDD_CHOOSE, DIALOG BEGIN RIGHTMARGIN, 429 END + IDD_DESKTOP, DIALOG + BEGIN + RIGHTMARGIN, 285 + BOTTOMMARGIN, 158 + END + IDD_FTP_AUTH, DIALOG BEGIN BOTTOMMARGIN, 49 @@ -373,9 +423,9 @@ BEGIN IDD_CHOOSER, DIALOG BEGIN LEFTMARGIN, 7 - RIGHTMARGIN, 179 + RIGHTMARGIN, 240 TOPMARGIN, 7 - BOTTOMMARGIN, 83 + BOTTOMMARGIN, 109 END END #endif // APSTUDIO_INVOKED diff --git a/resource.h b/resource.h index fbf17b42..926ef934 100644 --- a/resource.h +++ b/resource.h @@ -107,6 +107,10 @@ #define IDC_INS_BL_PACKAGE 1053 #define IDC_INS_BL_TOTAL 1054 #define IDC_INS_BL_DISK 1055 +#define IDC_STATIC_HEADER_TITLE 1060 +#define IDC_STATIC_WELCOME_TITLE 1061 +#define IDC_EDIT_USER_URL 1062 +#define IDC_BUTTON_ADD_URL 1063 #define IDC_STATIC -1 // Next default values for new objects @@ -115,9 +119,9 @@ #ifndef APSTUDIO_READONLY_SYMBOLS #define _APS_NO_MFC 1 #define _APS_3D_CONTROLS 1 -#define _APS_NEXT_RESOURCE_VALUE 128 +#define _APS_NEXT_RESOURCE_VALUE 129 #define _APS_NEXT_COMMAND_VALUE 40003 -#define _APS_NEXT_CONTROL_VALUE 1056 +#define _APS_NEXT_CONTROL_VALUE 1064 #define _APS_NEXT_SYMED_VALUE 101 #endif #endif diff --git a/root.h b/root.h index 3c47c7b4..bf083974 100644 --- a/root.h +++ b/root.h @@ -1,23 +1,23 @@ -#ifndef CINSTALL_ROOT_H -#define CINSTALL_ROOT_H - -#include "proppage.h" - -class RootPage:public PropertyPage -{ -public: - RootPage () - { - }; - virtual ~ RootPage () - { - }; - - bool Create (); - - virtual void OnInit (); - virtual long OnNext (); - virtual long OnBack (); -}; - -#endif // CINSTALL_ROOT_H +#ifndef CINSTALL_ROOT_H +#define CINSTALL_ROOT_H + +#include "proppage.h" + +class RootPage:public PropertyPage +{ +public: + RootPage () + { + }; + virtual ~ RootPage () + { + }; + + bool Create (); + + virtual void OnInit (); + virtual long OnNext (); + virtual long OnBack (); +}; + +#endif // CINSTALL_ROOT_H diff --git a/site.cc b/site.cc index ef052ceb..56b49797 100644 --- a/site.cc +++ b/site.cc @@ -45,12 +45,10 @@ static const char *cvsid = #include "threebar.h" extern ThreeBarProgressPage Progress; -#define NO_IDX (-1) -#define OTHER_IDX (-2) - list < site_list_type, const char *, strcasecmp > site_list; list < site_list_type, const char *, strcasecmp > all_site_list; -static int mirror_idx = NO_IDX; + +static char *other_url = 0; void site_list_type::init (char const *newurl) @@ -92,40 +90,16 @@ site_list_type::site_list_type (char const *newurl) } static void -check_if_enable_next (HWND h) -{ - EnableWindow (GetDlgItem (h, IDOK), - SendMessage (GetDlgItem (h, IDC_URL_LIST), LB_GETSELCOUNT, 0, - 0) > 0 ? 1 : 0); -} - -static void -load_dialog (HWND h) +save_dialog (HWND h) { - HWND listbox = GetDlgItem (h, IDC_URL_LIST); - for (size_t n = 1; n <= site_list.number (); n++) + // Remove anything that was previously in the selected site list. + while (site_list.number () > 0) { - int index = SendMessage (listbox, LB_FINDSTRING, (WPARAM) - 1, - (LPARAM) site_list[n]->displayed_url); - if (index != LB_ERR) - { - // Highlight the selected item - SendMessage (listbox, LB_SELITEMRANGE, TRUE, (index << 16) | index); - // Make sure it's fully visible - SendMessage (listbox, LB_SETCARETINDEX, index, FALSE); - } + // we don't delete the object because it's stored in the all_site_list. + site_list.removebyindex (1); } - check_if_enable_next (h); -} -static void -save_dialog (HWND h) -{ HWND listbox = GetDlgItem (h, IDC_URL_LIST); - mirror_idx = 0; - while (site_list.number () > 0) - /* we don't delete the object because it's stored in the all_site_list. */ - site_list.removebyindex (1); int sel_count = SendMessage (listbox, LB_GETSELCOUNT, 0, 0); if (sel_count > 0) { @@ -140,16 +114,9 @@ save_dialog (HWND h) { int mirror = SendMessage (listbox, LB_GETITEMDATA, sel_buffer[n], 0); - if (mirror == OTHER_IDX) - mirror_idx = OTHER_IDX; - else - site_list.registerbyobject (*all_site_list[mirror]); + site_list.registerbyobject (*all_site_list[mirror]); } } - else - { - NEXT (IDD_SITE); - } } void @@ -160,29 +127,17 @@ save_site_url () { if (f) { - char temp[_MAX_PATH]; - /* TODO: potential buffer overflow. we need snprintf asap. */ // FIXME: write all selected sites + TCHAR *temp; + temp = new TCHAR[sizeof (TCHAR) * (strlen (site_list[n]->url) + 2)]; sprintf (temp, "%s\n", site_list[n]->url); f->write (temp, strlen (temp)); + delete[]temp; } } delete f; } -static BOOL -dialog_cmd (HWND h, int id, HWND hwndctl, UINT code) -{ - switch (id) - { - - case IDC_URL_LIST: - check_if_enable_next (h); - break; - } - return 0; -} - static int get_site_list (HINSTANCE h, HWND owner) { @@ -302,7 +257,8 @@ do_download_site_info_thread (void *p) if (get_site_list (hinst, h)) { // Error: Couldn't download the site info. Go back to the Net setup page. - NEXT (IDD_NET); + MessageBox (h, TEXT ("Can't get list of download sites.\n\ +Make sure your network settings are corect and try again."), NULL, MB_OK); // Tell the progress page that we're done downloading Progress.PostMessage (WM_APP_SITE_INFO_DOWNLOAD_COMPLETE, 0, @@ -313,7 +269,6 @@ do_download_site_info_thread (void *p) } // Everything worked, go to the site select page - NEXT (IDD_SITE); // Tell the progress page that we're done downloading Progress.PostMessage (WM_APP_SITE_INFO_DOWNLOAD_COMPLETE, 0, IDD_SITE); @@ -334,32 +289,15 @@ do_download_site_info (HINSTANCE hinst, HWND owner) } -bool -SitePage::Create () +bool SitePage::Create () { - return PropertyPage::Create (NULL, dialog_cmd, IDD_SITE); + return PropertyPage::Create (IDD_SITE); } void SitePage::OnInit () { - HWND h = GetHWND (); - int j; - HWND listbox; - get_saved_sites (); - - listbox = GetDlgItem (IDC_URL_LIST); - for (size_t i = 1; i <= all_site_list.number (); i++) - { - j = - SendMessage (listbox, LB_ADDSTRING, 0, - (LPARAM) all_site_list[i]->displayed_url); - SendMessage (listbox, LB_SETITEMDATA, j, i); - } - j = SendMessage (listbox, LB_ADDSTRING, 0, (LPARAM) "Other URL"); - SendMessage (listbox, LB_SETITEMDATA, j, OTHER_IDX); - load_dialog (h); } long @@ -368,19 +306,14 @@ SitePage::OnNext () HWND h = GetHWND (); save_dialog (h); - if (mirror_idx == OTHER_IDX) - NEXT (IDD_OTHER_URL); - else - { - save_site_url (); - NEXT (IDD_S_LOAD_INI); + save_site_url (); - for (size_t n = 1; n <= site_list.number (); n++) - log (0, "site: %s", site_list[n]->url); + // Log all the selected URLs from the list. + for (size_t n = 1; n <= site_list.number (); n++) + log (0, "site: %s", site_list[n]->url); - Progress.SetActivateTask (WM_APP_START_SETUP_INI_DOWNLOAD); - return IDD_INSTATUS; - } + Progress.SetActivateTask (WM_APP_START_SETUP_INI_DOWNLOAD); + return IDD_INSTATUS; return 0; } @@ -391,6 +324,126 @@ SitePage::OnBack () HWND h = GetHWND (); save_dialog (h); - NEXT (IDD_NET); + + // Go back to the net connection type page return 0; } + +void +SitePage::OnActivate () +{ + // Fill the list box with all known sites. + PopulateListBox (); + + // Load the user URL box with whatever it was last time. + eset (GetHWND (), IDC_EDIT_USER_URL, other_url); + + // Get the enabled/disabled states of the controls set accordingly. + CheckControlsAndDisableAccordingly (); +} + +void +SitePage::CheckControlsAndDisableAccordingly () const +{ + DWORD ButtonFlags = PSWIZB_BACK; + + // Check that at least one download site is selected. + if (SendMessage (GetDlgItem (IDC_URL_LIST), LB_GETSELCOUNT, 0, 0) > 0) + { + // At least one official site selected, enable "Next". + ButtonFlags |= PSWIZB_NEXT; + } + GetOwner ()->SetButtons (ButtonFlags); +} + +void +SitePage::PopulateListBox () +{ + int j; + HWND listbox = GetDlgItem (IDC_URL_LIST); + + // Populate the list box with the URLs. + SendMessage (listbox, LB_RESETCONTENT, 0, 0); + for (size_t i = 1; i <= all_site_list.number (); i++) + { + j = SendMessage (listbox, LB_ADDSTRING, 0, + (LPARAM) all_site_list[i]->displayed_url); + SendMessage (listbox, LB_SETITEMDATA, j, i); + } + + // Select the selected ones. + for (size_t n = 1; n <= site_list.number (); n++) + { + int index = SendMessage (listbox, LB_FINDSTRING, (WPARAM) - 1, + (LPARAM) site_list[n]->displayed_url); + if (index != LB_ERR) + { + // Highlight the selected item + SendMessage (listbox, LB_SELITEMRANGE, TRUE, (index << 16) | index); + // Make sure it's fully visible + SendMessage (listbox, LB_SETCARETINDEX, index, FALSE); + } + } +} + +bool SitePage::OnMessageCmd (int id, HWND hwndctl, UINT code) +{ + switch (id) + { + case IDC_EDIT_USER_URL: + { + if (code == EN_CHANGE) + { + // Text in edit box may have changed. + other_url = eget (GetHWND (), IDC_EDIT_USER_URL, other_url); + } + break; + } + case IDC_URL_LIST: + { + if (code == LBN_SELCHANGE) + { + CheckControlsAndDisableAccordingly (); + } + break; + } + case IDC_BUTTON_ADD_URL: + { + if (code == BN_CLICKED) + { + // User pushed the Add button. + other_url = eget (GetHWND (), IDC_EDIT_USER_URL, other_url); + site_list_type * + newsite = + new + site_list_type (other_url); + site_list_type & listobj = + all_site_list.registerbyobject (*newsite); + if (&listobj != newsite) + { + // That site was already registered + delete + newsite; + } + else + { + // Log the adding of this new URL. + log (0, "Adding site: %s", other_url); + } + + // Assume the user wants to use it and select it for him. + site_list.registerbyobject (listobj); + + // Update the list box. + PopulateListBox (); + } + break; + } + default: + // Wasn't recognized or handled. + return false; + } + + // Was handled since we never got to default above. + return true; +} diff --git a/site.h b/site.h index 1c08c6e0..ff90a499 100644 --- a/site.h +++ b/site.h @@ -36,8 +36,14 @@ public: bool Create (); virtual void OnInit (); + virtual void OnActivate (); virtual long OnNext (); virtual long OnBack (); + + virtual bool OnMessageCmd (int id, HWND hwndctl, UINT code); + + void PopulateListBox(); + void CheckControlsAndDisableAccordingly () const; }; void do_download_site_info (HINSTANCE h, HWND owner); diff --git a/source.h b/source.h index 1859a6e3..2cf86270 100644 --- a/source.h +++ b/source.h @@ -1,43 +1,43 @@ -#ifndef CINSTALL_SOURCE_H -#define CINSTALL_SOURCE_H - -/* - * 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 - * - */ - -// This is the header for the SourcePage class, which lets the user -// select Download+Install, Download, or Install From Local Directory. - - -#include "proppage.h" - -class SourcePage:public PropertyPage -{ -public: - SourcePage () - { - }; - virtual ~ SourcePage () - { - }; - - bool Create (); - - virtual void OnActivate (); - virtual void OnDeactivate (); - virtual long OnNext (); - virtual long OnBack (); -}; - -#endif +#ifndef CINSTALL_SOURCE_H +#define CINSTALL_SOURCE_H + +/* + * 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 + * + */ + +// This is the header for the SourcePage class, which lets the user +// select Download+Install, Download, or Install From Local Directory. + + +#include "proppage.h" + +class SourcePage:public PropertyPage +{ +public: + SourcePage () + { + }; + virtual ~ SourcePage () + { + }; + + bool Create (); + + virtual void OnActivate (); + virtual void OnDeactivate (); + virtual long OnNext (); + virtual long OnBack (); +}; + +#endif diff --git a/splash.cc b/splash.cc index b53ec203..1e0c8603 100644 --- a/splash.cc +++ b/splash.cc @@ -36,4 +36,7 @@ SplashPage::OnInit () ver.Format (IDS_VERSION_INFO, version[0] ? version : "[unknown]"); SetWindowText (GetDlgItem (IDC_VERSION), ver.c_str ()); + + // Set the font for the IDC_STATIC_WELCOME_TITLE + SetDlgItemFont(IDC_STATIC_WELCOME_TITLE, "Ariel", 12, FW_BOLD); } diff --git a/splash.h b/splash.h index 27a3ccaa..f6a9597f 100644 --- a/splash.h +++ b/splash.h @@ -1,38 +1,38 @@ -#ifndef CINSTALL_SPLASH_H -#define CINSTALL_SPLASH_H - -/* - * 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 - * - */ - -// This is the header for the SplashPage class. Since the splash page -// has little to do, there's not much here. - -#include "proppage.h" - -class SplashPage:public PropertyPage -{ -public: - SplashPage () - { - }; - virtual ~ SplashPage () - { - }; - - bool Create (); - virtual void OnInit (); -}; - -#endif // CINSTALL_SPLASH_H +#ifndef CINSTALL_SPLASH_H +#define CINSTALL_SPLASH_H + +/* + * 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 + * + */ + +// This is the header for the SplashPage class. Since the splash page +// has little to do, there's not much here. + +#include "proppage.h" + +class SplashPage:public PropertyPage +{ +public: + SplashPage () + { + }; + virtual ~ SplashPage () + { + }; + + bool Create (); + virtual void OnInit (); +}; + +#endif // CINSTALL_SPLASH_H diff --git a/threebar.cc b/threebar.cc index d2403d30..62ba57f3 100644 --- a/threebar.cc +++ b/threebar.cc @@ -1,207 +1,207 @@ -/* - * 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 - * - */ - -// 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" - -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::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); -} - -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; -} +/* + * 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 + * + */ + +// 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" + +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::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); +} + +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; +} diff --git a/threebar.h b/threebar.h index 186bb949..84212485 100644 --- a/threebar.h +++ b/threebar.h @@ -1,81 +1,81 @@ -#ifndef CINSTALL_THREEBAR_H -#define CINSTALL_THREEBAR_H - -/* - * 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 - * - */ - -// This is the header for the ThreeBarProgressPage class. It is a fairly generic -// progress indicator property page with three progress bars. - - -#include "win32.h" -#include "proppage.h" - -#define WM_APP_START_DOWNLOAD WM_APP+0 -#define WM_APP_DOWNLOAD_THREAD_COMPLETE WM_APP+1 -#define WM_APP_START_INSTALL WM_APP+2 -#define WM_APP_INSTALL_THREAD_COMPLETE WM_APP+3 -#define WM_APP_START_SITE_INFO_DOWNLOAD WM_APP+4 -#define WM_APP_SITE_INFO_DOWNLOAD_COMPLETE WM_APP+5 -#define WM_APP_START_SETUP_INI_DOWNLOAD WM_APP+6 -#define WM_APP_SETUP_INI_DOWNLOAD_COMPLETE WM_APP+7 - -class ThreeBarProgressPage:public PropertyPage -{ - HWND ins_dialog; - HWND ins_action; - HWND ins_pkgname; - HWND ins_filename; - HWND ins_pprogress; - HWND ins_iprogress; - HWND ins_diskfull; - HWND ins_bl_package; - HWND ins_bl_total; - HWND ins_bl_disk; - - int task; - - void EnableSingleBar (bool enable = true); - -public: - ThreeBarProgressPage () - { - }; - virtual ~ ThreeBarProgressPage () - { - }; - - bool Create (); - - virtual void OnInit (); - virtual void OnActivate (); - virtual bool OnMessageApp (UINT uMsg, WPARAM wParam, LPARAM lParam); - - void SetText1 (const TCHAR * t); - void SetText2 (const TCHAR * t); - void SetText3 (const TCHAR * t); - - void SetBar1 (long progress, long max = 100); - void SetBar2 (long progress, long max = 100); - void SetBar3 (long progress, long max = 100); - - void SetActivateTask (int t) - { - task = t; - }; -}; - - -#endif // CINSTALL_THREEBAR_H +#ifndef CINSTALL_THREEBAR_H +#define CINSTALL_THREEBAR_H + +/* + * 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 + * + */ + +// This is the header for the ThreeBarProgressPage class. It is a fairly generic +// progress indicator property page with three progress bars. + + +#include "win32.h" +#include "proppage.h" + +#define WM_APP_START_DOWNLOAD WM_APP+0 +#define WM_APP_DOWNLOAD_THREAD_COMPLETE WM_APP+1 +#define WM_APP_START_INSTALL WM_APP+2 +#define WM_APP_INSTALL_THREAD_COMPLETE WM_APP+3 +#define WM_APP_START_SITE_INFO_DOWNLOAD WM_APP+4 +#define WM_APP_SITE_INFO_DOWNLOAD_COMPLETE WM_APP+5 +#define WM_APP_START_SETUP_INI_DOWNLOAD WM_APP+6 +#define WM_APP_SETUP_INI_DOWNLOAD_COMPLETE WM_APP+7 + +class ThreeBarProgressPage:public PropertyPage +{ + HWND ins_dialog; + HWND ins_action; + HWND ins_pkgname; + HWND ins_filename; + HWND ins_pprogress; + HWND ins_iprogress; + HWND ins_diskfull; + HWND ins_bl_package; + HWND ins_bl_total; + HWND ins_bl_disk; + + int task; + + void EnableSingleBar (bool enable = true); + +public: + ThreeBarProgressPage () + { + }; + virtual ~ ThreeBarProgressPage () + { + }; + + bool Create (); + + virtual void OnInit (); + virtual void OnActivate (); + virtual bool OnMessageApp (UINT uMsg, WPARAM wParam, LPARAM lParam); + + void SetText1 (const TCHAR * t); + void SetText2 (const TCHAR * t); + void SetText3 (const TCHAR * t); + + void SetBar1 (long progress, long max = 100); + void SetBar2 (long progress, long max = 100); + void SetBar3 (long progress, long max = 100); + + void SetActivateTask (int t) + { + task = t; + }; +}; + + +#endif // CINSTALL_THREEBAR_H diff --git a/window.cc b/window.cc index 8eccbd1f..d7325d8c 100644 --- a/window.cc +++ b/window.cc @@ -38,10 +38,19 @@ Window::Window () { WindowHandle = NULL; Parent = NULL; + FontCounter = 0; } Window::~Window () { + // Delete any fonts we created. + int i; + for (i = 0; i < FontCounter; i++) + { + DeleteObject (Fonts[i]); + } + FontCounter = 0; + // FIXME: Maybe do some reference counting and do this Unregister // when there are no more of us left. Not real critical unless // we're in a DLL which we're not right now. @@ -260,3 +269,49 @@ Window::PostMessage (UINT uMsg, WPARAM wParam, LPARAM lParam) { ::PostMessage (GetHWND (), uMsg, wParam, lParam); } + +UINT Window::IsButtonChecked (int nIDButton) const +{ + return::IsDlgButtonChecked (GetHWND (), nIDButton); +} + +bool + Window::SetDlgItemFont (int id, const TCHAR * fontname, int Pointsize, + int Weight, bool Italic, bool Underline, + bool Strikeout) +{ + HWND ctrl; + ctrl = GetDlgItem (id); + if (ctrl == NULL) + { + // Couldn't get that ID + return false; + } + + // We need the DC for the point size calculation. + HDC hdc = GetDC (ctrl); + + // Create the font. We have to keep it around until the dialog item + // goes away - basically until we're destroyed. + HFONT hfnt; + hfnt = + CreateFont (-MulDiv (Pointsize, GetDeviceCaps (hdc, LOGPIXELSY), 72), 0, + 0, 0, Weight, Italic ? TRUE : FALSE, + Underline ? TRUE : FALSE, Strikeout ? TRUE : FALSE, + ANSI_CHARSET, OUT_TT_PRECIS, CLIP_DEFAULT_PRECIS, + PROOF_QUALITY, DEFAULT_PITCH | FF_DONTCARE, fontname); + if (hfnt == NULL) + { + // Font creation failed + return false; + } + + // Set the new fint, and redraw any text which was already in the item. + SendMessage (ctrl, WM_SETFONT, (WPARAM) hfnt, TRUE); + + // Save it for later. + Fonts[FontCounter] = hfnt; + FontCounter++; + + return true; +} diff --git a/window.h b/window.h index 2cb405b0..03702490 100644 --- a/window.h +++ b/window.h @@ -39,6 +39,11 @@ class Window Window *Parent; + // FIXME: replace with when we get a chance. + static const int MAXFONTS = 5; + HFONT Fonts[MAXFONTS]; + int FontCounter; + protected: void SetHWND (HWND h) { @@ -79,6 +84,10 @@ public: { return::GetDlgItem (GetHWND (), id); }; + bool SetDlgItemFont(int id, const TCHAR *fontname, int Pointsize, + int Weight = FW_NORMAL, bool Italic = false, bool Underline = false, bool Strikeout = false); + + UINT IsButtonChecked (int nIDButton) const; void PostMessage (UINT uMsg, WPARAM wParam = 0, LPARAM lParam = 0); @@ -87,6 +96,12 @@ public: return false; }; + virtual bool OnMessageCmd (int id, HWND hwndctl, UINT code) + { + // Not processed. + return false; + }; + // Center the window on the parent, or on screen if no parent. void CenterWindow (); -- 2.43.5