summaryrefslogtreecommitdiff
path: root/include/gui/window.h
blob: defc6f7304dfb1facf61f545d67f3ba187ba9fa2 (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
#ifndef UPEM_MORPHING_WINDOW
#define UPEM_MORPHING_WINDOW

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

typedef void (*ClickHandler)(int x_pos, int y_pos);
/**
 * Type: Component
 * Abstract component that handles clicks.
 */
typedef struct {
  int width, height;
  ClickHandler click_handler;
} Component;
/**
 * Type: Window
 * Supports and handles components.
 */
typedef struct {
  int width, height;
  Component *components;
} 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_component
 * Adds components to the current window at the position specified in x and y.
 *
 * Parameters:
 *  *window - pointer to the input window
 *  *component - pointer to the input component
 *  x_pos - coordinate on x axis to place the component
 *  y_pos - coordinate on y axis to place the component
 */
void window_add_component(Window *window, Component *component, int x_pos, int y_pos);

#endif