summaryrefslogtreecommitdiff
path: root/include/gui/group.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/gui/group.h')
-rw-r--r--include/gui/group.h78
1 files changed, 76 insertions, 2 deletions
diff --git a/include/gui/group.h b/include/gui/group.h
index 6914d55..2a02ee4 100644
--- a/include/gui/group.h
+++ b/include/gui/group.h
@@ -3,17 +3,91 @@
3 3
4/** 4/**
5 * File: group.h 5 * File: group.h
6 * Group of components
6 */ 7 */
8#include "component.h"
7 9
10/**
11 * Struct: _GroupElement
12 * Node of the linked list that is involved in the Group behavior
13 *
14 * Parameters:
15 * *component - component
16 * *sub_component - sub component
17 * *next - link to the next node
18 */
19typedef struct _GroupElement {
20 Component *sub_component;
21 struct _GroupElement *next;
22} GroupElement;
23
24/**
25 * Struct: Group
26 * Group representation
27 *
28 * Parameters:
29 * component - Component used for the Group to catch clicks and handle print to delegate to the components contented in it
30 * *group_head - pointer to the head of the list that regroup all the components contained inside of the group
31 * margin - margin for all components
32 */
8typedef struct { 33typedef struct {
9 Component component; 34 Component component;
10 Component *sub_components; 35 GroupElement *group_head;
36 int margin;
11} Group; 37} Group;
12 38
13void group_init(Group *group, int padding); 39/**
40 * Function: group_print
41 * Print method for a group that will print all components contained in.
42 *
43 * Parameters:
44 * *parameterSelf - pointer that will be casted into a Group to print
45 */
46void group_print(Component *parameterSelf);
47
48/**
49 * Function: group_click_handler
50 * Delegates the click handling to the component contained inside.
51 *
52 * Parameters:
53 * x_pos - position of the mouse on x axis
54 * y_pos - position of the mouse on y axis
55 * *parameterSelf - pointer that will be casted into a Group to print
56 */
57void group_click_handler(int x_pos, int y_pos, Component *parameterSelf);
58
59/**
60 * Function: group_init
61 * Initializes fields of a Group that must be allocated before.
62 *
63 * Parameters:
64 * *group - group that must be initialized
65 * width - width of the current group
66 * height - height of the current group
67 * x_pos - position on the x axis from the upper left corner
68 * y_pos - position on the y axis from the upper left corner
69 * margin - space between each components
70 */
71void group_init(Group *group, int width, int height, int x_pos, int y_pos, int margin);
14 72
73/**
74 * Function: group_free
75 * Frees the resources held by the group like the linked list.
76 *
77 * Parameters:
78 * *group - group that must be freed
79 */
15void group_free(Group *group); 80void group_free(Group *group);
16 81
82/**
83 * Function: group_add_component
84 * Adds the component at the end of the chained list held by group_head.
85 *
86 * Parameters:
87 * *group - group in which we add the component
88 * *component - component which is added to the group
89 */
17void group_add_component(Group *group, Component *component); 90void group_add_component(Group *group, Component *component);
18 91
92
19#endif 93#endif