+#ifndef ANIGUI_H_
+#define ANIGUI_H_
+
+enum {
+ AG_TYPE_WIDGET,
+ AG_TYPE_WINDOW,
+ AG_TYPE_LABEL,
+ AG_TYPE_BUTTON,
+ AG_TYPE_CHECKBOX,
+ AG_TYPE_TEXTFIELD
+};
+
+enum {
+ AG_KEY_UP = 0x100,
+ AG_KEY_DOWN,
+ AG_KEY_LEFT,
+ AG_KEY_RIGHT,
+ AG_KEY_HOME,
+ AG_KEY_END,
+ AG_KEY_PGUP,
+ AG_KEY_PGDN
+};
+
+enum {
+ AG_WS_DEFAULT,
+ AG_WS_NOFRM
+};
+
+enum {
+ AG_CB_FOCUS,
+ AG_CB_UNFOCUS,
+ AG_CB_MODIFY,
+ AG_CB_CLICK,
+ AG_CB_MBUTTON,
+ AG_CB_MMOTION,
+
+ AG_NUM_CALLBACKS
+};
+
+typedef struct ag_widget ag_widget;
+typedef void (*ag_callback_func)(ag_widget*, void*);
+
+struct ag_image {
+ int width, height;
+ int bpp;
+ int pitch;
+ void *pixels;
+ void *udata;
+};
+
+struct ag_rect {
+ int x, y, w, h;
+};
+
+struct ag_graphics {
+ unsigned int flags;
+
+ void (*color)(int r, int g, int b);
+
+ void (*fillrect)(struct ag_rect *rect);
+ void (*line)(int x0, int y0, int x1, int y1);
+
+ int (*newimage)(struct ag_image *img);
+ void (*blit)(int img, int x, int y, int w, int h);
+
+ void (*text)(int font, const char *s, int x, int y);
+ void (*textbox)(int font, const char *s, int x, int y, struct ag_rect *boxret);
+ int (*lineheight)(int font);
+ int (*baseline)(int font);
+};
+
+typedef void (*ag_draw_func)(ag_widget*, struct ag_graphics*);
+
+struct ag_theme {
+ char *name;
+ void *so;
+ ag_draw_func draw_window;
+ ag_draw_func draw_label;
+ ag_draw_func draw_button;
+ ag_draw_func draw_checkbox;
+ ag_draw_func draw_textfield;
+
+ struct ag_theme *next;
+};
+
+void ag_allocator(void *(*allocfunc)(size_t), void (*freefunc)(void*));
+
+int ag_init(int w, int h, struct ag_graphics *gfx);
+void ag_destroy(void);
+
+struct ag_theme *ag_load_theme(const char *path); /* load dynamically, where applicable */
+void ag_unload_theme(struct ag_theme *theme);
+void ag_use_theme(struct ag_theme *theme);
+
+void ag_viewport(int x, int y, int w, int h);
+void ag_graphics(struct ag_graphics *gfx);
+
+void ag_inp_key(int key, int press);
+void ag_inp_mouse(int bn, int st, int x, int y);
+void ag_inp_motion(int x, int y);
+
+void ag_draw(void);
+
+ag_widget *ag_alloc_widget(ag_widget *par);
+void ag_free_widget(ag_widget *w);
+void ag_free_tree(ag_widget *tree);
+
+ag_widget *ag_window(ag_widget *par, const char *title, int style, int x, int y, int width, int height);
+ag_widget *ag_label(ag_widget *par, const char *text, int x, int y);
+ag_widget *ag_button(ag_widget *par, const char *text, int x, int y, int width, int height);
+ag_widget *ag_button_cb(ag_widget *par, const char *text, int x, int y, int width,
+ int height, ag_callback_func cbclick, void *cls);
+ag_widget *ag_checkbox(ag_widget *par, const char *text, int chk, int x, int y, int width, int height);
+ag_widget *ag_checkbox_cb(ag_widget *par, const char *text, int chk, int x, int y,
+ int width, int height, ag_callback_func cbtoggle, void *cls);
+ag_widget *ag_textfield(ag_widget *par, const char *text, int x, int y, int width, int height);
+
+int ag_type(ag_widget *w);
+
+int ag_set_text(ag_widget *w, const char *text);
+const char *ag_text(ag_widget *w);
+
+int ag_add_child(ag_widget *w, ag_widget *c);
+int ag_remove_child(ag_widget *w, ag_widget *c);
+ag_widget *ag_parent(ag_widget *w); /* parent widget */
+ag_widget *ag_widget_window(ag_widget *w); /* first ancestor of type window */
+int ag_child_count(ag_widget *w); /* number of children */
+ag_widget *ag_child(ag_widget *w, int idx); /* get child idx */
+
+void ag_move(ag_widget *w, int x, int y);
+void ag_resize(ag_widget *w, int x, int y);
+int *ag_position(ag_widget *w, int *xret, int *yret);
+int *ag_size(ag_widget *w, int *xret, int *yret);
+
+int ag_hittest(ag_widget *w, int x, int y);
+ag_widget *ag_widget_at(int x, int y);
+
+void ag_layout(ag_widget *w, int layout);
+void ag_padding(ag_widget *w, int pad);
+/* calculates layout of child widgets and updates dimensions */
+void ag_relayout(ag_widget *w);
+
+void ag_focus(ag_widget *w);
+void ag_unfocus(ag_widget *w);
+int ag_isfocused(ag_widget *w);
+
+void ag_hover(ag_widget *w);
+void ag_unhover(ag_widget *w);
+int ag_ishover(ag_widget *w);
+
+void ag_enable(ag_widget *w);
+void ag_disable(ag_widget *w);
+int ag_isenabled(ag_widget *w);
+
+void ag_callback(ag_widget *w, int type, ag_callback_func func, void *cls);
+
+void ag_rect(struct ag_rect *r, int x, int y, int w, int h);
+void ag_rect_union(struct ag_rect *a, struct ag_rect *b);
+int ag_rect_overlap(struct ag_rect *a, struct ag_rect *b);
+
+#endif /* ANIGUI_H_ */