summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/gui/button.h21
-rw-r--r--include/gui/group.h9
-rw-r--r--include/gui/window.h58
3 files changed, 84 insertions, 4 deletions
diff --git a/include/gui/button.h b/include/gui/button.h
index 62f75a3..8537151 100644
--- a/include/gui/button.h
+++ b/include/gui/button.h
@@ -1,16 +1,37 @@
1#ifndef UPEM_MORPHING_BUTTON 1#ifndef UPEM_MORPHING_BUTTON
2#define UPEM_MORPHING_BUTTON 2#define UPEM_MORPHING_BUTTON
3 3
4#include "window.h"
4/** 5/**
5 * File: button.h 6 * File: button.h
7 * Buttons handling
6 */ 8 */
7 9
10/**
11 * Type: Button
12 * Component that can be triggered by click to execute a specific action.
13 */
8typedef struct { 14typedef struct {
9 Component component; 15 Component component;
10} Button; 16} Button;
11 17
18/**
19 * Function: button_init
20 * Initializes the button.
21 *
22 * Parameters:
23 * *button - pointer to the input button
24 * text - label for the button
25 */
12void button_init(Button *button, char *text); 26void button_init(Button *button, char *text);
13 27
28/**
29 * Function: button_free
30 * Frees the resources for the button.
31 *
32 * Parameters:
33 * *button - pointer to the input button
34 */
14void button_free(Button *button); 35void button_free(Button *button);
15 36
16#endif 37#endif
diff --git a/include/gui/group.h b/include/gui/group.h
index 6914d55..45ec3b2 100644
--- a/include/gui/group.h
+++ b/include/gui/group.h
@@ -1,13 +1,20 @@
1#ifndef UPEM_MORPHING_GROUP 1#ifndef UPEM_MORPHING_GROUP
2#define UPEM_MORPHING_GROUP 2#define UPEM_MORPHING_GROUP
3 3
4#include "window.h"
5
4/** 6/**
5 * File: group.h 7 * File: group.h
6 */ 8 */
7 9
10typedef struct _GroupElement {
11 Component *c;
12 struct _GroupElement *next;
13} GroupElement;
14
8typedef struct { 15typedef struct {
9 Component component; 16 Component component;
10 Component *sub_components; 17 GroupElement *group_head;
11} Group; 18} Group;
12 19
13void group_init(Group *group, int padding); 20void group_init(Group *group, int padding);
diff --git a/include/gui/window.h b/include/gui/window.h
index 9394c84..6ccf00a 100644
--- a/include/gui/window.h
+++ b/include/gui/window.h
@@ -3,24 +3,76 @@
3 3
4/** 4/**
5 * File: window.h 5 * File: window.h
6 * Windows and components handling.
7 *
8 * See also:
9 * The famous OS
6 */ 10 */
7 11
12#include "group.h"
13
14/**
15 * Type: ClickHandler
16 * Type of functions that handle mouse's clicks.
17 */
8typedef void (*ClickHandler)(int x_pos, int y_pos); 18typedef void (*ClickHandler)(int x_pos, int y_pos);
9 19
20/**
21 * Type: PrintMethod
22 * Type of functions that will be used to print our component. This must be initialized by the initialization function of the component.
23 */
24typedef void (*PrintMethod)(void);
25
26/**
27 * Type: Component
28 * Abstract component that handles clicks.
29 */
10typedef struct { 30typedef struct {
11 int width, height; 31 int width, height;
32 int x_pos, y_pos;
12 ClickHandler click_handler; 33 ClickHandler click_handler;
34 PrintMethod print_method;
13} Component; 35} Component;
14 36/**
37 * Type: Window
38 * Supports and handles components.
39 */
15typedef struct { 40typedef struct {
16 int width, height; 41 int width, height;
17 Component *components; 42 Group *group_buttons;
43 Group *group_images;
18} Window; 44} Window;
19 45
46/**
47 * Function: window_init
48 * Initializes a window.
49 *
50 * Parameters:
51 * *window - pointer to the input window
52 * width - width of the window to initialize
53 * height - height of the window to initialize
54 * *title - title of the actual window
55 */
20void window_init(Window *window, int width, int height, char *title); 56void window_init(Window *window, int width, int height, char *title);
21 57
58/**
59 * Function: window_free
60 * Frees the resources supported by the window and the window itself.
61 *
62 * Parameters:
63 * *window - pointer to the input window
64 */
22void window_free(Window *window); 65void window_free(Window *window);
23 66
24void window_add_component(Window *window, Component *component, int x_pos, int y_pos); 67/**
68 * Function: window_add_component
69 * Adds components to the current window at the position specified in x and y.
70 *
71 * Parameters:
72 * *window - pointer to the input window
73 * *component - pointer to the input component
74 */
75void window_add_component(Window *window, Component *component);
76
25 77
26#endif 78#endif