diff options
Diffstat (limited to 'src/gui/window.c')
-rw-r--r-- | src/gui/window.c | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/src/gui/window.c b/src/gui/window.c new file mode 100644 index 0000000..6e287e5 --- /dev/null +++ b/src/gui/window.c | |||
@@ -0,0 +1,60 @@ | |||
1 | #include <stdlib.h> | ||
2 | #include <gui/window.h> | ||
3 | #include <gui/button.h> | ||
4 | #include <gui/pictureframe.h> | ||
5 | #include <gui/group.h> | ||
6 | #include "common/mem.h" | ||
7 | #include "string.h" | ||
8 | #include "assert.h" | ||
9 | #include "MLV/MLV_window.h" | ||
10 | |||
11 | void window_init(Window *window, int width, int height, char *title) { | ||
12 | assert(window != NULL); | ||
13 | assert(width > 0); | ||
14 | assert(height > 0); | ||
15 | assert(title != NULL); | ||
16 | window->width = width; | ||
17 | window->height = height; | ||
18 | window->title = malloc_or_die(sizeof(char) * (strlen(title) + 1)); | ||
19 | strcpy(window->title, title); | ||
20 | window->group_buttons = malloc_or_die(sizeof(Group)); | ||
21 | group_init(window->group_buttons, window->width, 100, 0, window->height - 100, 5); | ||
22 | window->group_pictureframe = malloc_or_die(sizeof(Group)); | ||
23 | group_init(window->group_pictureframe, window->width, window->height - 100, 0, 0, 5); | ||
24 | } | ||
25 | |||
26 | void window_free(Window *window) { | ||
27 | assert(window != NULL); | ||
28 | free(window->title); | ||
29 | group_free(window->group_buttons); | ||
30 | group_free(window->group_pictureframe); | ||
31 | } | ||
32 | |||
33 | void window_add_button(Window *window, Button *button) { | ||
34 | assert(window != NULL); | ||
35 | assert(button != NULL); | ||
36 | group_add_component(window->group_buttons, &(button->component)); | ||
37 | } | ||
38 | |||
39 | void window_add_pictureframe(Window *window, PictureFrame *pictureFrame) { | ||
40 | assert(window != NULL); | ||
41 | assert(pictureFrame != NULL); | ||
42 | group_add_component(window->group_pictureframe, &(pictureFrame->component)); | ||
43 | } | ||
44 | |||
45 | void window_create(Window *window) { | ||
46 | assert(window != NULL); | ||
47 | MLV_create_window(window->title, window->title, (unsigned int) window->width, (unsigned int) window->height); | ||
48 | } | ||
49 | |||
50 | void window_print_buttons(Window *window) { | ||
51 | assert(window != NULL); | ||
52 | window->group_buttons->component.print_method(&(window->group_buttons->component)); | ||
53 | MLV_actualise_window(); | ||
54 | } | ||
55 | |||
56 | void window_print_pictureframes(Window *window) { | ||
57 | assert(window != NULL); | ||
58 | window->group_pictureframe->component.print_method(&(window->group_pictureframe->component)); | ||
59 | MLV_actualise_window(); | ||
60 | } \ No newline at end of file | ||