draw window frame
[windtk] / src / window.c
index d0d8d74..cd39284 100644 (file)
@@ -20,10 +20,62 @@ wt_widget *wt_window(wt_widget *par, const char *title, int style, int x, int y,
        return w;
 }
 
+#define FRMTHICK       1
+#define FRMBEVEL       1
+#define FRMOFFS                (FRMTHICK + FRMBEVEL * 2)
+#define TBARTHICK      12      /* TODO: base it on font metrics */
+#define TBAROFFS       (TBARTHICK + FRMBEVEL * 2)
+
 static void draw_win(wt_widget *w, struct wt_graphics *gfx)
 {
+       struct wt_rect fr, tmprect;
+       int frmcol = COL_FFRM;//wt->focuswin == w ? COL_FFRM : COL_FRM;
+
        wt_gfx_color(COL_BG);
        wt_gfx_fillrect(&w->rect);
+
+       fr.x = w->rect.x - FRMOFFS;
+       fr.y = w->rect.y - TBAROFFS - FRMOFFS;
+       fr.width = w->rect.width + FRMOFFS * 2;
+       fr.height = w->rect.height + TBAROFFS + FRMOFFS * 2;
+
+       wt_gfx_frame(&fr, FRM_OUT | FRM_NOFILL, frmcol);        /* outer bevel */
+
+       /* draw main frame */
+       wt_gfx_color(frmcol);
+
+       fr.x += FRMBEVEL;
+       fr.y += FRMBEVEL;
+       fr.width -= FRMBEVEL * 2;
+       fr.height -= FRMBEVEL * 2;
+
+       tmprect = fr;
+       tmprect.width = FRMTHICK;
+       wt_gfx_fillrect(&tmprect);      /* left bar */
+       tmprect.x += fr.width - FRMTHICK;
+       wt_gfx_fillrect(&tmprect);      /* right bar */
+
+       tmprect = fr;
+       tmprect.height = FRMTHICK;
+       tmprect.x += FRMTHICK;
+       tmprect.width -= FRMTHICK * 2;
+       wt_gfx_fillrect(&tmprect);      /* top bar */
+       tmprect.y += fr.height - FRMTHICK;
+       wt_gfx_fillrect(&tmprect);      /* bottom bar */
+
+       /* inner bevel */
+       fr.x += FRMTHICK;
+       fr.y += FRMTHICK;
+       fr.width -= FRMTHICK * 2;
+       fr.height -= FRMTHICK * 2;
+       wt_gfx_frame(&fr, FRM_IN | FRM_NOFILL, frmcol);
+
+       /* titlebar */
+       fr.x = w->rect.x;
+       fr.width = w->rect.width;
+       fr.y += FRMBEVEL;
+       fr.height = TBARTHICK + FRMBEVEL * 2;
+       wt_gfx_frame(&fr, FRM_OUT, frmcol);
 }
 
 static void use_theme(wt_widget *w, struct wt_theme *theme)