Index: Makefile.am =================================================================== RCS file: /cvs/cygwin-apps/setup/Makefile.am,v retrieving revision 2.34 diff -u -p -r2.34 Makefile.am --- Makefile.am 30 Jul 2003 09:04:27 -0000 2.34 +++ Makefile.am 16 Oct 2003 16:32:49 -0000 @@ -140,6 +140,8 @@ setup_SOURCES = \ compress_gz.h \ ConnectionSetting.cc \ ConnectionSetting.h \ + ControlAdjuster.cc \ + ControlAdjuster.h \ cygpackage.cc \ cygpackage.h \ desktop.cc \ Index: proppage.cc =================================================================== RCS file: /cvs/cygwin-apps/setup/proppage.cc,v retrieving revision 2.9 diff -u -p -r2.9 proppage.cc --- proppage.cc 2 Aug 2003 00:02:01 -0000 2.9 +++ proppage.cc 16 Oct 2003 16:32:49 -0000 @@ -26,12 +26,23 @@ bool PropertyPage::DoOnceForSheet = true; +/* + Sizing information for some controls that are common to all pages. + */ +static ControlAdjuster::ControlInfo DefaultControlsInfo[] = { + {IDC_HEADICON, false, true, true, false}, + {IDC_HEADSEPARATOR, true, true, true, false}, + {0, false, false, false, false} +}; + PropertyPage::PropertyPage () { proc = NULL; cmdproc = NULL; IsFirst = false; IsLast = false; + + sizeProcessor.AddControlInfo (DefaultControlsInfo); } PropertyPage::~PropertyPage () @@ -117,6 +128,9 @@ PropertyPage::DialogProc (UINT message, OnInit (); setTitleFont (); + + // Call it here so it stores the initial client rect. + sizeProcessor.UpdateSize (GetHWND ()); // TRUE = Set focus to default control (in wParam). return TRUE; @@ -140,6 +154,8 @@ PropertyPage::DialogProc (UINT message, DoOnceForSheet = false; } + GetOwner ()->AdjustPageSize (GetHWND ()); + // Set the wizard buttons apropriately if (IsFirst) { @@ -253,6 +269,11 @@ PropertyPage::DialogProc (UINT message, { return HANDLE_WM_COMMAND (GetHWND (), wParam, lParam, cmdproc); } + break; + } + case WM_SIZE: + { + sizeProcessor.UpdateSize (GetHWND ()); break; } default: Index: proppage.h =================================================================== RCS file: /cvs/cygwin-apps/setup/proppage.h,v retrieving revision 2.9 diff -u -p -r2.9 proppage.h --- proppage.h 6 Oct 2003 22:19:59 -0000 2.9 +++ proppage.h 16 Oct 2003 16:32:49 -0000 @@ -24,6 +24,7 @@ #include #include "window.h" +#include "ControlAdjuster.h" class PropSheet; @@ -39,7 +40,7 @@ class PropertyPage:public Window // For setting the back/finish buttons properly. bool IsFirst, IsLast; - + static BOOL CALLBACK FirstDialogProcReflector (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam); @@ -48,6 +49,8 @@ class PropertyPage:public Window void setTitleFont (); protected: + SizeProcessor sizeProcessor; + virtual BOOL CALLBACK DialogProc (UINT message, WPARAM wParam, LPARAM lParam); Index: propsheet.cc =================================================================== RCS file: /cvs/cygwin-apps/setup/propsheet.cc,v retrieving revision 2.6 diff -u -p -r2.6 propsheet.cc --- propsheet.cc 3 Aug 2003 16:25:18 -0000 2.6 +++ propsheet.cc 16 Oct 2003 16:32:49 -0000 @@ -21,6 +21,8 @@ #include "propsheet.h" #include "proppage.h" #include "resource.h" +#include "RECTWrapper.h" +#include "ControlAdjuster.h" //#include // ...but since there is no shlwapi.h in mingw yet: @@ -99,6 +101,102 @@ PropSheet::CreatePages () return retarray; } +// Stuff needed by the PropSheet wndproc hook +// @@@ Ugly. Really only works because only one PS is used now. +static struct _PropSheetData +{ + WNDPROC oldWndProc; + bool clientRectValid; + RECTWrapper lastClientRect; + bool gotPage; + RECTWrapper pageRect; + + _PropSheetData () + { + // Brutish... but does the trick. + memset (this, 0, sizeof (*this)); + } +} PropSheetData; + +static ControlAdjuster::ControlInfo PropSheetControlsInfo[] = { + {0x3023, false, false, true, true }, // Back + {0x3024, false, false, true, true }, // Next + {0x3025, false, false, true, true }, // Finish + {0x3026, true, false, true, true }, // Line above buttons + { 2, false, false, true, true }, // Cancel + {0, false, false, false, false} +}; + +static bool IsDialog (HWND hwnd) +{ + char className[7]; + GetClassName (hwnd, className, sizeof (className)); + + return (strcmp (className, "#32770") == 0); +} + +BOOL CALLBACK EnumPages (HWND hwnd, LPARAM lParam) +{ + // Is it really a dialog? + if (IsDialog (hwnd)) + { + SetWindowPos (hwnd, 0, PropSheetData.pageRect.left, + PropSheetData.pageRect.top, PropSheetData.pageRect.width (), + PropSheetData.pageRect.height (), SWP_NOACTIVATE | SWP_NOZORDER); + } + + return TRUE; +} + +static LRESULT CALLBACK PropSheetWndProc (HWND hwnd, UINT uMsg, + WPARAM wParam, LPARAM lParam) +{ + switch (uMsg) + { + case WM_SIZE: + { + RECTWrapper clientRect; + GetClientRect (hwnd, &clientRect); + + /* + The first time we get a WM_SIZE, the client rect will be all zeros. + */ + if (PropSheetData.clientRectValid) + { + const int dX = + clientRect.width () - PropSheetData.lastClientRect.width (); + const int dY = + clientRect.height () - PropSheetData.lastClientRect.height (); + + ControlAdjuster::AdjustControls (hwnd, PropSheetControlsInfo, + dX, dY); + + PropSheetData.pageRect.right += dX; + PropSheetData.pageRect.bottom += dY; + + /* + The pages are child windows, but don't have IDs. + So change them by enumerating all childs and adjust all dilogs + among them. + */ + if (PropSheetData.gotPage) + EnumChildWindows (hwnd, &EnumPages, 0); + } + else + { + PropSheetData.clientRectValid = true; + } + + memcpy (&PropSheetData.lastClientRect, &clientRect, + sizeof (RECTWrapper)); + } + break; + } + + return CallWindowProc (PropSheetData.oldWndProc, + hwnd, uMsg, wParam, lParam); +} + static int CALLBACK PropSheetProc (HWND hwndDlg, UINT uMsg, LPARAM lParam) { @@ -106,17 +204,31 @@ PropSheetProc (HWND hwndDlg, UINT uMsg, { case PSCB_PRECREATE: { + const LONG additionalStyle = + (WS_MINIMIZEBOX | WS_MAXIMIZEBOX | WS_THICKFRAME); // Add a minimize box to the sheet/wizard. if (((LPDLGTEMPLATEEX) lParam)->signature == 0xFFFF) { - ((LPDLGTEMPLATEEX) lParam)->style |= WS_MINIMIZEBOX; + ((LPDLGTEMPLATEEX) lParam)->style |= additionalStyle; } else { - ((LPDLGTEMPLATE) lParam)->style |= WS_MINIMIZEBOX; + ((LPDLGTEMPLATE) lParam)->style |= additionalStyle; } } return TRUE; + case PSCB_INITIALIZED: + { + /* + Hook into the window proc. + We need to catch some messages for resizing. + */ + PropSheetData.oldWndProc = + (WNDPROC)GetWindowLongPtr (hwndDlg, GWLP_WNDPROC); + SetWindowLongPtr (hwndDlg, GWLP_WNDPROC, + (LONG_PTR)&PropSheetWndProc); + } + return TRUE; } return TRUE; } @@ -218,6 +330,49 @@ PropSheet::SetHWNDFromPage (HWND h) // If we're a modal dialog, there's no way for us to know our window handle unless // one of our pages tells us through this function. SetHWND (h); +} + +/* + Adjust the size of a page so that it fits nicely into the window. + */ +void +PropSheet::AdjustPageSize (HWND page) +{ + if (!PropSheetData.clientRectValid) return; + + /* + It's probably not obvious what's done here: + When this method is called the first time, the first page is already + created and sized, but at the coordinates (0,0). The sheet, however, + isn't in it's final size. My guess is that the sheet first creates the + page, and then resizes itself to have the right metrics to contain the + page and moves it to it's position. For our purposes, however, we need + the final metrucs of the page. So, the first time this method is called, + we basically grab the size of the page, but calculate the top/left coords + ourselves. + */ + + if (!PropSheetData.gotPage) + { + PropSheetData.gotPage = true; + + RECTWrapper& pageRect = PropSheetData.pageRect; + ::GetWindowRect (page, &pageRect); + // We want client coords. + ::ScreenToClient (page, (LPPOINT)&pageRect.left); + ::ScreenToClient (page, (LPPOINT)&pageRect.right); + + LONG dialogBaseUnits = ::GetDialogBaseUnits (); + // The margins in DUs are a result of "educated guesses" and T&E. + int marginX = MulDiv (5, LOWORD(dialogBaseUnits), 4); + int marginY = MulDiv (5, HIWORD(dialogBaseUnits), 8); + + pageRect.move (marginX, marginY); + } + + SetWindowPos (page, 0, PropSheetData.pageRect.left, + PropSheetData.pageRect.top, PropSheetData.pageRect.width (), + PropSheetData.pageRect.height (), SWP_NOACTIVATE | SWP_NOZORDER); } void Index: propsheet.h =================================================================== RCS file: /cvs/cygwin-apps/setup/propsheet.h,v retrieving revision 2.5 diff -u -p -r2.5 propsheet.h --- propsheet.h 3 Aug 2003 16:25:18 -0000 2.5 +++ propsheet.h 16 Oct 2003 16:32:49 -0000 @@ -45,6 +45,7 @@ public: // Should be private and friended to PropertyPage void SetHWNDFromPage (HWND h); + void AdjustPageSize (HWND page); virtual bool Create (const Window * Parent = NULL, DWORD Style = Index: res.rc =================================================================== RCS file: /cvs/cygwin-apps/setup/res.rc,v retrieving revision 2.52 diff -u -p -r2.52 res.rc --- res.rc 26 Jul 2003 13:35:21 -0000 2.52 +++ res.rc 16 Oct 2003 16:32:49 -0000 @@ -45,8 +45,8 @@ BEGIN BS_AUTORADIOBUTTON | WS_TABSTOP,101,84,115,10 CONTROL "Install from &Local Directory",IDC_SOURCE_CWD,"Button", 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, + ICON IDI_CYGWIN,IDC_HEADICON,290,0,21,20 + CONTROL "",IDC_HEADSEPARATOR,"Static",SS_BLACKFRAME | SS_SUNKEN,0,28, 317,1 LTEXT "Choose A Download Source",IDC_STATIC_HEADER_TITLE,7,0, 258,8,NOT WS_GROUP @@ -63,8 +63,8 @@ BEGIN BS_AUTORADIOBUTTON | WS_GROUP | WS_TABSTOP,101,69,115,10 CONTROL "&Leave Virus scanner alone",IDC_LEAVE_AV,"Button", BS_AUTORADIOBUTTON | WS_TABSTOP,101,84,115,10 - ICON IDI_CYGWIN,IDC_STATIC,290,0,21,20 - CONTROL "",IDC_STATIC,"Static",SS_BLACKFRAME | SS_SUNKEN,0,28, + ICON IDI_CYGWIN,IDC_HEADICON,290,0,21,20 + CONTROL "",IDC_HEADSEPARATOR,"Static",SS_BLACKFRAME | SS_SUNKEN,0,28, 317,1 LTEXT "Choose whether to disable your virus scanner while installing.",IDC_STATIC_HEADER_TITLE,7,0, 258,8,NOT WS_GROUP @@ -82,8 +82,8 @@ BEGIN 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, + ICON IDI_CYGWIN,IDC_HEADICON,290,0,21,20 + CONTROL "",IDC_HEADSEPARATOR,"Static",SS_BLACKFRAME | SS_SUNKEN,0,28, 317,1 LTEXT "Select a directory where you want Setup to store the installation files it downloads. The directory will be created if it does not already exist.", IDC_STATIC,21,9,248,16,NOT WS_GROUP @@ -109,8 +109,8 @@ BEGIN 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, + ICON IDI_CYGWIN,IDC_HEADICON,290,0,21,20 + CONTROL "",IDC_HEADSEPARATOR,"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 @@ -125,13 +125,13 @@ EXSTYLE WS_EX_CONTROLPARENT CAPTION "Cygwin Setup - Choose Download Site(s)" FONT 8, "MS Shell Dlg" BEGIN - ICON IDI_CYGWIN,IDC_STATIC,290,0,20,20 + ICON IDI_CYGWIN,IDC_HEADICON,290,0,21,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, + CONTROL "",IDC_HEADSEPARATOR,"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 @@ -163,8 +163,8 @@ BEGIN NOT WS_GROUP 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, + ICON IDI_CYGWIN,IDC_HEADICON,290,0,21,20 + CONTROL "",IDC_HEADSEPARATOR,"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 @@ -190,8 +190,8 @@ BEGIN 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, + ICON IDI_CYGWIN,IDC_HEADICON,290,0,21,20 + CONTROL "",IDC_HEADSEPARATOR,"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 @@ -204,7 +204,7 @@ STYLE DS_MODALFRAME | DS_CENTER | WS_POP CAPTION "Proxy Authentication required" FONT 8, "MS Shell Dlg" BEGIN - ICON IDI_CYGWIN,IDC_STATIC,5,5,20,20 + ICON IDI_CYGWIN,IDC_HEADICON,5,5,21,20 LTEXT "Proxy &User ID",IDC_STATIC,5,28,55,15,SS_CENTERIMAGE, WS_EX_RIGHT EDITTEXT IDC_NET_USER,65,28,145,12,ES_AUTOHSCROLL @@ -221,7 +221,7 @@ STYLE DS_MODALFRAME | DS_CENTER | WS_POP CAPTION "Server Authentication required" FONT 8, "MS Shell Dlg" BEGIN - ICON IDI_CYGWIN,IDC_STATIC,5,5,20,20 + ICON IDI_CYGWIN,IDC_HEADICON,5,5,21,20 LTEXT "&User ID",IDC_STATIC,5,28,55,15,SS_CENTERIMAGE, WS_EX_RIGHT EDITTEXT IDC_NET_USER,65,28,145,12,ES_AUTOHSCROLL @@ -262,8 +262,8 @@ BEGIN 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, + ICON IDI_CYGWIN,IDC_HEADICON,290,0,21,20 + CONTROL "",IDC_HEADSEPARATOR,"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 @@ -276,7 +276,7 @@ STYLE DS_MODALFRAME | DS_CENTER | WS_POP CAPTION "FTP Authentication required" FONT 8, "MS Shell Dlg" BEGIN - ICON IDI_CYGWIN,IDC_STATIC,5,5,20,20 + ICON IDI_CYGWIN,IDC_HEADICON,5,5,21,20 LTEXT "&User ID",IDC_STATIC,5,28,55,15,SS_CENTERIMAGE, WS_EX_RIGHT EDITTEXT IDC_NET_USER,65,28,145,12,ES_AUTOHSCROLL @@ -303,11 +303,11 @@ BEGIN CONTROL "E&xp",IDC_CHOOSE_EXP,"Button",BS_AUTORADIOBUTTON , 210,30,25,10 PUSHBUTTON "&View",IDC_CHOOSE_VIEW,245,30,20,10,WS_GROUP - CONTROL "",IDC_STATIC,"Static",SS_BLACKFRAME | SS_SUNKEN,0,28, + CONTROL "",IDC_HEADSEPARATOR,"Static",SS_BLACKFRAME | SS_SUNKEN,0,28, 317,1 CONTROL "",IDC_LISTVIEW_POS,"Static",SS_BLACKFRAME | NOT WS_VISIBLE,7,41,303,134 - ICON IDI_CYGWIN,IDC_STATIC,290,0,20,20 + ICON IDI_CYGWIN,IDC_HEADICON,290,0,21,20 LTEXT "Select the packages you want setup to install.", IDC_CHOOSE_INST_TEXT,21,9,239,16,NOT WS_GROUP LTEXT "Select Packages",IDC_STATIC_HEADER_TITLE,7,0,258,8,NOT Index: resource.h =================================================================== RCS file: /cvs/cygwin-apps/setup/resource.h,v retrieving revision 2.22 diff -u -p -r2.22 resource.h --- resource.h 9 Mar 2003 01:39:42 -0000 2.22 +++ resource.h 16 Oct 2003 16:36:13 -0000 @@ -122,6 +122,8 @@ #define IDC_CHOOSE_KEEP 1069 #define IDS_MISSING_LOG 1070 #define IDS_SKIP_PACKAGE 1071 +#define IDC_HEADICON 1072 +#define IDC_HEADSEPARATOR 1073 #define IDC_STATIC -1 // Next default values for new objects