changeset 1387:db27c6e139a3

Fixed dw_container_optimize() on Windows was not calculating things correctly. The first column could be undersized due to an invalid check after adding icon padding.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Sat, 26 Nov 2011 00:09:07 +0000
parents fd1de4e9e542
children 8fe15c1648c9
files win/dw.c
diffstat 1 files changed, 15 insertions(+), 22 deletions(-) [+]
line wrap: on
line diff
--- a/win/dw.c	Fri Nov 25 21:13:12 2011 +0000
+++ b/win/dw.c	Sat Nov 26 00:09:07 2011 +0000
@@ -8730,33 +8730,26 @@
       {
          for(z=0;z<cinfo->columns;z++)
          {
-            LV_ITEM lvi;
-
-            memset(&lvi, 0, sizeof(LV_ITEM));
-
-            lvi.iItem = index;
-            lvi.iSubItem = z;
-            lvi.mask = LVIF_TEXT;
-            lvi.cchTextMax = 1023;
-            lvi.pszText = text;
-
-            if(ListView_GetItem(handle, &lvi))
-            {
-               int width = ListView_GetStringWidth(handle, lvi.pszText);
-               if(width > columns[z])
-               {
-                  if(z == 0)
-                     columns[z] = width + 20;
-                  else
-                     columns[z] = width;
-               }
-            }
+            int width;
+            
+            ListView_GetItemText(handle, index, z, text, 1023);
+            width = ListView_GetStringWidth(handle, text);
+
+            /* Figure extra space for the icon for the first column */
+            if(z == 0)
+               width += 20;
+
+            if(width > columns[z])
+               columns[z] = width;
          }
 
          index = ListView_GetNextItem(handle, index, LVNI_ALL);
       }
 
-      /* Set the new sizes */
+      /* Set the new sizes... Microsoft says we need to add
+       * padding to the calculated sized but does not give 
+       * a value.  Trial and error shows that 16 works for us.
+       */
       for(z=0;z<cinfo->columns;z++)
          ListView_SetColumnWidth(handle, z, columns[z] + 16);