On Sun, 19 Oct 2003, Igor Pechtchanski wrote:

> On Thu, 16 Oct 2003, Igor Pechtchanski wrote:
>
> > On Thu, 16 Oct 2003, Frank Richter wrote:
> >
> > > On 16.10.2003 22:29, Robert Collins wrote:
> > > > Before further review, I'd like you to correct
> > > > such abuses of C++.
> > >
> > > Done.
> > >
> > > Also, this patch is a bit more useful than the last one - the Chooser
> > > now sizes with the window.
> > >
> > > - f.r.
> >
> > Okay, this does indeed give us a resizeable chooser -- yuppee!!!  The
> > header row still behaves weirdly under Win2k (i.e., it fixes on a
> > particular size and won't bulge until a scroll bar is touched after
> > switching views), but it's something that can be lived with.
> >
> > Once this gets accepted, it would be relatively easy to make most other
> > dialogs resizeable.  One problem, as I mentioned before, would be with
> > items that need to be centered.
> >
> > Frank, thank you *very much* for doing this.
> >         Igor
>
> Rob, BTW, when this patch gets accepted, I have an idea on how to modify
> this code to allow more intuitive control over the elements (e.g.,
> centering).  I'll also be able to make most of the other dialogs
> resizeable.
>         Igor

As promised.
        Igor
==============================================================================
ChangeLog:
2003-10-31  Igor Pechtchanski  <[EMAIL PROTECTED]>

        * ControlAdjuster.h (ControlPosition): New enum type.
        (ControlInfo::horizontalPos, ControlInfo::verticalPos): New
        instance variables.
        (ControlInfo::anchorLeft, ControlInfo::anchorTop,
        ControlInfo::anchorRight, ControlInfo::anchorBottom): Remove.
        * ControlAdjuster.cc (ControlAdjuster::AdjustControls): Switch to
        using position specifiers instead of anchors.
        * choose.cc (ChooserControlsInfo): Ditto.
        * proppage.cc (DefaultControlsInfo): Ditto.
        * propsheet.cc (PropSheetControlsInfo): Ditto.
        * site.cc (SiteControlsInfo): Position specifiers for site
        selection dialog controls.
        * threebar.cc (ThreeBarControlsInfo): Position specifiers for
        progress dialog controls.

-- 
                                http://cs.nyu.edu/~pechtcha/
      |\      _,,,---,,_                [EMAIL PROTECTED]
