comparison gtk/dw.c @ 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 c3e08322b8f6
comparison
equal deleted inserted replaced
1571:5371dbfc2262 1572:e6a2e6405d30
10021 10021
10022 /* Internal function to get the recommended size of scrolled items */ 10022 /* Internal function to get the recommended size of scrolled items */
10023 void _get_scrolled_size(GtkWidget *item, gint *thiswidth, gint *thisheight) 10023 void _get_scrolled_size(GtkWidget *item, gint *thiswidth, gint *thisheight)
10024 { 10024 {
10025 GtkWidget *widget = gtk_object_get_user_data(GTK_OBJECT(item)); 10025 GtkWidget *widget = gtk_object_get_user_data(GTK_OBJECT(item));
10026 static char testtext[] = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
10026 10027
10027 /* Try to figure out the contents for Listbox and Container */ 10028 /* Try to figure out the contents for Listbox and Container */
10028 if(widget && (GTK_IS_LIST(widget) || GTK_IS_CLIST(widget))) 10029 if(widget && (GTK_IS_LIST(widget) || GTK_IS_CLIST(widget)))
10029 { 10030 {
10030 GtkRequisition req; 10031 GtkRequisition req;
10031 10032
10032 gtk_widget_size_request(widget, &req); 10033 gtk_widget_size_request(widget, &req);
10033 10034
10034 *thiswidth = req.width + 20; 10035 *thiswidth = req.width + 20;
10035 *thisheight = req.height + 20; 10036 *thisheight = req.height + 20;
10037
10038 if(GTK_IS_CLIST(widget))
10039 {
10040 gint rowcount = GPOINTER_TO_INT(gtk_object_get_data(GTK_OBJECT(widget), "_dw_rowcount"));
10041
10042 if(rowcount)
10043 {
10044 int height = 0;
10045
10046 dw_font_text_extents_get(item, NULL, testtext, NULL, &height);
10047 *thisheight += rowcount * height;
10048 }
10049 }
10036 } 10050 }
10037 /* Try to figure out the contents for MLE */ 10051 /* Try to figure out the contents for MLE */
10038 else if(widget && GTK_IS_TEXT_VIEW(widget)) 10052 else if(widget && GTK_IS_TEXT_VIEW(widget))
10039 { 10053 {
10040 unsigned long bytes; 10054 unsigned long bytes;
10041 int height, width; 10055 int height, width;
10042 char *buf, *ptr; 10056 char *buf, *ptr;
10043 int basicwidth; 10057 int basicwidth;
10044 int wrap = (gtk_text_view_get_wrap_mode(GTK_TEXT_VIEW(widget)) == GTK_WRAP_WORD); 10058 int wrap = (gtk_text_view_get_wrap_mode(GTK_TEXT_VIEW(widget)) == GTK_WRAP_WORD);
10045 static char testtext[] = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
10046 10059
10047 *thisheight = 20; 10060 *thisheight = 20;
10048 basicwidth = *thiswidth = 20; 10061 basicwidth = *thiswidth = 20;
10049 10062
10050 dw_mle_get_size(item, &bytes, NULL); 10063 dw_mle_get_size(item, &bytes, NULL);