From 26bb3df365ed43dd415be8ac870da8ac8991b425 Mon Sep 17 00:00:00 2001 From: Adam NAILI Date: Tue, 12 Dec 2017 13:13:24 +0100 Subject: Adding beta version of print function, working on implementation of the linked list (add + free) --- src/gui/group.c | 37 ++++++++++++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/src/gui/group.c b/src/gui/group.c index dc48c50..ac2c440 100644 --- a/src/gui/group.c +++ b/src/gui/group.c @@ -1,11 +1,31 @@ #include #include +#include +#include +#include "MLV/MLV_shape.h" +#include "MLV/MLV_window.h" + +void group_print(void *parameter) { + Group *group = (Group *) parameter; + /*DEBUG*/ + MLV_draw_filled_rectangle(group->component.x_pos, group->component.y_pos, group->component.width, + group->component.height, MLV_COLOR_AQUAMARINE); + /**/ + MLV_actualise_window(); +} void group_init(Group *group, int width, int height, int x_pos, int y_pos, int padding) { + assert(group != NULL); + assert(width>0); + assert(height>0); + assert(x_pos>=0); + assert(y_pos>=0); + assert(padding>=0); group->component.width = width; group->component.height = height; group->component.x_pos = x_pos; group->component.y_pos = y_pos; + group->component.print_method = group_print; group->padding = padding; } @@ -22,5 +42,20 @@ void group_free(Group *group) { } void group_add_component(Group *group, Component *component) { - + if (group->group_head != NULL) { + /*Initialize the new node*/ + GroupElement *tmp = malloc_or_die(sizeof(GroupElement)); + tmp->sub_component = component; + tmp->next = NULL; + GroupElement *p = group->group_head; + /*Browsing*/ + while (p->next != NULL) { + p = p->next; + } + p->next = tmp; + } else { + group->group_head = malloc_or_die(sizeof(GroupElement)); + group->group_head->sub_component = component; + group->group_head->next = NULL; + } } \ No newline at end of file -- cgit v1.2.3