summaryrefslogtreecommitdiff
path: root/src/gui/window.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui/window.c')
-rw-r--r--src/gui/window.c32
1 files changed, 25 insertions, 7 deletions
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 @@
1#include <stdlib.h> 1#include <stdlib.h>
2#include <gui/window.h> 2#include <gui/window.h>
3#include <gui/button.h>
4#include <gui/pictureframe.h>
3#include <gui/group.h> 5#include <gui/group.h>
4#include <gui/component.h>
5#include "gui/window.h"
6#include "common/mem.h" 6#include "common/mem.h"
7#include "string.h" 7#include "string.h"
8#include "assert.h" 8#include "assert.h"
@@ -12,9 +12,9 @@ void window_init(Window *window, int width, int height, char *title) {
12 assert(window != NULL); 12 assert(window != NULL);
13 assert(width > 0); 13 assert(width > 0);
14 assert(height > 0); 14 assert(height > 0);
15 assert(title != NULL);
15 window->width = width; 16 window->width = width;
16 window->height = height; 17 window->height = height;
17 assert(title != NULL);
18 window->title = malloc_or_die(sizeof(char) * (strlen(title) + 1)); 18 window->title = malloc_or_die(sizeof(char) * (strlen(title) + 1));
19 strcpy(window->title, title); 19 strcpy(window->title, title);
20 window->group_buttons = malloc_or_die(sizeof(Group)); 20 window->group_buttons = malloc_or_die(sizeof(Group));
@@ -24,19 +24,37 @@ void window_init(Window *window, int width, int height, char *title) {
24} 24}
25 25
26void window_free(Window *window) { 26void window_free(Window *window) {
27 assert(window != NULL);
27 free(window->title); 28 free(window->title);
28 group_free(window->group_buttons); 29 group_free(window->group_buttons);
29 group_free(window->group_pictureframe); 30 group_free(window->group_pictureframe);
30} 31}
31 32
32void window_add_button(Window *window, Component *component) { 33void window_add_button(Window *window, Button *button) {
33 group_add_component(window->group_buttons, component); 34 assert(window != NULL);
35 assert(button != NULL);
36 group_add_component(window->group_buttons, &(button->component));
34} 37}
35 38
36void window_add_pictureframe(Window *window, Component *component) { 39void window_add_pictureframe(Window *window, PictureFrame *pictureFrame) {
37 group_add_component(window->group_pictureframe, component); 40 assert(window != NULL);
41 assert(pictureFrame != NULL);
42 group_add_component(window->group_pictureframe, &(pictureFrame->component));
38} 43}
39 44
40void window_create(Window *window) { 45void window_create(Window *window) {
46 assert(window != NULL);
41 MLV_create_window(window->title, window->title, (unsigned int) window->width, (unsigned int) window->height); 47 MLV_create_window(window->title, window->title, (unsigned int) window->width, (unsigned int) window->height);
48}
49
50void 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
56void window_print_pictureframes(Window *window) {
57 assert(window != NULL);
58 window->group_pictureframe->component.print_method(&(window->group_pictureframe->component));
59 MLV_actualise_window();
42} \ No newline at end of file 60} \ No newline at end of file