diff options
author | Adam NAILI | 2017-12-22 19:14:55 +0100 |
---|---|---|
committer | Adam NAILI | 2017-12-22 19:14:55 +0100 |
commit | e84ae1203b8cd7a51d93ec77a5a2663e7496eef5 (patch) | |
tree | d36be9a638c10833c94a7e3fa9d17f3e6fec4d8a | |
parent | 629928d374812c69392879a6c4aca5d6479c33cb (diff) | |
download | morpher-e84ae1203b8cd7a51d93ec77a5a2663e7496eef5.tar.gz |
Adding asserts, modifying signatures of function for more precise type, implementing window_add functions, window_print functions
-rw-r--r-- | include/gui/window.h | 10 | ||||
-rw-r--r-- | src/gui/window.c | 32 |
2 files changed, 31 insertions, 11 deletions
diff --git a/include/gui/window.h b/include/gui/window.h index 3212a49..329997b 100644 --- a/include/gui/window.h +++ b/include/gui/window.h | |||
@@ -11,6 +11,8 @@ | |||
11 | 11 | ||
12 | #include "group.h" | 12 | #include "group.h" |
13 | #include "component.h" | 13 | #include "component.h" |
14 | #include "button.h" | ||
15 | #include "pictureframe.h" | ||
14 | 16 | ||
15 | /** | 17 | /** |
16 | * Struct: Window | 18 | * Struct: Window |
@@ -57,9 +59,9 @@ void window_free(Window *window); | |||
57 | * | 59 | * |
58 | * Parameters: | 60 | * Parameters: |
59 | * *window - pointer to the input window | 61 | * *window - pointer to the input window |
60 | * *component - pointer to the input component | 62 | * *button - pointer to the input button |
61 | */ | 63 | */ |
62 | void window_add_button(Window *window, Component *component); | 64 | void window_add_button(Window *window, Button *button); |
63 | 65 | ||
64 | /** | 66 | /** |
65 | * Function: window_add_pictureframe | 67 | * Function: window_add_pictureframe |
@@ -67,9 +69,9 @@ void window_add_button(Window *window, Component *component); | |||
67 | * | 69 | * |
68 | * Parameters: | 70 | * Parameters: |
69 | * *window - pointer to the input window | 71 | * *window - pointer to the input window |
70 | * *component - pointer to the input component | 72 | * *pictureFrame - pointer to the input picture frame |
71 | */ | 73 | */ |
72 | void window_add_pictureframe(Window *window, Component *component); | 74 | void window_add_pictureframe(Window *window, PictureFrame *pictureFrame); |
73 | 75 | ||
74 | /** | 76 | /** |
75 | * Function: window_create | 77 | * Function: window_create |
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 | ||
26 | void window_free(Window *window) { | 26 | void 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 | ||
32 | void window_add_button(Window *window, Component *component) { | 33 | void 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 | ||
36 | void window_add_pictureframe(Window *window, Component *component) { | 39 | void 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 | ||
40 | void window_create(Window *window) { | 45 | void 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 | |||
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(); | ||
42 | } \ No newline at end of file | 60 | } \ No newline at end of file |