glutMotionFunc(motion);
glutPassiveMotionFunc(motion);
+ glClearColor(0.6, 0.6, 0.6, 1);
+
if(wt_init(800, 600, &gfx)) {
return 1;
}
- wt_window(0, "foo", WT_WS_DEFAULT, 10, 10, 200, 200);
+ wt_window(0, "foo", WT_WS_DEFAULT, 100, 100, 200, 200);
glutMainLoop();
return 0;
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)
static unsigned int def_colors[] = {
0xf0f0f0, /* font/foreground */
- 0x333333, /* background */
- 0x444444, /* highlight */
- 0x222222, /* shadow */
+ 0x444444, /* background */
+ 0x555555, /* highlight */
+ 0x333333, /* shadow */
0x403065, /* inactive frame */
0x54349c, /* inactive frame highlight */
0x221e2c, /* inactive frame shadow */
void wt_viewport(int x, int y, int w, int h)
{
- wt_setrect(&wt->vp, x, y, w, h);
+ wt_rect(&wt->vp, x, y, w, h);
wt_move(wt->root, x, y);
wt_resize(wt->root, w, h);
}
wt->gfx.fillrect(r);
}
+void wt_gfx_fillrect4i(int x, int y, int w, int h)
+{
+ struct wt_rect r;
+ wt_rect(&r, x, y, w, h);
+ wt->gfx.fillrect(&r);
+}
+
void wt_gfx_frame(struct wt_rect *r, int style, int basecol)
{
- wt_gfx_color(basecol);
- wt_gfx_fillrect(r);
- wt_gfx_color(style == FRM_OUT ? basecol + 2 : basecol + 1);
- wt_gfx_line(r->x, r->y + r->height, r->x + r->width - 1, r->y + r->height);
- wt_gfx_line(r->x + r->width, r->y + 1, r->x + r->width, r->y + r->height);
- wt_gfx_color(style == FRM_OUT ? basecol + 1 : basecol + 2);
- wt_gfx_line(r->x, r->y, r->x + r->width, r->y);
- wt_gfx_line(r->x, r->y + 1, r->x, r->y + r->height - 1);
+ if((style & FRM_NOFILL) == 0) {
+ wt_gfx_color(basecol);
+ wt_gfx_fillrect(r);
+ }
+ wt_gfx_color(FRMSTYLE(style) == FRM_OUT ? basecol + 2 : basecol + 1);
+ wt_gfx_fillrect4i(r->x + 1, r->y + r->height - 1, r->width - 2, 1);
+ wt_gfx_fillrect4i(r->x + r->width - 1, r->y, 1, r->height);
+ wt_gfx_color(FRMSTYLE(style) == FRM_OUT ? basecol + 1 : basecol + 2);
+ wt_gfx_fillrect4i(r->x + 1, r->y, r->width - 2, 1);
+ wt_gfx_fillrect4i(r->x, r->y, 1, r->height);
}
void wt_gfx_line(int x0, int y0, int x1, int y1)
wt->gfx.line(x0, y0, x1, y1);
}
-void wt_setrect(struct wt_rect *r, int x, int y, int w, int h)
+void wt_rect(struct wt_rect *r, int x, int y, int w, int h)
{
r->x = x;
r->y = y;