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 */
wt->root = 0;
}
+struct wt_theme *wt_load_theme(const char *path)
+{
+ return 0; /* TODO */
+}
+
+void wt_unload_theme(struct wt_theme *theme)
+{
+}
+
+static void use_theme(wt_widget *w, struct wt_theme *theme)
+{
+ int i;
+
+ if(w->use_theme) {
+ w->use_theme(w, theme);
+ }
+
+ for(i=0; i<w->num_child; i++) {
+ use_theme(w->child[i], theme);
+ }
+}
+
+void wt_use_theme(struct wt_theme *theme)
+{
+ wt->theme = theme;
+ use_theme(wt->root, theme);
+}
+
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);
}
int i;
if(tree->draw) {
- tree->draw(tree);
+ tree->draw(tree, &wt->gfx);
}
for(i=0; i<tree->num_child; i++) {
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;