ZZZzz /,`.-'`'    -.  ;-;;,_            [EMAIL PROTECTED]
     |,4-  ) )-,_. ,\ (  `'-'           Igor Pechtchanski, Ph.D.
    '---''(_/--'  `-'\_) fL     a.k.a JaguaR-R-R-r-r-r-.-.-.  Meow!

"I have since come to realize that being between your mentor and his route
to the bathroom is a major career booster."  -- Patrick Naughton
Index: ControlAdjuster.cc
===================================================================
RCS file: /cvs/cygwin-apps/setup/ControlAdjuster.cc,v
retrieving revision 2.1
diff -u -p -r2.1 ControlAdjuster.cc
--- ControlAdjuster.cc  26 Oct 2003 19:38:30 -0000      2.1
+++ ControlAdjuster.cc  1 Nov 2003 03:12:34 -0000
@@ -35,18 +35,40 @@ void ControlAdjuster::AdjustControls (HW
       
       /*
         Now adjust the rectangle.
-       If an anchor is set, the resp. edge is 'sticky' with respect to the
-       opposite border.
        */
-      if (!ci->anchorLeft) 
-        ctlRect.left += widthChange;
-      if (!ci->anchorTop) 
-        ctlRect.top += heightChange;
-      if (ci->anchorRight) 
-        ctlRect.right += widthChange;
-      if (ci->anchorBottom) 
-        ctlRect.bottom += heightChange;
-       
+      switch (ci->horizontalPos)
+      {
+       case CP_LEFT:
+         break;
+       case CP_MIDDLE:
+         ctlRect.left += widthChange/2;
+         ctlRect.right += widthChange - widthChange/2;
+         break;
+       case CP_RIGHT:
+         ctlRect.left += widthChange;
+         ctlRect.right += widthChange;
+         break;
+       case CP_STRETCH:
+         ctlRect.right += widthChange;
+         break;
+      }
+      switch (ci->verticalPos)
+      {
+       case CP_TOP:
+         break;
+       case CP_MIDDLE:
+         ctlRect.top += heightChange/2;
+         ctlRect.bottom += heightChange - heightChange/2;
+         break;
+       case CP_BOTTOM:
+         ctlRect.top += heightChange;
+         ctlRect.bottom += heightChange;
+         break;
+       case CP_STRETCH:
+         ctlRect.bottom += heightChange;
+         break;
+      }
+
       SetWindowPos (ctl, 0, ctlRect.left, ctlRect.top, 
        ctlRect.width (), ctlRect.height (), SWP_NOACTIVATE | SWP_NOZORDER);
       // If not done, weird visual glitches can occur.
Index: ControlAdjuster.h
===================================================================
RCS file: /cvs/cygwin-apps/setup/ControlAdjuster.h,v
retrieving revision 2.1
diff -u -p -r2.1 ControlAdjuster.h
--- ControlAdjuster.h   26 Oct 2003 19:38:30 -0000      2.1
+++ ControlAdjuster.h   1 Nov 2003 03:12:34 -0000
@@ -28,6 +28,15 @@
   when the size changes.
  */
 
+enum ControlPosition {
+  CP_LEFT = 0,
+  CP_TOP = CP_LEFT,
+  CP_MIDDLE,
+  CP_RIGHT,
+  CP_BOTTOM = CP_RIGHT,
+  CP_STRETCH,
+};
+
 class ControlAdjuster
 {
 public:
@@ -36,12 +45,10 @@ public:
     // Control ID
     int control;
     /*
-      Anchors. Basically, says which edge should be "sticky".
+     * Position specifiers.
      */
-    bool anchorLeft;
-    bool anchorTop;
-    bool anchorRight;
-    bool anchorBottom;
+    ControlPosition horizontalPos;
+    ControlPosition verticalPos;
   };
   
   /*
Index: choose.cc
===================================================================
RCS file: /cvs/cygwin-apps/setup/choose.cc,v
retrieving revision 2.134
diff -u -p -r2.134 choose.cc
--- choose.cc   26 Oct 2003 19:38:30 -0000      2.134
+++ choose.cc   1 Nov 2003 03:12:34 -0000
@@ -66,15 +66,15 @@ extern ThreeBarProgressPage Progress;
   Sizing information.
  */
 static ControlAdjuster::ControlInfo ChooserControlsInfo[] = {
-  {IDC_CHOOSE_KEEP,            false, true,  true,  false},
-  {IDC_CHOOSE_PREV,            false, true,  true,  false},
-  {IDC_CHOOSE_CURR,            false, true,  true,  false},
-  {IDC_CHOOSE_EXP,             false, true,  true,  false},
-  {IDC_CHOOSE_VIEW,            false, true,  true,  false},
-  {IDC_LISTVIEW_POS,           false, true,  true,  false},
-  {IDC_CHOOSE_VIEWCAPTION,     false, true,  true,  false},
-  {IDC_CHOOSE_LIST,            true,  true,  true,  true },
-  {0, false, false, false, false}
+  {IDC_CHOOSE_KEEP,            CP_RIGHT,   CP_TOP},
+  {IDC_CHOOSE_PREV,            CP_RIGHT,   CP_TOP},
+  {IDC_CHOOSE_CURR,            CP_RIGHT,   CP_TOP},
+  {IDC_CHOOSE_EXP,             CP_RIGHT,   CP_TOP},
+  {IDC_CHOOSE_VIEW,            CP_RIGHT,   CP_TOP},
+  {IDC_LISTVIEW_POS,           CP_RIGHT,   CP_TOP},
+  {IDC_CHOOSE_VIEWCAPTION,     CP_RIGHT,   CP_TOP},
+  {IDC_CHOOSE_LIST,            CP_STRETCH, CP_STRETCH},
+  {0, CP_LEFT, CP_TOP}
 };
 
 ChooserPage::ChooserPage ()
Index: proppage.cc
===================================================================
RCS file: /cvs/cygwin-apps/setup/proppage.cc,v
retrieving revision 2.10
diff -u -p -r2.10 proppage.cc
--- proppage.cc 26 Oct 2003 19:38:30 -0000      2.10
+++ proppage.cc 1 Nov 2003 03:12:35 -0000
@@ -30,9 +30,9 @@ 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}
+  {IDC_HEADICON,       CP_RIGHT,   CP_TOP},
+  {IDC_HEADSEPARATOR,  CP_STRETCH, CP_TOP},
+  {0, CP_LEFT, CP_TOP}
 };
 
 PropertyPage::PropertyPage ()
