gui.h 3.62 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

Cedric Roux's avatar
Cedric Roux committed
15 16
#define DEFAULT_FONT 0

17 18 19 20 21
/* key modifiers */
#define KEY_SHIFT   (1<<0)
#define KEY_CONTROL (1<<1)
#define KEY_ALT     (1<<2)

22 23 24 25
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
26
void widget_del_child(gui *gui, widget *parent, widget *child);
27
void widget_dirty(gui *gui, widget *this);
28 29 30

widget *new_toplevel_window(gui *gui, int width, int height, char *title);
widget *new_container(gui *gui, int vertical);
31
widget *new_positioner(gui *gui);
32 33 34
widget *new_label(gui *gui, const char *text);
widget *new_xy_plot(gui *gui, int width, int height, char *label,
    int vruler_width);
Cedric Roux's avatar
Cedric Roux committed
35
widget *new_textlist(gui *gui, int width, int nlines, int background_color);
Cedric Roux's avatar
Cedric Roux committed
36 37
widget *new_timeline(gui *gui, int width, int number_of_sublines,
    int subline_height);
38
widget *new_space(gui *gui, int width, int height);
Cedric Roux's avatar
Cedric Roux committed
39
widget *new_image(gui *gui, unsigned char *data, int length);
40

41
void label_set_clickable(gui *gui, widget *label, int clickable);
Cedric Roux's avatar
Cedric Roux committed
42
void label_set_text(gui *gui, widget *label, char *text);
43

44 45 46
void container_set_child_growable(gui *_gui, widget *_this,
    widget *child, int growable);

47
int xy_plot_new_plot(gui *gui, widget *this, int color);
48 49
void xy_plot_set_range(gui *gui, widget *this,
    float xmin, float xmax, float ymin, float ymax);
Cedric Roux's avatar
Cedric Roux committed
50
void xy_plot_set_points(gui *gui, widget *this,
51
    int plot, int npoints, float *x, float *y);
52
void xy_plot_get_dimensions(gui *gui, widget *this, int *width, int *height);
53

54
void textlist_add(gui *gui, widget *this, const char *text, int position,
Cedric Roux's avatar
Cedric Roux committed
55
    int color);
56 57
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
58
    int position, int color);
59 60
void textlist_del_silent(gui *gui, widget *this, int position);
void textlist_state(gui *_gui, widget *_this,
Cedric Roux's avatar
Cedric Roux committed
61
    int *visible_lines, int *start_line, int *number_of_lines);
62 63
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
64
    char **text, int *color);
65
void textlist_set_color(gui *gui, widget *this, int line, int color);
66

Cedric Roux's avatar
Cedric Roux committed
67
void timeline_clear(gui *gui, widget *this);
68
void timeline_clear_silent(gui *gui, widget *this);
Cedric Roux's avatar
Cedric Roux committed
69 70
void timeline_add_points(gui *gui, widget *this, int subline, int color,
    int *x, int len);
71 72
void timeline_add_points_silent(gui *gui, widget *this, int subline,
    int color, int *x, int len);
Cedric Roux's avatar
Cedric Roux committed
73 74
void timeline_set_subline_background_color(gui *gui, widget *this,
    int subline, int color);
Cedric Roux's avatar
Cedric Roux committed
75
void timeline_get_width(gui *gui, widget *this, int *width);
Cedric Roux's avatar
Cedric Roux committed
76

77 78 79 80 81 82 83
void gui_loop(gui *gui);

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

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

84 85
/* notifications */
/* known notifications:
86
 * - textlist:
Cedric Roux's avatar
Cedric Roux committed
87 88
 *      - scrollup   { int: key_modifiers }
 *      - scrolldown { int: key_modifiers }
Cedric Roux's avatar
Cedric Roux committed
89
 *      - click      { int [2]: line, button }
90 91
 * - label:
 *      - click      { int: button } (if enabled)
Cedric Roux's avatar
Cedric Roux committed
92 93
 * - timeline
 *      - resize     { int: width }
94 95
 *      - scrollup   { int [3]: x, y, key_modifiers }
 *      - scrolldown { int [3]: x, y, key_modifiers }
Cedric Roux's avatar
Cedric Roux committed
96
 *      - click      { int: button }
97 98 99 100 101 102 103 104 105
 */

/* 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);

106
#endif /* _GUI_H_ */