theme
[windtk] / src / window.c
1 #include "wtimpl.h"
2
3 static void draw_win(wt_widget *w, struct wt_graphics *gfx);
4 static void use_theme(wt_widget *w, struct wt_theme *theme);
5
6 wt_widget *wt_window(wt_widget *par, const char *title, int style, int x, int y, int xsz, int ysz)
7 {
8         wt_widget *w;
9
10         if(!(w = wt_alloc_widget(par))) {
11                 return 0;
12         }
13         w->type = WT_TYPE_WINDOW;
14         wt_set_text(w, title);
15         wt_move(w, x, y);
16         wt_resize(w, xsz, ysz);
17         /* TODO: style */
18
19         use_theme(w, wt->theme);
20         return w;
21 }
22
23 static void draw_win(wt_widget *w, struct wt_graphics *gfx)
24 {
25         wt_gfx_color(COL_BG);
26         wt_gfx_fillrect(&w->rect);
27 }
28
29 static void use_theme(wt_widget *w, struct wt_theme *theme)
30 {
31         w->draw = theme && theme->draw_window ? theme->draw_window : draw_win;
32 }