diff options
Diffstat (limited to 'src/gui/window.c')
-rw-r--r-- | src/gui/window.c | 23 |
1 files changed, 16 insertions, 7 deletions
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 @@ | |||
1 | #include <stdlib.h> | 1 | #include <stdlib.h> |
2 | #include <gui/window.h> | 2 | #include <gui/window.h> |
3 | #include <common/mem.h> | 3 | #include "gui/window.h" |
4 | #include "common/mem.h" | ||
4 | #include "string.h" | 5 | #include "string.h" |
5 | #include "assert.h" | 6 | #include "assert.h" |
7 | #include "MLV/MLV_window.h" | ||
6 | 8 | ||
7 | void window_init(Window *window, int width, int height, char *title) { | 9 | void window_init(Window *window, int width, int height, char *title) { |
8 | window = malloc_or_die(sizeof(window)); | ||
9 | assert(width > 0); | 10 | assert(width > 0); |
10 | assert(height > 0); | 11 | assert(height > 0); |
11 | window->width = width; | 12 | window->width = width; |
12 | window->height = height; | 13 | window->height = height; |
13 | assert(title != NULL); | 14 | assert(title != NULL); |
14 | strcpy(window->title,title); | 15 | window->title = malloc_or_die(sizeof(char) * (strlen(title) + 1)); |
16 | strcpy(window->title, title); | ||
15 | window->group_buttons = malloc_or_die(sizeof(Group)); | 17 | window->group_buttons = malloc_or_die(sizeof(Group)); |
18 | group_init(window->group_buttons, 5); | ||
16 | window->group_pictureframe = malloc_or_die(sizeof(Group)); | 19 | window->group_pictureframe = malloc_or_die(sizeof(Group)); |
20 | group_init(window->group_pictureframe, 5); | ||
17 | } | 21 | } |
18 | 22 | ||
19 | void window_free(Window *window) { | 23 | void window_free(Window *window) { |
24 | free(window->title); | ||
20 | group_free(window->group_buttons); | 25 | group_free(window->group_buttons); |
21 | group_free(window->group_pictureframe); | 26 | group_free(window->group_pictureframe); |
22 | } | 27 | } |
23 | 28 | ||
24 | void window_add_button(Window *window, Component *component){ | 29 | void window_add_button(Window *window, Component *component) { |
25 | group_add_component(window->group_buttons,component); | 30 | group_add_component(window->group_buttons, component); |
26 | } | 31 | } |
27 | 32 | ||
28 | void window_add_pictureframe(Window *window, Component *component){ | 33 | void window_add_pictureframe(Window *window, Component *component) { |
29 | group_add_component(window->group_pictureframe,component); | 34 | group_add_component(window->group_pictureframe, component); |
35 | } | ||
36 | |||
37 | void window_create(Window *window) { | ||
38 | MLV_create_window(window->title, window->title, (unsigned int) window->width, (unsigned int) window->height); | ||
30 | } \ No newline at end of file | 39 | } \ No newline at end of file |