3 static void draw_win(wt_widget *w, struct wt_graphics *gfx);
4 static void use_theme(wt_widget *w, struct wt_theme *theme);
6 wt_widget *wt_window(wt_widget *par, const char *title, int style, int x, int y, int xsz, int ysz)
10 if(!(w = wt_alloc_widget(par))) {
13 w->type = WT_TYPE_WINDOW;
14 wt_set_text(w, title);
16 wt_resize(w, xsz, ysz);
19 use_theme(w, wt->theme);
25 #define FRMOFFS (FRMTHICK + FRMBEVEL * 2)
26 #define TBARTHICK 12 /* TODO: base it on font metrics */
27 #define TBAROFFS (TBARTHICK + FRMBEVEL * 2)
29 static void draw_win(wt_widget *w, struct wt_graphics *gfx)
31 struct wt_rect fr, tmprect;
32 int frmcol = COL_FFRM;//wt->focuswin == w ? COL_FFRM : COL_FRM;
35 wt_gfx_fillrect(&w->rect);
37 fr.x = w->rect.x - FRMOFFS;
38 fr.y = w->rect.y - TBAROFFS - FRMOFFS;
39 fr.width = w->rect.width + FRMOFFS * 2;
40 fr.height = w->rect.height + TBAROFFS + FRMOFFS * 2;
42 wt_gfx_frame(&fr, FRM_OUT | FRM_NOFILL, frmcol); /* outer bevel */
49 fr.width -= FRMBEVEL * 2;
50 fr.height -= FRMBEVEL * 2;
53 tmprect.width = FRMTHICK;
54 wt_gfx_fillrect(&tmprect); /* left bar */
55 tmprect.x += fr.width - FRMTHICK;
56 wt_gfx_fillrect(&tmprect); /* right bar */
59 tmprect.height = FRMTHICK;
60 tmprect.x += FRMTHICK;
61 tmprect.width -= FRMTHICK * 2;
62 wt_gfx_fillrect(&tmprect); /* top bar */
63 tmprect.y += fr.height - FRMTHICK;
64 wt_gfx_fillrect(&tmprect); /* bottom bar */
69 fr.width -= FRMTHICK * 2;
70 fr.height -= FRMTHICK * 2;
71 wt_gfx_frame(&fr, FRM_IN | FRM_NOFILL, frmcol);
75 fr.width = w->rect.width;
77 fr.height = TBARTHICK + FRMBEVEL * 2;
78 wt_gfx_frame(&fr, FRM_OUT, frmcol);
81 static void use_theme(wt_widget *w, struct wt_theme *theme)
83 w->draw = theme && theme->draw_window ? theme->draw_window : draw_win;