+#ifndef WINDTK_H_
+#define WINDTK_H_
+
+enum {
+ WT_TYPE_WIDGET,
+ WT_TYPE_WINDOW,
+ WT_TYPE_LABEL,
+ WT_TYPE_BUTTON,
+ WT_TYPE_CHECKBOX,
+ WT_TYPE_TEXTFIELD
+};
+
+enum {
+ WT_KEY_UP = 0x100,
+ WT_KEY_DOWN,
+ WT_KEY_LEFT,
+ WT_KEY_RIGHT,
+ WT_KEY_HOME,
+ WT_KEY_END,
+ WT_KEY_PGUP,
+ WT_KEY_PGDN
+};
+
+enum {
+ WT_WS_DEFAULT,
+ WT_WS_NOFRM
+};
+
+enum {
+ WT_CB_FOCUS,
+ WT_CB_UNFOCUS,
+ WT_CB_MODIFY,
+ WT_CB_CLICK,
+ WT_CB_MBUTTON,
+ WT_CB_MMOTION,
+
+ WT_NUM_CALLBACKS
+};
+
+typedef struct wt_widget wt_widget;
+typedef void (*wt_callback_func)(wt_widget*, void*);
+
+struct wt_image {
+ int width, height;
+ int bpp;
+ int pitch;
+ void *pixels;
+ void *udata;
+};
+
+struct wt_rect {
+ int x, y, width, height;
+};
+
+struct wt_graphics {
+ int (*newcolor)(int r, int g, int b);
+ void (*color)(int c);
+
+ void (*fillrect)(struct wt_rect *rect);
+ void (*line)(int x0, int y0, int x1, int y1);
+
+ int (*newimage)(struct wt_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 wt_rect *boxret);
+ int (*lineheight)(int font);
+ int (*baseline)(int font);
+};
+
+void wt_allocator(void *(*allocfunc)(size_t), void (*freefunc)(void*));
+
+int wt_init(int w, int h, struct wt_graphics *gfx);
+void wt_destroy(void);
+
+void wt_viewport(int x, int y, int w, int h);
+void wt_graphics(struct wt_graphics *gfx);
+
+void wt_inp_key(int key, int press);
+void wt_inp_mouse(int bn, int st, int x, int y);
+void wt_inp_motion(int x, int y);
+
+wt_widget *wt_alloc_widget(wt_widget *par);
+void wt_free_widget(wt_widget *w);
+void wt_free_tree(wt_widget *tree);
+
+wt_widget *wt_window(wt_widget *par, const char *title, int style, int x, int y, int width, int height);
+wt_widget *wt_label(wt_widget *par, const char *text, int x, int y);
+wt_widget *wt_button(wt_widget *par, const char *text, int x, int y, int width, int height);
+wt_widget *wt_button_cb(wt_widget *par, const char *text, int x, int y, int width,
+ int height, wt_callback_func cbclick, void *cls);
+wt_widget *wt_checkbox(wt_widget *par, const char *text, int chk, int x, int y, int width, int height);
+wt_widget *wt_checkbox_cb(wt_widget *par, const char *text, int chk, int x, int y,
+ int width, int height, wt_callback_func cbtoggle, void *cls);
+wt_widget *wt_textfield(wt_widget *par, const char *text, int x, int y, int width, int height);
+
+int wt_type(wt_widget *w);
+
+int wt_set_text(wt_widget *w, const char *text);
+const char *wt_text(wt_widget *w);
+
+int wt_add_child(wt_widget *w, wt_widget *c);
+int wt_remove_child(wt_widget *w, wt_widget *c);
+wt_widget *wt_parent(wt_widget *w); /* parent widget */
+wt_widget *wt_widget_window(wt_widget *w); /* first ancestor of type window */
+int wt_child_count(wt_widget *w); /* number of children */
+wt_widget *wt_child(wt_widget *w, int idx); /* get child idx */
+
+void wt_move(wt_widget *w, int x, int y);
+void wt_resize(wt_widget *w, int x, int y);
+int *wt_position(wt_widget *w, int *xret, int *yret);
+int *wt_size(wt_widget *w, int *xret, int *yret);
+
+void wt_layout(wt_widget *w, int layout);
+void wt_padding(wt_widget *w, int pad);
+/* calculates layout of child widgets and updates dimensions */
+void wt_relayout(wt_widget *w);
+
+int wt_hittest(wt_widget *w, int x, int y);
+wt_widget *wt_widget_at(int x, int y);
+
+void wt_focus(wt_widget *w);
+void wt_unfocus(wt_widget *w);
+int wt_isfocused(wt_widget *w);
+
+void wt_hover(wt_widget *w);
+void wt_unhover(wt_widget *w);
+int wt_ishover(wt_widget *w);
+
+void wt_enable(wt_widget *w);
+void wt_disable(wt_widget *w);
+int wt_isenabled(wt_widget *w);
+
+void wt_callback(wt_widget *w, int type, wt_callback_func func, void *cls);
+
+void wt_setrect(struct wt_rect *r, int x, int y, int w, int h);
+
+#endif /* WINDTK_H_ */