40 typedef struct ag_widget ag_widget;
41 typedef void (*ag_callback_func)(ag_widget*, void*);
58 void (*color)(int r, int g, int b);
60 void (*fillrect)(struct ag_rect *rect);
61 void (*line)(int x0, int y0, int x1, int y1);
63 int (*newimage)(struct ag_image *img);
64 void (*blit)(int img, int x, int y, int w, int h);
66 void (*text)(int font, const char *s, int x, int y);
67 void (*textbox)(int font, const char *s, int x, int y, struct ag_rect *boxret);
68 int (*lineheight)(int font);
69 int (*baseline)(int font);
72 typedef void (*ag_draw_func)(ag_widget*, struct ag_graphics*);
77 ag_draw_func draw_window;
78 ag_draw_func draw_label;
79 ag_draw_func draw_button;
80 ag_draw_func draw_checkbox;
81 ag_draw_func draw_textfield;
83 struct ag_theme *next;
86 void ag_allocator(void *(*allocfunc)(size_t), void (*freefunc)(void*));
88 int ag_init(int w, int h, struct ag_graphics *gfx);
89 void ag_destroy(void);
91 struct ag_theme *ag_load_theme(const char *path); /* load dynamically, where applicable */
92 void ag_unload_theme(struct ag_theme *theme);
93 void ag_use_theme(struct ag_theme *theme);
95 void ag_viewport(int x, int y, int w, int h);
96 void ag_graphics(struct ag_graphics *gfx);
98 void ag_inp_key(int key, int press);
99 void ag_inp_mouse(int bn, int st, int x, int y);
100 void ag_inp_motion(int x, int y);
104 ag_widget *ag_alloc_widget(ag_widget *par);
105 void ag_free_widget(ag_widget *w);
106 void ag_free_tree(ag_widget *tree);
108 ag_widget *ag_window(ag_widget *par, const char *title, int style, int x, int y, int width, int height);
109 ag_widget *ag_label(ag_widget *par, const char *text, int x, int y);
110 ag_widget *ag_button(ag_widget *par, const char *text, int x, int y, int width, int height);
111 ag_widget *ag_button_cb(ag_widget *par, const char *text, int x, int y, int width,
112 int height, ag_callback_func cbclick, void *cls);
113 ag_widget *ag_checkbox(ag_widget *par, const char *text, int chk, int x, int y, int width, int height);
114 ag_widget *ag_checkbox_cb(ag_widget *par, const char *text, int chk, int x, int y,
115 int width, int height, ag_callback_func cbtoggle, void *cls);
116 ag_widget *ag_textfield(ag_widget *par, const char *text, int x, int y, int width, int height);
118 int ag_type(ag_widget *w);
120 int ag_set_text(ag_widget *w, const char *text);
121 const char *ag_text(ag_widget *w);
123 int ag_add_child(ag_widget *w, ag_widget *c);
124 int ag_remove_child(ag_widget *w, ag_widget *c);
125 ag_widget *ag_parent(ag_widget *w); /* parent widget */
126 ag_widget *ag_widget_window(ag_widget *w); /* first ancestor of type window */
127 int ag_child_count(ag_widget *w); /* number of children */
128 ag_widget *ag_child(ag_widget *w, int idx); /* get child idx */
130 void ag_move(ag_widget *w, int x, int y);
131 void ag_resize(ag_widget *w, int x, int y);
132 int *ag_position(ag_widget *w, int *xret, int *yret);
133 int *ag_size(ag_widget *w, int *xret, int *yret);
135 int ag_hittest(ag_widget *w, int x, int y);
136 ag_widget *ag_widget_at(int x, int y);
138 void ag_layout(ag_widget *w, int layout);
139 void ag_padding(ag_widget *w, int pad);
140 /* calculates layout of child widgets and updates dimensions */
141 void ag_relayout(ag_widget *w);
143 void ag_focus(ag_widget *w);
144 void ag_unfocus(ag_widget *w);
145 int ag_isfocused(ag_widget *w);
147 void ag_hover(ag_widget *w);
148 void ag_unhover(ag_widget *w);
149 int ag_ishover(ag_widget *w);
151 void ag_enable(ag_widget *w);
152 void ag_disable(ag_widget *w);
153 int ag_isenabled(ag_widget *w);
155 void ag_callback(ag_widget *w, int type, ag_callback_func func, void *cls);
157 void ag_rect(struct ag_rect *r, int x, int y, int w, int h);
158 void ag_rect_union(struct ag_rect *a, struct ag_rect *b);
159 int ag_rect_overlap(struct ag_rect *a, struct ag_rect *b);
161 #endif /* ANIGUI_H_ */