diff options
author | Adam NAILI | 2017-12-12 13:13:24 +0100 |
---|---|---|
committer | Adam NAILI | 2017-12-12 13:17:06 +0100 |
commit | 26bb3df365ed43dd415be8ac870da8ac8991b425 (patch) | |
tree | 4220642c299f1d9758a4b1acb74cf9b9ebf3cccf /src/gui | |
parent | 45800d79fb2fd74542daeda29e2cb2467f46399a (diff) | |
download | morpher-26bb3df365ed43dd415be8ac870da8ac8991b425.tar.gz |
Adding beta version of print function, working on implementation of the linked list (add + free)
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/group.c | 37 |
1 files changed, 36 insertions, 1 deletions
diff --git a/src/gui/group.c b/src/gui/group.c index dc48c50..ac2c440 100644 --- a/src/gui/group.c +++ b/src/gui/group.c | |||
@@ -1,11 +1,31 @@ | |||
1 | #include <stdlib.h> | 1 | #include <stdlib.h> |
2 | #include <gui/group.h> | 2 | #include <gui/group.h> |
3 | #include <common/mem.h> | ||
4 | #include <assert.h> | ||
5 | #include "MLV/MLV_shape.h" | ||
6 | #include "MLV/MLV_window.h" | ||
7 | |||
8 | void group_print(void *parameter) { | ||
9 | Group *group = (Group *) parameter; | ||
10 | /*DEBUG*/ | ||
11 | MLV_draw_filled_rectangle(group->component.x_pos, group->component.y_pos, group->component.width, | ||
12 | group->component.height, MLV_COLOR_AQUAMARINE); | ||
13 | /**/ | ||
14 | MLV_actualise_window(); | ||
15 | } | ||
3 | 16 | ||
4 | void group_init(Group *group, int width, int height, int x_pos, int y_pos, int padding) { | 17 | void group_init(Group *group, int width, int height, int x_pos, int y_pos, int padding) { |
18 | assert(group != NULL); | ||
19 | assert(width>0); | ||
20 | assert(height>0); | ||
21 | assert(x_pos>=0); | ||
22 | assert(y_pos>=0); | ||
23 | assert(padding>=0); | ||
5 | group->component.width = width; | 24 | group->component.width = width; |
6 | group->component.height = height; | 25 | group->component.height = height; |
7 | group->component.x_pos = x_pos; | 26 | group->component.x_pos = x_pos; |
8 | group->component.y_pos = y_pos; | 27 | group->component.y_pos = y_pos; |
28 | group->component.print_method = group_print; | ||
9 | group->padding = padding; | 29 | group->padding = padding; |
10 | } | 30 | } |
11 | 31 | ||
@@ -22,5 +42,20 @@ void group_free(Group *group) { | |||
22 | } | 42 | } |
23 | 43 | ||
24 | void group_add_component(Group *group, Component *component) { | 44 | void group_add_component(Group *group, Component *component) { |
25 | 45 | if (group->group_head != NULL) { | |
46 | /*Initialize the new node*/ | ||
47 | GroupElement *tmp = malloc_or_die(sizeof(GroupElement)); | ||
48 | tmp->sub_component = component; | ||
49 | tmp->next = NULL; | ||
50 | GroupElement *p = group->group_head; | ||
51 | /*Browsing*/ | ||
52 | while (p->next != NULL) { | ||
53 | p = p->next; | ||
54 | } | ||
55 | p->next = tmp; | ||
56 | } else { | ||
57 | group->group_head = malloc_or_die(sizeof(GroupElement)); | ||
58 | group->group_head->sub_component = component; | ||
59 | group->group_head->next = NULL; | ||
60 | } | ||
26 | } \ No newline at end of file | 61 | } \ No newline at end of file |