4 * Copyright (c) Tuomo Valkonen 1999-2006.
6 * Ion is free software; you can redistribute it and/or modify it under
7 * the terms of the GNU Lesser General Public License as published by
8 * the Free Software Foundation; either version 2.1 of the License, or
9 * (at your option) any later version.
14 #include <libtu/objp.h>
15 #include <libextl/extl.h>
17 #include <ioncore/common.h>
18 #include <ioncore/rootwin.h>
19 #include <ioncore/extlconv.h>
20 #include <ioncore/ioncore.h>
29 /*{{{ Brush creation and releasing */
32 bool debrush_init(DEBrush *brush, Window win,
33 const char *stylename, DEStyle *style)
36 brush->extras_fn=NULL;
39 brush->clip_set=FALSE;
43 if(!grbrush_init(&(brush->grbrush))){
48 if(MATCHES("tab-frame", stylename) || MATCHES("tab-info", stylename)){
49 brush->extras_fn=debrush_tab_extras;
50 if(!style->tabbrush_data_ok)
51 destyle_create_tab_gcs(style);
52 }else if(MATCHES("tab-menuentry", stylename)){
53 brush->extras_fn=debrush_menuentry_extras;
54 brush->indicator_w=grbrush_get_text_width((GrBrush*)brush,
63 DEBrush *create_debrush(Window win, const char *stylename, DEStyle *style)
65 CREATEOBJ_IMPL(DEBrush, debrush, (p, win, stylename, style));
69 static DEBrush *do_get_brush(Window win, WRootWin *rootwin,
70 const char *stylename, bool slave)
72 DEStyle *style=de_get_style(rootwin, stylename);
78 brush=create_debrush(win, stylename, style);
80 /* Set background colour */
81 if(brush!=NULL && !slave){
82 grbrush_enable_transparency(&(brush->grbrush),
83 GR_TRANSPARENCY_DEFAULT);
90 DEBrush *de_get_brush(Window win, WRootWin *rootwin, const char *stylename)
92 return do_get_brush(win, rootwin, stylename, FALSE);
96 DEBrush *debrush_get_slave(DEBrush *master, WRootWin *rootwin,
97 const char *stylename)
99 return do_get_brush(master->win, rootwin, stylename, TRUE);
103 void debrush_deinit(DEBrush *brush)
105 destyle_unref(brush->d);
107 grbrush_deinit(&(brush->grbrush));
111 void debrush_release(DEBrush *brush)
113 destroy_obj((Obj*)brush);
120 /*{{{ Border widths and extra information */
123 void debrush_get_border_widths(DEBrush *brush, GrBorderWidths *bdw)
125 DEStyle *style=brush->d;
126 DEBorder *bd=&(style->border);
131 case DEBORDER_GROOVE:
132 tmp=bd->sh+bd->hl+bd->pad;
133 bdw->top=tmp; bdw->bottom=tmp; bdw->left=tmp; bdw->right=tmp;
135 case DEBORDER_INLAID:
136 tmp=bd->sh+bd->pad; bdw->top=tmp; bdw->left=tmp;
137 tmp=bd->hl+bd->pad; bdw->bottom=tmp; bdw->right=tmp;
139 case DEBORDER_ELEVATED:
141 tmp=bd->hl+bd->pad; bdw->top=tmp; bdw->left=tmp;
142 tmp=bd->sh+bd->pad; bdw->bottom=tmp; bdw->right=tmp;
146 bdw->tb_ileft=bdw->left;
147 bdw->tb_iright=bdw->right;
148 bdw->spacing=style->spacing;
150 bdw->right+=brush->indicator_w;
151 bdw->tb_iright+=brush->indicator_w;
155 bool debrush_get_extra(DEBrush *brush, const char *key, char type, void *data)
157 DEStyle *style=brush->d;
159 if(extl_table_get(style->data_table, 's', type, key, data))
161 style=style->based_on;
171 /*{{{ Class implementation */
174 static DynFunTab debrush_dynfuntab[]={
175 {grbrush_release, debrush_release},
176 {grbrush_draw_border, debrush_draw_border},
177 {grbrush_draw_borderline, debrush_draw_borderline},
178 {grbrush_get_border_widths, debrush_get_border_widths},
179 {grbrush_draw_string, debrush_draw_string},
180 {debrush_do_draw_string, debrush_do_draw_string_default},
181 {grbrush_get_font_extents, debrush_get_font_extents},
182 {(DynFun*)grbrush_get_text_width, (DynFun*)debrush_get_text_width},
183 {grbrush_draw_textbox, debrush_draw_textbox},
184 {grbrush_draw_textboxes, debrush_draw_textboxes},
185 {grbrush_set_window_shape, debrush_set_window_shape},
186 {grbrush_enable_transparency, debrush_enable_transparency},
187 {grbrush_clear_area, debrush_clear_area},
188 {grbrush_fill_area, debrush_fill_area},
189 {(DynFun*)grbrush_get_extra, (DynFun*)debrush_get_extra},
190 {(DynFun*)grbrush_get_slave, (DynFun*)debrush_get_slave},
191 {grbrush_begin, debrush_begin},
192 {grbrush_end, debrush_end},
197 IMPLCLASS(DEBrush, GrBrush, debrush_deinit, debrush_dynfuntab);