if(wt_init(800, 600, &gfx)) {
return 1;
}
+ wt_window(0, "foo", WT_WS_DEFAULT, 10, 10, 200, 200);
glutMainLoop();
return 0;
{
glClear(GL_COLOR_BUFFER_BIT);
+ wt_draw();
+
glutSwapBuffers();
}
}
w->type = WT_TYPE_WIDGET;
- if(par) {
- wt_add_child(par, w);
- }
+ if(!par) par = wt->root;
+ wt_add_child(par, w);
return w;
}
int wt_add_child(wt_widget *w, wt_widget *c)
{
+ if(!w || !c) return -1;
+
if(find_child(w, c) != -1) {
return 0;
}
int wt_init(int w, int h, struct wt_graphics *gfx)
{
+ wt->root = 0;
if(!(wt->root = wt_alloc_widget(0))) {
return -1;
}
{
}
+void wt_draw_tree(wt_widget *tree)
+{
+ int i;
+
+ if(tree->draw) {
+ tree->draw(tree);
+ }
+
+ for(i=0; i<tree->num_child; i++) {
+ wt_draw_tree(tree->child[i]);
+ }
+}
+
+void wt_draw(void)
+{
+ wt_draw_tree(wt->root);
+}
+
void wt_gfx_color(int cidx)
{
wt->gfx.color(wt->colors[cidx]);
void wt_inp_mouse(int bn, int st, int x, int y);
void wt_inp_motion(int x, int y);
+void wt_draw(void);
+
wt_widget *wt_alloc_widget(wt_widget *par);
void wt_free_widget(wt_widget *w);
void wt_free_tree(wt_widget *tree);
int *wt_position(wt_widget *w, int *xret, int *yret);
int *wt_size(wt_widget *w, int *xret, int *yret);
+int wt_hittest(wt_widget *w, int x, int y);
+wt_widget *wt_widget_at(int x, int y);
+
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);