diff --git a/common/utils/T/tracer/gui/container.c b/common/utils/T/tracer/gui/container.c index 939f75bc555040998b75d6ddc4e220a3a66aa8f8..97cac62066555768a87a4c6b01b0e221bcc4255a 100644 --- a/common/utils/T/tracer/gui/container.c +++ b/common/utils/T/tracer/gui/container.c @@ -2,6 +2,7 @@ #include "gui_defs.h" #include <stdio.h> #include <stdlib.h> +#include <string.h> #define MAX(a, b) ((a)>(b)?(a):(b)) @@ -19,6 +20,19 @@ printf("ADD_CHILD container\n"); struct container_widget *this = _this; this->hints_are_valid = 0; widget_add_child_internal(g, this, child, position); + + /* initially not growable */ + this->growable = realloc(this->growable, (this->nchildren+1)*sizeof(int)); + if (this->growable == NULL) abort(); + + if (position == -1) position = this->nchildren; + + memmove(this->growable + position+1, this->growable + position, + (this->nchildren - position) * sizeof(int)); + + this->growable[position] = 0; + + this->nchildren++; } static void compute_vertical_hints(struct gui *g, @@ -246,3 +260,33 @@ widget *new_container(gui *_gui, int vertical) return w; } + +/*************************************************************************/ +/* public functions */ +/*************************************************************************/ + +void container_set_child_growable(gui *_gui, widget *_this, + widget *child, int growable) +{ + gui *g = _gui; + struct container_widget *this = _this; + struct widget_list *lcur; + int i; + + glock(g); + + lcur = this->common.children; + i = 0; + while (lcur) { + if (lcur->item == child) break; + lcur = lcur->next; + i++; + } + if (lcur == NULL) ERR("%s:%d: child not found\n", __FILE__, __LINE__); + + this->growable[i] = growable; + + send_event(g, DIRTY, this->common.id); + + gunlock(g); +} diff --git a/common/utils/T/tracer/gui/gui.h b/common/utils/T/tracer/gui/gui.h index c1bbbd7d06610b42c4bd60030bafa370fef9e31f..b1440a20c462ddec125bcfe2651f9fe81f97284a 100644 --- a/common/utils/T/tracer/gui/gui.h +++ b/common/utils/T/tracer/gui/gui.h @@ -24,6 +24,9 @@ widget *new_xy_plot(gui *gui, int width, int height, char *label, int vruler_width); widget *new_text_list(gui *_gui, int width, int nlines, int background_color); +void container_set_child_growable(gui *_gui, widget *_this, + widget *child, int growable); + void xy_plot_set_range(gui *gui, widget *this, float xmin, float xmax, float ymin, float ymax); void xy_plot_set_points(gui *gui, widget *this, diff --git a/common/utils/T/tracer/gui/gui_defs.h b/common/utils/T/tracer/gui/gui_defs.h index a80dc247986fccfe09ef89a9f3575c0c3b520b3d..58ae329467b10e710abfffad790aa2ced01b72c2 100644 --- a/common/utils/T/tracer/gui/gui_defs.h +++ b/common/utils/T/tracer/gui/gui_defs.h @@ -69,6 +69,8 @@ struct container_widget { int hints_are_valid; /* used to cache hints values */ int hint_width; /* cached hint values - invalid if */ int hint_height; /* repack_was_called == 1 */ + int *growable; + int nchildren; }; struct text_list_widget {