40 typedef struct wt_widget wt_widget;
41 typedef void (*wt_callback_func)(wt_widget*, void*);
57 WT_GFX_RGB = 1, /* RGB mode, calls newcolor to set current, not to allocate */
58 WT_GFX_NODIRTY = 2 /* don't use dirty rects, always redraw completely */
64 int (*newcolor)(int r, int g, int b);
67 void (*fillrect)(struct wt_rect *rect);
68 void (*line)(int x0, int y0, int x1, int y1);
70 int (*newimage)(struct wt_image *img);
71 void (*blit)(int img, int x, int y, int w, int h);
73 void (*text)(int font, const char *s, int x, int y);
74 void (*textbox)(int font, const char *s, int x, int y, struct wt_rect *boxret);
75 int (*lineheight)(int font);
76 int (*baseline)(int font);
79 typedef void (*wt_draw_func)(wt_widget*, struct wt_graphics*);
84 wt_draw_func draw_window;
85 wt_draw_func draw_label;
86 wt_draw_func draw_button;
87 wt_draw_func draw_checkbox;
88 wt_draw_func draw_textfield;
90 struct wt_theme *next;
93 void wt_allocator(void *(*allocfunc)(size_t), void (*freefunc)(void*));
95 int wt_init(int w, int h, struct wt_graphics *gfx);
96 void wt_destroy(void);
98 struct wt_theme *wt_load_theme(const char *path); /* load dynamically, where applicable */
99 void wt_unload_theme(struct wt_theme *theme);
100 void wt_use_theme(struct wt_theme *theme);
102 void wt_viewport(int x, int y, int w, int h);
103 void wt_graphics(struct wt_graphics *gfx);
105 void wt_inp_key(int key, int press);
106 void wt_inp_mouse(int bn, int st, int x, int y);
107 void wt_inp_motion(int x, int y);
111 /* screen regions updated by the last wt_draw */
112 int wt_num_upd(void);
113 struct wt_rect *wt_upd_rect(int idx);
114 void wt_add_upd_rect(struct wt_rect *r);
116 wt_widget *wt_alloc_widget(wt_widget *par);
117 void wt_free_widget(wt_widget *w);
118 void wt_free_tree(wt_widget *tree);
120 void wt_dirty_widget(wt_widget *w); /* propagates to children */
122 wt_widget *wt_window(wt_widget *par, const char *title, int style, int x, int y, int width, int height);
123 wt_widget *wt_label(wt_widget *par, const char *text, int x, int y);
124 wt_widget *wt_button(wt_widget *par, const char *text, int x, int y, int width, int height);
125 wt_widget *wt_button_cb(wt_widget *par, const char *text, int x, int y, int width,
126 int height, wt_callback_func cbclick, void *cls);
127 wt_widget *wt_checkbox(wt_widget *par, const char *text, int chk, int x, int y, int width, int height);
128 wt_widget *wt_checkbox_cb(wt_widget *par, const char *text, int chk, int x, int y,
129 int width, int height, wt_callback_func cbtoggle, void *cls);
130 wt_widget *wt_textfield(wt_widget *par, const char *text, int x, int y, int width, int height);
132 int wt_type(wt_widget *w);
134 int wt_set_text(wt_widget *w, const char *text);
135 const char *wt_text(wt_widget *w);
137 int wt_add_child(wt_widget *w, wt_widget *c);
138 int wt_remove_child(wt_widget *w, wt_widget *c);
139 wt_widget *wt_parent(wt_widget *w); /* parent widget */
140 wt_widget *wt_widget_window(wt_widget *w); /* first ancestor of type window */
141 int wt_child_count(wt_widget *w); /* number of children */
142 wt_widget *wt_child(wt_widget *w, int idx); /* get child idx */
144 void wt_move(wt_widget *w, int x, int y);
145 void wt_resize(wt_widget *w, int x, int y);
146 int *wt_position(wt_widget *w, int *xret, int *yret);
147 int *wt_size(wt_widget *w, int *xret, int *yret);
149 int wt_hittest(wt_widget *w, int x, int y);
150 wt_widget *wt_widget_at(int x, int y);
152 void wt_layout(wt_widget *w, int layout);
153 void wt_padding(wt_widget *w, int pad);
154 /* calculates layout of child widgets and updates dimensions */
155 void wt_relayout(wt_widget *w);
157 void wt_focus(wt_widget *w);
158 void wt_unfocus(wt_widget *w);
159 int wt_isfocused(wt_widget *w);
161 void wt_hover(wt_widget *w);
162 void wt_unhover(wt_widget *w);
163 int wt_ishover(wt_widget *w);
165 void wt_enable(wt_widget *w);
166 void wt_disable(wt_widget *w);
167 int wt_isenabled(wt_widget *w);
169 void wt_callback(wt_widget *w, int type, wt_callback_func func, void *cls);
171 void wt_rect(struct wt_rect *r, int x, int y, int w, int h);
172 void wt_rect_union(struct wt_rect *a, struct wt_rect *b);
173 int wt_rect_overlap(struct wt_rect *a, struct wt_rect *b);
175 #endif /* WINDTK_H_ */