Index: propsheet.cc
===================================================================
RCS file: /cvs/cygwin-apps/setup/propsheet.cc,v
retrieving revision 2.7
diff -u -p -r2.7 propsheet.cc
--- propsheet.cc        26 Oct 2003 19:38:30 -0000      2.7
+++ propsheet.cc        1 Nov 2003 03:12:35 -0000
@@ -126,12 +126,12 @@ struct 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}
+  {0x3023, CP_RIGHT,   CP_BOTTOM},     // Back
+  {0x3024, CP_RIGHT,   CP_BOTTOM},     // Next
+  {0x3025, CP_RIGHT,   CP_BOTTOM},     // Finish
+  {0x3026, CP_STRETCH, CP_BOTTOM},     // Line above buttons
+  {    2, CP_RIGHT,   CP_BOTTOM},      // Cancel
+  {0, CP_LEFT, CP_TOP}
 };
 
 static bool IsDialog (HWND hwnd)
Index: site.cc
===================================================================
RCS file: /cvs/cygwin-apps/setup/site.cc,v
retrieving revision 2.31
diff -u -p -r2.31 site.cc
--- site.cc     30 Jul 2003 08:13:09 -0000      2.31
+++ site.cc     1 Nov 2003 03:12:35 -0000
@@ -43,7 +43,24 @@ static const char *cvsid =
 #include "propsheet.h"
 
 #include "threebar.h"
+#include "ControlAdjuster.h"
+
 extern ThreeBarProgressPage Progress;
+
+/*
+  Sizing information.
+ */
+static ControlAdjuster::ControlInfo SiteControlsInfo[] = {
+  {IDC_URL_LIST,               CP_STRETCH, CP_STRETCH},
+  {IDC_EDIT_USER_URL,          CP_STRETCH, CP_BOTTOM},
+  {IDC_BUTTON_ADD_URL,         CP_RIGHT,   CP_BOTTOM},
+  {0, CP_LEFT, CP_TOP}
+};
+
+SitePage::SitePage ()
+{
+  sizeProcessor.AddControlInfo (SiteControlsInfo);
+}
 
 #include "getopt++/StringOption.h"
 #include "UserSettings.h"
Index: site.h
===================================================================
RCS file: /cvs/cygwin-apps/setup/site.h,v
retrieving revision 2.14
diff -u -p -r2.14 site.h
--- site.h      27 Jul 2003 10:29:53 -0000      2.14
+++ site.h      1 Nov 2003 03:12:35 -0000
@@ -27,9 +27,7 @@
 class SitePage:public PropertyPage
 {
 public:
-  SitePage ()
-  {
-  };
+  SitePage ();
   virtual ~ SitePage ()
   {
   };
Index: threebar.cc
===================================================================
RCS file: /cvs/cygwin-apps/setup/threebar.cc,v
retrieving revision 2.7
diff -u -p -r2.7 threebar.cc
--- threebar.cc 30 Jul 2003 21:49:53 -0000      2.7
+++ threebar.cc 1 Nov 2003 03:12:35 -0000
@@ -28,6 +28,29 @@
 #include "cistring.h"
 #include "state.h"
 
+#include "ControlAdjuster.h"
+
+/*
+  Sizing information.
+ */
+static ControlAdjuster::ControlInfo ThreeBarControlsInfo[] = {
+  {IDC_INS_ACTION,             CP_LEFT,    CP_TOP},
+  {IDC_INS_PKG,                CP_LEFT,    CP_TOP},
+  {IDC_INS_FILE,               CP_LEFT,    CP_TOP},
+  {IDC_INS_DISKFULL,           CP_STRETCH, CP_TOP},
+  {IDC_INS_IPROGRESS,          CP_STRETCH, CP_TOP},
+  {IDC_INS_PPROGRESS,          CP_STRETCH, CP_TOP},
+  {IDC_INS_BL_PACKAGE,                 CP_LEFT,    CP_TOP},
+  {IDC_INS_BL_TOTAL,           CP_LEFT,    CP_TOP},
+  {IDC_INS_BL_DISK,            CP_LEFT,    CP_TOP},
+  {0, CP_LEFT, CP_TOP}
+};
+
+ThreeBarProgressPage::ThreeBarProgressPage ()
+{
+  sizeProcessor.AddControlInfo (ThreeBarControlsInfo);
+}
+
 bool ThreeBarProgressPage::Create ()
 {
   return PropertyPage::Create (IDD_INSTATUS);
Index: threebar.h
===================================================================
RCS file: /cvs/cygwin-apps/setup/threebar.h,v
retrieving revision 2.6
diff -u -p -r2.6 threebar.h
--- threebar.h  23 Jun 2003 20:49:00 -0000      2.6
+++ threebar.h  1 Nov 2003 03:12:35 -0000
@@ -53,9 +53,7 @@ class ThreeBarProgressPage:public Proper
   void EnableSingleBar (bool enable = true);
 
 public:
-    ThreeBarProgressPage ()
-  {
-  };
+  ThreeBarProgressPage ();
   virtual ~ ThreeBarProgressPage ()
   {
   };

Reply via email to