3 static void draw_win(ag_widget *w, struct ag_graphics *gfx);
4 static void use_theme(ag_widget *w, struct ag_theme *theme);
6 ag_widget *ag_window(ag_widget *par, const char *title, int style, int x, int y, int xsz, int ysz)
10 if(!(w = ag_alloc_widget(par))) {
13 w->type = AG_TYPE_WINDOW;
14 ag_set_text(w, title);
16 ag_resize(w, xsz, ysz);
19 use_theme(w, ag->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 ag_calc_window_rect(struct ag_rect *r, ag_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(ag_widget *w, struct ag_graphics *gfx)
39 struct ag_rect fr, tmprect;
40 int frmcol = COL_FFRM;//ag->focuswin == w ? COL_FFRM : COL_FRM;
43 ag_gfx_fillrect(&w->rect);
45 ag_calc_window_rect(&fr, w);
47 ag_gfx_frame(&fr, FRM_OUT | FRM_NOFILL, frmcol); /* outer bevel */
59 ag_gfx_fillrect(&tmprect); /* left bar */
60 tmprect.x += fr.w - FRMTHICK;
61 ag_gfx_fillrect(&tmprect); /* right bar */
65 tmprect.x += FRMTHICK;
66 tmprect.w -= FRMTHICK * 2;
67 ag_gfx_fillrect(&tmprect); /* top bar */
68 tmprect.y += fr.h - FRMTHICK;
69 ag_gfx_fillrect(&tmprect); /* bottom bar */
76 ag_gfx_frame(&fr, FRM_IN | FRM_NOFILL, frmcol);
82 fr.h = TBARTHICK + FRMBEVEL * 2;
83 ag_gfx_frame(&fr, FRM_OUT, frmcol);
86 static void use_theme(ag_widget *w, struct ag_theme *theme)
88 w->draw = theme && theme->draw_window ? theme->draw_window : draw_win;