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 typedef void (*wt_draw_func)(wt_widget*, struct wt_graphics*);
76 wt_draw_func draw_window;
77 wt_draw_func draw_label;
78 wt_draw_func draw_button;
79 wt_draw_func draw_checkbox;
80 wt_draw_func draw_textfield;
82 struct wt_theme *next;
85 void wt_allocator(void *(*allocfunc)(size_t), void (*freefunc)(void*));
87 int wt_init(int w, int h, struct wt_graphics *gfx);
88 void wt_destroy(void);
90 struct wt_theme *wt_load_theme(const char *path); /* load dynamically, where applicable */
91 void wt_unload_theme(struct wt_theme *theme);
92 void wt_use_theme(struct wt_theme *theme);
94 void wt_viewport(int x, int y, int w, int h);
95 void wt_graphics(struct wt_graphics *gfx);
97 void wt_inp_key(int key, int press);
98 void wt_inp_mouse(int bn, int st, int x, int y);
99 void wt_inp_motion(int x, int y);
103 wt_widget *wt_alloc_widget(wt_widget *par);
104 void wt_free_widget(wt_widget *w);
105 void wt_free_tree(wt_widget *tree);
107 wt_widget *wt_window(wt_widget *par, const char *title, int style, int x, int y, int width, int height);
108 wt_widget *wt_label(wt_widget *par, const char *text, int x, int y);
109 wt_widget *wt_button(wt_widget *par, const char *text, int x, int y, int width, int height);
110 wt_widget *wt_button_cb(wt_widget *par, const char *text, int x, int y, int width,
111 int height, wt_callback_func cbclick, void *cls);
112 wt_widget *wt_checkbox(wt_widget *par, const char *text, int chk, int x, int y, int width, int height);
113 wt_widget *wt_checkbox_cb(wt_widget *par, const char *text, int chk, int x, int y,
114 int width, int height, wt_callback_func cbtoggle, void *cls);
115 wt_widget *wt_textfield(wt_widget *par, const char *text, int x, int y, int width, int height);
117 int wt_type(wt_widget *w);
119 int wt_set_text(wt_widget *w, const char *text);
120 const char *wt_text(wt_widget *w);
122 int wt_add_child(wt_widget *w, wt_widget *c);
123 int wt_remove_child(wt_widget *w, wt_widget *c);
124 wt_widget *wt_parent(wt_widget *w); /* parent widget */
125 wt_widget *wt_widget_window(wt_widget *w); /* first ancestor of type window */
126 int wt_child_count(wt_widget *w); /* number of children */
127 wt_widget *wt_child(wt_widget *w, int idx); /* get child idx */
129 void wt_move(wt_widget *w, int x, int y);
130 void wt_resize(wt_widget *w, int x, int y);
131 int *wt_position(wt_widget *w, int *xret, int *yret);
132 int *wt_size(wt_widget *w, int *xret, int *yret);
134 int wt_hittest(wt_widget *w, int x, int y);
135 wt_widget *wt_widget_at(int x, int y);
137 void wt_layout(wt_widget *w, int layout);
138 void wt_padding(wt_widget *w, int pad);
139 /* calculates layout of child widgets and updates dimensions */
140 void wt_relayout(wt_widget *w);
142 void wt_focus(wt_widget *w);
143 void wt_unfocus(wt_widget *w);
144 int wt_isfocused(wt_widget *w);
146 void wt_hover(wt_widget *w);
147 void wt_unhover(wt_widget *w);
148 int wt_ishover(wt_widget *w);
150 void wt_enable(wt_widget *w);
151 void wt_disable(wt_widget *w);
152 int wt_isenabled(wt_widget *w);
154 void wt_callback(wt_widget *w, int type, wt_callback_func func, void *cls);
156 void wt_setrect(struct wt_rect *r, int x, int y, int w, int h);
158 #endif /* WINDTK_H_ */