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 void calc_window_rect(struct wt_rect *r, wt_widget *w)
31 r->x = w->rect.x - FRMOFFS;
32 r->y = w->rect.y - TBAROFFS - FRMOFFS;
33 r->w = w->rect.w + FRMOFFS * 2;
34 r->h = w->rect.h + TBAROFFS + FRMOFFS * 2;
37 static void draw_win(wt_widget *w, struct wt_graphics *gfx)
39 struct wt_rect fr, tmprect;
40 int frmcol = COL_FFRM;//wt->focuswin == w ? COL_FFRM : COL_FRM;
43 wt_gfx_fillrect(&w->rect);
45 calc_window_rect(&fr, w);
47 wt_gfx_frame(&fr, FRM_OUT | FRM_NOFILL, frmcol); /* outer bevel */
59 wt_gfx_fillrect(&tmprect); /* left bar */
60 tmprect.x += fr.w - FRMTHICK;
61 wt_gfx_fillrect(&tmprect); /* right bar */
65 tmprect.x += FRMTHICK;
66 tmprect.w -= FRMTHICK * 2;
67 wt_gfx_fillrect(&tmprect); /* top bar */
68 tmprect.y += fr.h - FRMTHICK;
69 wt_gfx_fillrect(&tmprect); /* bottom bar */
76 wt_gfx_frame(&fr, FRM_IN | FRM_NOFILL, frmcol);
82 fr.h = TBARTHICK + FRMBEVEL * 2;
83 wt_gfx_frame(&fr, FRM_OUT, frmcol);
86 static void use_theme(wt_widget *w, struct wt_theme *theme)
88 w->draw = theme && theme->draw_window ? theme->draw_window : draw_win;