summaryrefslogtreecommitdiff
path: root/include/gui/window.h
blob: a20456d4d320783a2bf97dc8b35098f2820eff61 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
#ifndef UPEM_MORPHING_WINDOW
#define UPEM_MORPHING_WINDOW

/**
 * File: window.h
 * Windows and components handling.
 *
 * See also:
 *  The famous OS
 */

#include "group.h"

/**
 * Type: ClickHandler
 * Type of functions that handle mouse's clicks.
 */
typedef void (*ClickHandler)(int x_pos, int y_pos);

/**
 * Type: PrintMethod
 * Type of functions that will be used to print our component. This must be initialized by the initialization function of the component.
 */
typedef void (*PrintMethod)(void);

/**
 * Struct: Component
 * Represents an abstract module handling clicks and a way to be print on the screen.
 *
 * Fields:
 *  width - width of the component
 *  height - height of the component
 *  x_pos - position on the x axis from the origin meant to be placed in top left
 *  y_pos - position on the y axis from the origin meant to be placed in top left
 *  click_handler - pointer of function that is called on mouse click
 *  print_method - pointer of function that handle the component's print
 */
typedef struct {
  int width, height;
  int x_pos, y_pos;
  ClickHandler click_handler;
  PrintMethod print_method;
} Component;
/**
 * Struct: Window
 * Supports and handles components.
 *
 * Fields:
 *   width - width of the window
 *   height - height of the window
 *   *title - string printed as name for the window
 *   *group_buttons - group that handles the buttons added to the window
 *   *group_pictureframe - group that handles the picture frames added to the window
 */
typedef struct {
  int width, height;
  char *title;
  Group *group_buttons;
  Group *group_pictureframe;
} Window;

/**
 * Function: window_init
 * Initializes a window.
 *
 * Parameters:
 *  *window - pointer to the input window
 *  width - width of the window to initialize
 *  height - height of the window to initialize
 *  *title - title of the actual window
 */
void window_init(Window *window, int width, int height, char *title);

/**
 * Function: window_free
 * Frees the resources supported by the window and the window itself.
 *
 * Parameters:
 *  *window - pointer to the input window
 */
void window_free(Window *window);

/**
 * Function: window_add_button
 * Adds Button component to the group of buttons of the current window.
 *
 * Parameters:
 *  *window - pointer to the input window
 *  *component - pointer to the input component
 */
void window_add_button(Window *window, Component *component);

/**
 * Function: window_add_pictureframe
 * Adds PictureFrame component to the group of picture frames of the current window.
 *
 * Parameters:
 *  *window - pointer to the input window
 *  *component - pointer to the input component
 */
void window_add_pictureframe(Window *window, Component *component);


#endif