comparison console/libgnt/gntbox.c @ 13853:bbf0470cb348

[gaim-migrate @ 16312] Improvement/fixing of GntTree. Do the scrolling and stuff without 'reliably'. committer: Tailor Script <tailor@pidgin.im>
author Sadrul Habib Chowdhury <imadil@gmail.com>
date Fri, 23 Jun 2006 00:45:45 +0000
parents 0e1e59770cb0
children a4c30c1d9de8
comparison
equal deleted inserted replaced
13852:d95e5e0e29b9 13853:bbf0470cb348
29 g_utf8_strncpy(title, box->title, widget->priv.width - 2); 29 g_utf8_strncpy(title, box->title, widget->priv.width - 2);
30 pos = 1; 30 pos = 1;
31 } 31 }
32 else 32 else
33 { 33 {
34 /* XXX: Position of the title might be configurable */
34 pos = (widget->priv.width - pos - 2) / 2; 35 pos = (widget->priv.width - pos - 2) / 2;
35 /*pos = 2;*/
36 } 36 }
37 wbkgdset(widget->window, '\0' | COLOR_PAIR(GNT_COLOR_TITLE)); 37 wbkgdset(widget->window, '\0' | COLOR_PAIR(GNT_COLOR_TITLE));
38 mvwprintw(widget->window, 0, pos, title); 38 mvwprintw(widget->window, 0, pos, title);
39 g_free(title); 39 g_free(title);
40 } 40 }
50 GntBox *box = GNT_BOX(widget); 50 GntBox *box = GNT_BOX(widget);
51 int w, h, curx, cury, max; 51 int w, h, curx, cury, max;
52 gboolean has_border = FALSE; 52 gboolean has_border = FALSE;
53 int x, y; 53 int x, y;
54 54
55 x = widget->priv.x;
56 y = widget->priv.y;
57 w = h = 0; 55 w = h = 0;
58 max = -1; 56 max = -1;
59 curx = widget->priv.x; 57 curx = widget->priv.x + 1;
60 cury = widget->priv.y; 58 cury = widget->priv.y + 1;
61 if (!(GNT_WIDGET_FLAGS(widget) & GNT_WIDGET_NO_BORDER)) 59 if (!(GNT_WIDGET_FLAGS(widget) & GNT_WIDGET_NO_BORDER))
62 { 60 {
63 has_border = TRUE; 61 has_border = TRUE;
64 curx += 1; 62 curx += box->pad;
65 cury += 1; 63 cury += box->pad;
66 if (!box->vertical) 64 if (!box->vertical)
67 curx++; 65 curx++;
68 } 66 }
69 67
70 for (iter = box->list; iter; iter = iter->next) 68 for (iter = box->list; iter; iter = iter->next)
71 { 69 {
72 gnt_widget_set_position(GNT_WIDGET(iter->data), curx, cury); 70 gnt_widget_set_position(GNT_WIDGET(iter->data), curx, cury);
73 gnt_widget_get_size(GNT_WIDGET(iter->data), &w, &h); 71 gnt_widget_get_size(GNT_WIDGET(iter->data), &w, &h);
74 if (box->vertical) 72 if (box->vertical)
75 { 73 {
76 cury += h + 1; 74 cury += h + box->pad;
77 if (max < w) 75 if (max < w)
78 max = w; 76 max = w;
79 } 77 }
80 else 78 else
81 { 79 {
82 curx += w + 2; 80 curx += w + box->pad;
83 if (max < h) 81 if (max < h)
84 max = h; 82 max = h;
85 } 83 }
86 } 84 }
87 85
301 GntWidget *widget = g_object_new(GNT_TYPE_BOX, NULL); 299 GntWidget *widget = g_object_new(GNT_TYPE_BOX, NULL);
302 GntBox *box = GNT_BOX(widget); 300 GntBox *box = GNT_BOX(widget);
303 301
304 box->homogeneous = homo; 302 box->homogeneous = homo;
305 box->vertical = vert; 303 box->vertical = vert;
304 box->pad = 1;
306 gnt_widget_set_take_focus(widget, TRUE); 305 gnt_widget_set_take_focus(widget, TRUE);
307 GNT_WIDGET_SET_FLAGS(widget, GNT_WIDGET_NO_BORDER | GNT_WIDGET_NO_SHADOW); 306 GNT_WIDGET_SET_FLAGS(widget, GNT_WIDGET_NO_BORDER | GNT_WIDGET_NO_SHADOW);
308 307
309 return widget; 308 return widget;
310 } 309 }
319 { 318 {
320 g_free(b->title); 319 g_free(b->title);
321 b->title = g_strdup(title); 320 b->title = g_strdup(title);
322 } 321 }
323 322
323 void gnt_box_set_pad(GntBox *box, int pad)
324 {
325 box->pad = pad;
326 /* XXX: Perhaps redraw if already showing? */
327 }
328