changeset 1572:e6a2e6405d30

Added estimation of container contents on GTK2.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Sun, 22 Jan 2012 12:30:20 +0000
parents 5371dbfc2262
children d6e17c8f4de2
files gtk/dw.c
diffstat 1 files changed, 14 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/gtk/dw.c	Sun Jan 22 10:27:18 2012 +0000
+++ b/gtk/dw.c	Sun Jan 22 12:30:20 2012 +0000
@@ -10023,6 +10023,7 @@
 void _get_scrolled_size(GtkWidget *item, gint *thiswidth, gint *thisheight)
 {
    GtkWidget *widget = gtk_object_get_user_data(GTK_OBJECT(item));
+   static char testtext[] = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
 
    /* Try to figure out the contents for Listbox and Container */
    if(widget && (GTK_IS_LIST(widget) || GTK_IS_CLIST(widget)))
@@ -10033,6 +10034,19 @@
       
       *thiswidth = req.width + 20;
       *thisheight = req.height + 20;
+      
+      if(GTK_IS_CLIST(widget))
+      {
+         gint rowcount = GPOINTER_TO_INT(gtk_object_get_data(GTK_OBJECT(widget), "_dw_rowcount"));
+         
+         if(rowcount)
+         {
+            int height = 0;
+            
+            dw_font_text_extents_get(item, NULL, testtext, NULL, &height);
+            *thisheight += rowcount * height;
+         }
+      }
    }
    /* Try to figure out the contents for MLE */
    else if(widget && GTK_IS_TEXT_VIEW(widget))
@@ -10042,7 +10056,6 @@
       char *buf, *ptr;
       int basicwidth;
       int wrap = (gtk_text_view_get_wrap_mode(GTK_TEXT_VIEW(widget)) == GTK_WRAP_WORD);
-      static char testtext[] = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
       
       *thisheight = 20;
       basicwidth = *thiswidth = 20;