gui.h 2.29 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
#ifndef _GUI_H_
#define _GUI_H_

/* defines the public API of the GUI */

typedef void gui;
typedef void widget;

#define HORIZONTAL 0
#define VERTICAL   1

12
13
14
#define BACKGROUND_COLOR 0
#define FOREGROUND_COLOR 1

15
16
17
18
gui *gui_init(void);

/* position = -1 to put at the end */
void widget_add_child(gui *gui, widget *parent, widget *child, int position);
Cedric Roux's avatar
Cedric Roux committed
19
void widget_del_child(gui *gui, widget *parent, widget *child);
20
void widget_dirty(gui *gui, widget *this);
21
22
23
24
25
26

widget *new_toplevel_window(gui *gui, int width, int height, char *title);
widget *new_container(gui *gui, int vertical);
widget *new_label(gui *gui, const char *text);
widget *new_xy_plot(gui *gui, int width, int height, char *label,
    int vruler_width);
27
widget *new_textlist(gui *_gui, int width, int nlines, int background_color);
28

29
30
31
void container_set_child_growable(gui *_gui, widget *_this,
    widget *child, int growable);

32
33
void xy_plot_set_range(gui *gui, widget *this,
    float xmin, float xmax, float ymin, float ymax);
Cedric Roux's avatar
Cedric Roux committed
34
35
void xy_plot_set_points(gui *gui, widget *this,
    int npoints, float *x, float *y);
36

37
void textlist_add(gui *gui, widget *this, const char *text, int position,
Cedric Roux's avatar
Cedric Roux committed
38
    int color);
39
40
void textlist_del(gui *gui, widget *this, int position);
void textlist_add_silent(gui *gui, widget *this, const char *text,
Cedric Roux's avatar
Cedric Roux committed
41
    int position, int color);
42
43
void textlist_del_silent(gui *gui, widget *this, int position);
void textlist_state(gui *_gui, widget *_this,
Cedric Roux's avatar
Cedric Roux committed
44
    int *visible_lines, int *start_line, int *number_of_lines);
45
46
void textlist_set_start_line(gui *gui, widget *this, int line);
void textlist_get_line(gui *gui, widget *this, int line,
Cedric Roux's avatar
Cedric Roux committed
47
    char **text, int *color);
48
void textlist_set_color(gui *gui, widget *this, int line, int color);
49
50
51
52
53
54
55
56

void gui_loop(gui *gui);

void glock(gui *gui);
void gunlock(gui *gui);

int new_color(gui *gui, char *color);

57
58
/* notifications */
/* known notifications:
59
 * - textlist:
Cedric Roux's avatar
Cedric Roux committed
60
61
62
 *      - scrollup   { void *: NULL }
 *      - scrolldown { void *: NULL }
 *      - click      { int [2]: line, button }
63
64
65
66
67
68
69
70
71
 */

/* same type as in gui_defs.h */
typedef void (*notifier)(void *private, gui *g,
    char *notification, widget *w, void *notification_data);
unsigned long register_notifier(gui *g, char *notification, widget *w,
    notifier handler, void *private);
void unregister_notifier(gui *g, unsigned long notifier_id);

72
#endif /* _GUI_H_ */