This is the mail archive of the cygwin-apps mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Incidental setup.exe patches #2: Fix chooser vertical scroll bar.



    Hi,

  Here's another one I noticed: the vertical scroll bar doesn't get adjusted
when you resize the chooser vertically.  It does get reproportioned correctly
when you click anywhere in the chooser (or change mode or do anything that
triggers a full redraw), and this patch factors out the code to adjust it into
a routine that can be called from both clicks and resize operations.  While
it's doing that, it clears up a bit of naming confusion where variables with
names relating to "ClientRect" are used to store details that are actually
those returned from GetWindowRect(); I figured that would look doubly
confusing when I went and introduced an actual GetClientRect() call in the
same area if I didn't clean it up.

	* PickView.h (PickView::set_vscroll_info): Add prototype.
	(PickView::hasClientRect): Rename from this ...
	(PickView::hasWindowRect): ... to this ...
	(PickView::lastClientRect): ... and from this ...
	(PickView::lastWindowRect): ... to this.

	* PickView.cc (PickView::PickView): Adjust member init to match.
	(PickView::set_vscroll_info): Abstract code to set vertical scroll
	bar proportions from ...
	(PickView::list_click): ... here.  Call it.  Fix comment typo.
	(PickView::WindowProc): Update all renamed variables in WM_SIZE
	case, and check also for a y delta, calling set_vscroll_info if so.

  OK?

    cheers,
      DaveK

Index: PickView.h
===================================================================
RCS file: /cvs/cygwin-apps/setup/PickView.h,v
retrieving revision 2.19
diff -u -p -r2.19 PickView.h
--- PickView.h	1 Jul 2009 07:50:07 -0000	2.19
+++ PickView.h	12 Apr 2010 21:34:59 -0000
@@ -51,6 +51,7 @@ public:
   LRESULT CALLBACK list_click (HWND hwnd, BOOL dblclk, int x, int y, UINT hitCode);
   LRESULT CALLBACK list_hscroll (HWND hwnd, HWND hctl, UINT code, int pos);
   LRESULT CALLBACK list_vscroll (HWND hwnd, HWND hctl, UINT code, int pos);
+  void set_vscroll_info (const RECT &r);
   virtual LRESULT WindowProc (UINT uMsg, WPARAM wParam, LPARAM lParam);
   Header *headers;
   PickView (Category & cat);
@@ -146,8 +147,8 @@ private:
   std::string packageFilterString;
 
   // Stuff needed to handle resizing
-  bool hasClientRect;
-  RECTWrapper lastClientRect;
+  bool hasWindowRect;
+  RECTWrapper lastWindowRect;
   int total_delta_x;
 
   int set_header_column_order (views vm);
Index: PickView.cc
===================================================================
RCS file: /cvs/cygwin-apps/setup/PickView.cc,v
retrieving revision 2.36
diff -u -p -r2.36 PickView.cc
--- PickView.cc	13 Dec 2009 19:23:43 -0000	2.36
+++ PickView.cc	12 Apr 2010 21:34:59 -0000
@@ -527,7 +527,7 @@ PickView::init_headers (HDC dc)
 
 PickView::PickView (Category &cat) : deftrust (TRUST_UNKNOWN),
 contents (*this, cat, 0, false, true), showObsolete (false), 
-packageFilterString (), hasClientRect (false), total_delta_x (0)
+packageFilterString (), hasWindowRect (false), total_delta_x (0)
 {
 }
 
@@ -668,6 +668,28 @@ PickView::list_hscroll (HWND hwnd, HWND 
   return 0;
 }
 
+void
+PickView::set_vscroll_info (const RECT &r)
+{
+  SCROLLINFO si;
+  memset (&si, 0, sizeof (si));
+  si.cbSize = sizeof (si);
+  si.fMask = SIF_ALL | SIF_DISABLENOSCROLL;    /* SIF_RANGE was giving strange behaviour */
+  si.nMin = 0;
+
+  si.nMax = contents.itemcount () * row_height;
+  si.nPage = r.bottom - header_height;
+
+  /* if we are under the minimum display count ,
+   * set the offset to 0
+   */
+  if ((unsigned int) si.nMax <= si.nPage)
+    scroll_ulc_y = 0;
+  si.nPos = scroll_ulc_y;
+
+  SetScrollInfo (GetHWND(), SB_VERT, &si, TRUE);
+}
+
 LRESULT CALLBACK
 PickView::list_click (HWND hwnd, BOOL dblclk, int x, int y, UINT hitCode)
 {
@@ -688,31 +710,14 @@ PickView::list_click (HWND hwnd, BOOL db
 
   refresh = click (row, x);
 
-  // XXX we need a method to queryt he database to see if more
+  // XXX we need a method to query the database to see if more
   // than just one package has changed! Until then...
 #if 0
   if (refresh)
     {
 #endif
       RECT r = GetClientRect ();
-      SCROLLINFO si;
-      memset (&si, 0, sizeof (si));
-      si.cbSize = sizeof (si);
-      si.fMask = SIF_ALL | SIF_DISABLENOSCROLL;    /* SIF_RANGE was giving strange behaviour */
-      si.nMin = 0;
-
-      si.nMax = contents.itemcount () * row_height;
-      si.nPage = r.bottom - header_height;
-
-      /* if we are under the minimum display count ,
-       * set the offset to 0
-       */
-      if ((unsigned int) si.nMax <= si.nPage)
-        scroll_ulc_y = 0;
-      si.nPos = scroll_ulc_y;
-
-      SetScrollInfo (GetHWND(), SB_VERT, &si, TRUE);
-
+      set_vscroll_info (r);
       InvalidateRect (GetHWND(), &r, TRUE);
 #if 0
     }
@@ -812,12 +817,12 @@ PickView::WindowProc (UINT message, WPAR
     case WM_SIZE:
       {
         // Note: WM_SIZE msgs only appear when 'just' scrolling the window
-        RECT clientRect = GetWindowRect ();
-        if (hasClientRect)
+        RECT windowRect = GetWindowRect ();
+        if (hasWindowRect)
           {
             int dx;
-            if ((dx = clientRect.right - clientRect.left -
-                        lastClientRect.width ()) != 0)
+            if ((dx = windowRect.right - windowRect.left -
+                        lastWindowRect.width ()) != 0)
               {
                 cat_headers[set_header_column_order (views::Category)].width += dx;
                 pkg_headers[set_header_column_order (views::Package)].width += dx;
@@ -828,11 +833,13 @@ PickView::WindowProc (UINT message, WPAR
                             headers[last_col].width, header_height, TRUE);
                 total_delta_x += dx;
               }
+	    if (windowRect.right - windowRect.left - lastWindowRect.width ())
+	      set_vscroll_info (GetClientRect ());
           }
         else
-          hasClientRect = true;
+          hasWindowRect = true;
   
-        lastClientRect = clientRect;
+        lastWindowRect = windowRect;
         return 0;     
       }
     }

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]