From a7e6f8a296b536966cee49f8de105960970d04c5 Mon Sep 17 00:00:00 2001 From: Adam NAILI Date: Sat, 9 Dec 2017 01:58:10 +0100 Subject: Creating source file window.c --- src/gui/window.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 src/gui/window.c (limited to 'src/gui/window.c') diff --git a/src/gui/window.c b/src/gui/window.c new file mode 100644 index 0000000..2b4c7e0 --- /dev/null +++ b/src/gui/window.c @@ -0,0 +1,13 @@ +#include "gui/window.h" + +void window_init(Window *window, int width, int height, char *title) { +//TODO +} + +void window_free(Window *window) { +//TODO +} + +void window_add_component(Window *window, Component *component) { +//TODO +} -- cgit v1.2.3 From 2aed52d89856847ea394b06d7b70782fa6b21d24 Mon Sep 17 00:00:00 2001 From: Adam NAILI Date: Sun, 10 Dec 2017 13:01:42 +0100 Subject: Implementing init, free, add_button, add_pictureframe functions for window --- src/gui/window.c | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) (limited to 'src/gui/window.c') diff --git a/src/gui/window.c b/src/gui/window.c index 2b4c7e0..bd96050 100644 --- a/src/gui/window.c +++ b/src/gui/window.c @@ -1,13 +1,30 @@ -#include "gui/window.h" +#include +#include +#include +#include "string.h" +#include "assert.h" void window_init(Window *window, int width, int height, char *title) { -//TODO + 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->group_buttons = malloc_or_die(sizeof(Group)); + window->group_pictureframe = malloc_or_die(sizeof(Group)); } void window_free(Window *window) { -//TODO + group_free(window->group_buttons); + group_free(window->group_pictureframe); } -void window_add_component(Window *window, Component *component) { -//TODO +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); +} \ No newline at end of file -- cgit v1.2.3 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 From e96c998be9e867e328d393966a60599dc3c37e3a Mon Sep 17 00:00:00 2001 From: Adam NAILI Date: Tue, 12 Dec 2017 13:18:22 +0100 Subject: Adding asserts, fixing the call of group_init that changed --- src/gui/window.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'src/gui/window.c') diff --git a/src/gui/window.c b/src/gui/window.c index 81af66a..7b5a75f 100644 --- a/src/gui/window.c +++ b/src/gui/window.c @@ -1,5 +1,7 @@ #include #include +#include +#include #include "gui/window.h" #include "common/mem.h" #include "string.h" @@ -7,6 +9,7 @@ #include "MLV/MLV_window.h" void window_init(Window *window, int width, int height, char *title) { + assert(window != NULL); assert(width > 0); assert(height > 0); window->width = width; @@ -15,9 +18,9 @@ void window_init(Window *window, int width, int height, char *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); + group_init(window->group_buttons,window->width,100,0,window->height-100,5); window->group_pictureframe = malloc_or_die(sizeof(Group)); - group_init(window->group_pictureframe, 5); + group_init(window->group_pictureframe,window->width,window->height-100,0,0,5); } void window_free(Window *window) { -- cgit v1.2.3 From a42fdf7d5c9712297f1bbe3dd0951baa8ee32447 Mon Sep 17 00:00:00 2001 From: Adam NAILI Date: Tue, 12 Dec 2017 13:25:56 +0100 Subject: Formatting files --- src/gui/window.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/gui/window.c') diff --git a/src/gui/window.c b/src/gui/window.c index 7b5a75f..2c84aeb 100644 --- a/src/gui/window.c +++ b/src/gui/window.c @@ -18,9 +18,9 @@ void window_init(Window *window, int width, int height, char *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,window->width,100,0,window->height-100,5); + group_init(window->group_buttons, window->width, 100, 0, window->height - 100, 5); window->group_pictureframe = malloc_or_die(sizeof(Group)); - group_init(window->group_pictureframe,window->width,window->height-100,0,0,5); + group_init(window->group_pictureframe, window->width, window->height - 100, 0, 0, 5); } void window_free(Window *window) { -- cgit v1.2.3 From e84ae1203b8cd7a51d93ec77a5a2663e7496eef5 Mon Sep 17 00:00:00 2001 From: Adam NAILI Date: Fri, 22 Dec 2017 19:14:55 +0100 Subject: Adding asserts, modifying signatures of function for more precise type, implementing window_add functions, window_print functions --- src/gui/window.c | 32 +++++++++++++++++++++++++------- 1 file changed, 25 insertions(+), 7 deletions(-) (limited to 'src/gui/window.c') diff --git a/src/gui/window.c b/src/gui/window.c index 2c84aeb..6e287e5 100644 --- a/src/gui/window.c +++ b/src/gui/window.c @@ -1,8 +1,8 @@ #include #include +#include +#include #include -#include -#include "gui/window.h" #include "common/mem.h" #include "string.h" #include "assert.h" @@ -12,9 +12,9 @@ void window_init(Window *window, int width, int height, char *title) { assert(window != NULL); assert(width > 0); assert(height > 0); + assert(title != NULL); window->width = width; window->height = height; - assert(title != NULL); window->title = malloc_or_die(sizeof(char) * (strlen(title) + 1)); strcpy(window->title, title); window->group_buttons = malloc_or_die(sizeof(Group)); @@ -24,19 +24,37 @@ void window_init(Window *window, int width, int height, char *title) { } void window_free(Window *window) { + assert(window != NULL); 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, Button *button) { + assert(window != NULL); + assert(button != NULL); + group_add_component(window->group_buttons, &(button->component)); } -void window_add_pictureframe(Window *window, Component *component) { - group_add_component(window->group_pictureframe, component); +void window_add_pictureframe(Window *window, PictureFrame *pictureFrame) { + assert(window != NULL); + assert(pictureFrame != NULL); + group_add_component(window->group_pictureframe, &(pictureFrame->component)); } void window_create(Window *window) { + assert(window != NULL); MLV_create_window(window->title, window->title, (unsigned int) window->width, (unsigned int) window->height); +} + +void window_print_buttons(Window *window) { + assert(window != NULL); + window->group_buttons->component.print_method(&(window->group_buttons->component)); + MLV_actualise_window(); +} + +void window_print_pictureframes(Window *window) { + assert(window != NULL); + window->group_pictureframe->component.print_method(&(window->group_pictureframe->component)); + MLV_actualise_window(); } \ No newline at end of file -- cgit v1.2.3