# HG changeset patch # User bsmith@81767d24-ef19-dc11-ae90-00e081727c95 # Date 1327235420 0 # Node ID e6a2e6405d309179045823856b103991f4e67acc # Parent 5371dbfc2262f791bdb86080a666c5e2e63bde3c Added estimation of container contents on GTK2. diff -r 5371dbfc2262 -r e6a2e6405d30 gtk/dw.c --- 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;