From bd3864dda0ca20a2d234bda525e6cd7c21d4f729 Mon Sep 17 00:00:00 2001 From: Adam NAILI Date: Sun, 10 Dec 2017 18:39:27 +0100 Subject: Modification of the implementation of init, free and successful test for the init function (creation of a window with the right parameters) --- src/gui/window.c | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) (limited to 'src/gui/window.c') diff --git a/src/gui/window.c b/src/gui/window.c index bd96050..81af66a 100644 --- a/src/gui/window.c +++ b/src/gui/window.c @@ -1,30 +1,39 @@ #include #include -#include +#include "gui/window.h" +#include "common/mem.h" #include "string.h" #include "assert.h" +#include "MLV/MLV_window.h" void window_init(Window *window, int width, int height, char *title) { - window = malloc_or_die(sizeof(window)); assert(width > 0); assert(height > 0); window->width = width; window->height = height; assert(title != NULL); - strcpy(window->title,title); + window->title = malloc_or_die(sizeof(char) * (strlen(title) + 1)); + strcpy(window->title, title); window->group_buttons = malloc_or_die(sizeof(Group)); + group_init(window->group_buttons, 5); window->group_pictureframe = malloc_or_die(sizeof(Group)); + group_init(window->group_pictureframe, 5); } void window_free(Window *window) { + free(window->title); group_free(window->group_buttons); group_free(window->group_pictureframe); } -void window_add_button(Window *window, Component *component){ - group_add_component(window->group_buttons,component); +void window_add_button(Window *window, Component *component) { + group_add_component(window->group_buttons, component); } -void window_add_pictureframe(Window *window, Component *component){ - group_add_component(window->group_pictureframe,component); +void window_add_pictureframe(Window *window, Component *component) { + group_add_component(window->group_pictureframe, component); +} + +void window_create(Window *window) { + MLV_create_window(window->title, window->title, (unsigned int) window->width, (unsigned int) window->height); } \ No newline at end of file -- cgit v1.2.3