Skip to content
Snippets Groups Projects
Commit 69e2a15e authored by Cedric Roux's avatar Cedric Roux
Browse files

prepare container to deal with growable children

parent 53fd31ef
No related branches found
No related tags found
No related merge requests found
......@@ -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);
}
......@@ -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,
......
......@@ -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 {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment