40 typedef struct wt_widget wt_widget;
41 typedef void (*wt_callback_func)(wt_widget*, void*);
52 int x, y, width, height;
56 int (*newcolor)(int r, int g, int b);
59 void (*fillrect)(struct wt_rect *rect);
60 void (*line)(int x0, int y0, int x1, int y1);
62 int (*newimage)(struct wt_image *img);
63 void (*blit)(int img, int x, int y, int w, int h);
65 void (*text)(int font, const char *s, int x, int y);
66 void (*textbox)(int font, const char *s, int x, int y, struct wt_rect *boxret);
67 int (*lineheight)(int font);
68 int (*baseline)(int font);
71 void wt_allocator(void *(*allocfunc)(size_t), void (*freefunc)(void*));
73 int wt_init(int w, int h, struct wt_graphics *gfx);
74 void wt_destroy(void);
76 void wt_viewport(int x, int y, int w, int h);
77 void wt_graphics(struct wt_graphics *gfx);
79 void wt_inp_key(int key, int press);
80 void wt_inp_mouse(int bn, int st, int x, int y);
81 void wt_inp_motion(int x, int y);
83 wt_widget *wt_alloc_widget(wt_widget *par);
84 void wt_free_widget(wt_widget *w);
85 void wt_free_tree(wt_widget *tree);
87 wt_widget *wt_window(wt_widget *par, const char *title, int style, int x, int y, int width, int height);
88 wt_widget *wt_label(wt_widget *par, const char *text, int x, int y);
89 wt_widget *wt_button(wt_widget *par, const char *text, int x, int y, int width, int height);
90 wt_widget *wt_button_cb(wt_widget *par, const char *text, int x, int y, int width,
91 int height, wt_callback_func cbclick, void *cls);
92 wt_widget *wt_checkbox(wt_widget *par, const char *text, int chk, int x, int y, int width, int height);
93 wt_widget *wt_checkbox_cb(wt_widget *par, const char *text, int chk, int x, int y,
94 int width, int height, wt_callback_func cbtoggle, void *cls);
95 wt_widget *wt_textfield(wt_widget *par, const char *text, int x, int y, int width, int height);
97 int wt_type(wt_widget *w);
99 int wt_set_text(wt_widget *w, const char *text);
100 const char *wt_text(wt_widget *w);
102 int wt_add_child(wt_widget *w, wt_widget *c);
103 int wt_remove_child(wt_widget *w, wt_widget *c);
104 wt_widget *wt_parent(wt_widget *w); /* parent widget */
105 wt_widget *wt_widget_window(wt_widget *w); /* first ancestor of type window */
106 int wt_child_count(wt_widget *w); /* number of children */
107 wt_widget *wt_child(wt_widget *w, int idx); /* get child idx */
109 void wt_move(wt_widget *w, int x, int y);
110 void wt_resize(wt_widget *w, int x, int y);
111 int *wt_position(wt_widget *w, int *xret, int *yret);
112 int *wt_size(wt_widget *w, int *xret, int *yret);
114 void wt_layout(wt_widget *w, int layout);
115 void wt_padding(wt_widget *w, int pad);
116 /* calculates layout of child widgets and updates dimensions */
117 void wt_relayout(wt_widget *w);
119 int wt_hittest(wt_widget *w, int x, int y);
120 wt_widget *wt_widget_at(int x, int y);
122 void wt_focus(wt_widget *w);
123 void wt_unfocus(wt_widget *w);
124 int wt_isfocused(wt_widget *w);
126 void wt_hover(wt_widget *w);
127 void wt_unhover(wt_widget *w);
128 int wt_ishover(wt_widget *w);
130 void wt_enable(wt_widget *w);
131 void wt_disable(wt_widget *w);
132 int wt_isenabled(wt_widget *w);
134 void wt_callback(wt_widget *w, int type, wt_callback_func func, void *cls);
136 void wt_setrect(struct wt_rect *r, int x, int y, int w, int h);
138 #endif /* WINDTK_H_ */