changeset 1570:d6988022c5cf

Implemented listbox sizing on OS/2 and Windows. Mac already works and GTK3 looks like it should from the code but have not tested. Will need to check into GTK2.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Sun, 22 Jan 2012 10:05:16 +0000
parents 866d7d05d425
children 5371dbfc2262
files os2/dw.c win/dw.c
diffstat 2 files changed, 68 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/os2/dw.c	Sat Jan 21 04:42:49 2012 +0000
+++ b/os2/dw.c	Sun Jan 22 10:05:16 2012 +0000
@@ -4784,6 +4784,40 @@
        if(thisheight > _DW_SCROLLED_MAX_HEIGHT)
            thisheight = _DW_SCROLLED_MAX_HEIGHT;
    }
+   /* Listbox */
+   else if(strncmp(tmpbuf, "#7", 3)==0)
+   {
+      char buf[1025] = {0};
+      int x, count = dw_listbox_count(handle);
+      int basicwidth = thiswidth = WinQuerySysValue(HWND_DESKTOP, SV_CXVSCROLL) + 8;
+      
+      thisheight = 8;
+      
+      for(x=0;x<count;x++)
+      {
+         int height, width = 0;
+         
+         dw_listbox_get_text(handle, x, buf, 1024);
+         
+         if(strlen(buf))
+            dw_font_text_extents_get(handle, NULL, buf, &width, &height);
+         else
+            dw_font_text_extents_get(handle, NULL, testtext, NULL, &height);
+        
+         width += basicwidth;
+         
+         if(width > thiswidth)
+            thiswidth = width > _DW_SCROLLED_MAX_WIDTH ? _DW_SCROLLED_MAX_WIDTH : width;
+         thisheight += height;
+      }
+      
+      if(thiswidth < _DW_SCROLLED_MIN_WIDTH)
+         thiswidth = _DW_SCROLLED_MIN_WIDTH;
+      if(thisheight < _DW_SCROLLED_MIN_HEIGHT)
+         thisheight = _DW_SCROLLED_MIN_HEIGHT;
+      if(thisheight > _DW_SCROLLED_MAX_HEIGHT)
+         thisheight = _DW_SCROLLED_MAX_HEIGHT;
+   }
    /* Container and Tree */
    else if(strncmp(tmpbuf, "#37", 4)==0)
    {
--- a/win/dw.c	Sat Jan 21 04:42:49 2012 +0000
+++ b/win/dw.c	Sun Jan 22 10:05:16 2012 +0000
@@ -4506,6 +4506,40 @@
       thiswidth = 50;
       extraheight = 6;
    }
+   /* Listbox */
+   else if(strnicmp(tmpbuf, LISTBOXCLASSNAME, strlen(LISTBOXCLASSNAME)+1) == 0)
+   {
+      char buf[1025] = {0};
+      int x, count = dw_listbox_count(handle);
+      int basicwidth = thiswidth = GetSystemMetrics(SM_CXVSCROLL) + 8;
+      
+      thisheight = 8;
+      
+      for(x=0;x<count;x++)
+      {
+         int height, width = 0;
+         
+         dw_listbox_get_text(handle, x, buf, 1024);
+         
+         if(strlen(buf))
+            dw_font_text_extents_get(handle, NULL, buf, &width, &height);
+         else
+            dw_font_text_extents_get(handle, NULL, testtext, NULL, &height);
+        
+         width += basicwidth;
+         
+         if(width > thiswidth)
+            thiswidth = width > _DW_SCROLLED_MAX_WIDTH ? _DW_SCROLLED_MAX_WIDTH : width;
+         thisheight += height;
+      }
+      
+      if(thiswidth < _DW_SCROLLED_MIN_WIDTH)
+         thiswidth = _DW_SCROLLED_MIN_WIDTH;
+      if(thisheight < _DW_SCROLLED_MIN_HEIGHT)
+         thisheight = _DW_SCROLLED_MIN_HEIGHT;
+      if(thisheight > _DW_SCROLLED_MAX_HEIGHT)
+         thisheight = _DW_SCROLLED_MAX_HEIGHT;
+   }
    /* Entryfields and MLE */
    else if(strnicmp(tmpbuf, EDITCLASSNAME, strlen(EDITCLASSNAME)+1) == 0 ||
            strnicmp(tmpbuf, RICHEDIT_CLASS, strlen(RICHEDIT_CLASS)+1) == 0)