4 * Copyright (c) Tuomo Valkonen 1999-2005.
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
, const char *stylename
, DEStyle
*style
)
35 brush
->extras_fn
=NULL
;
40 if(!grbrush_init(&(brush
->grbrush
))){
45 if(MATCHES("tab-frame", stylename
)){
46 brush
->extras_fn
=debrush_tab_extras
;
47 if(!style
->tabbrush_data_ok
)
48 destyle_create_tab_gcs(style
);
49 }else if(MATCHES("tab-menuentry", stylename
)){
50 brush
->extras_fn
=debrush_menuentry_extras
;
51 brush
->indicator_w
=grbrush_get_text_width((GrBrush
*)brush
,
60 DEBrush
*create_debrush(const char *stylename
, DEStyle
*style
)
62 CREATEOBJ_IMPL(DEBrush
, debrush
, (p
, stylename
, style
));
66 static DEBrush
*do_get_brush(WRootWin
*rootwin
, Window win
,
67 const char *stylename
, bool slave
)
69 DEStyle
*style
=de_get_style(rootwin
, stylename
);
75 brush
=create_debrush(stylename
, style
);
77 /* Set background colour */
78 if(brush
!=NULL
&& !slave
){
79 grbrush_enable_transparency(&(brush
->grbrush
), win
,
80 GR_TRANSPARENCY_DEFAULT
);
87 DEBrush
*de_get_brush(WRootWin
*rootwin
, Window win
, const char *stylename
)
89 return do_get_brush(rootwin
, win
, stylename
, FALSE
);
93 DEBrush
*debrush_get_slave(DEBrush
*master
, WRootWin
*rootwin
,
94 Window win
, const char *stylename
)
96 return do_get_brush(rootwin
, win
, stylename
, TRUE
);
100 void debrush_deinit(DEBrush
*brush
)
102 destyle_unref(brush
->d
);
104 grbrush_deinit(&(brush
->grbrush
));
108 void debrush_release(DEBrush
*brush
, Window win
)
110 destroy_obj((Obj
*)brush
);
117 /*{{{ Border widths and extra information */
120 void debrush_get_border_widths(DEBrush
*brush
, GrBorderWidths
*bdw
)
122 DEStyle
*style
=brush
->d
;
123 DEBorder
*bd
=&(style
->border
);
128 case DEBORDER_GROOVE
:
129 tmp
=bd
->sh
+bd
->hl
+bd
->pad
;
130 bdw
->top
=tmp
; bdw
->bottom
=tmp
; bdw
->left
=tmp
; bdw
->right
=tmp
;
132 case DEBORDER_INLAID
:
133 tmp
=bd
->sh
+bd
->pad
; bdw
->top
=tmp
; bdw
->left
=tmp
;
134 tmp
=bd
->hl
+bd
->pad
; bdw
->bottom
=tmp
; bdw
->right
=tmp
;
136 case DEBORDER_ELEVATED
:
138 tmp
=bd
->hl
+bd
->pad
; bdw
->top
=tmp
; bdw
->left
=tmp
;
139 tmp
=bd
->sh
+bd
->pad
; bdw
->bottom
=tmp
; bdw
->right
=tmp
;
143 bdw
->tb_ileft
=bdw
->left
;
144 bdw
->tb_iright
=bdw
->right
;
145 bdw
->spacing
=style
->spacing
;
147 bdw
->right
+=brush
->indicator_w
;
148 bdw
->tb_iright
+=brush
->indicator_w
;
152 bool debrush_get_extra(DEBrush
*brush
, const char *key
, char type
, void *data
)
154 DEStyle
*style
=brush
->d
;
156 if(extl_table_get(style
->data_table
, 's', type
, key
, data
))
158 style
=style
->based_on
;
168 /*{{{ Class implementation */
171 static DynFunTab debrush_dynfuntab
[]={
172 {grbrush_release
, debrush_release
},
173 {grbrush_draw_border
, debrush_draw_border
},
174 {grbrush_draw_borderline
, debrush_draw_borderline
},
175 {grbrush_get_border_widths
, debrush_get_border_widths
},
176 {grbrush_draw_string
, debrush_draw_string
},
177 {debrush_do_draw_string
, debrush_do_draw_string_default
},
178 {grbrush_get_font_extents
, debrush_get_font_extents
},
179 {(DynFun
*)grbrush_get_text_width
, (DynFun
*)debrush_get_text_width
},
180 {grbrush_draw_textbox
, debrush_draw_textbox
},
181 {grbrush_draw_textboxes
, debrush_draw_textboxes
},
182 {grbrush_set_clipping_rectangle
, debrush_set_clipping_rectangle
},
183 {grbrush_clear_clipping_rectangle
, debrush_clear_clipping_rectangle
},
184 {grbrush_set_window_shape
, debrush_set_window_shape
},
185 {grbrush_enable_transparency
, debrush_enable_transparency
},
186 {grbrush_clear_area
, debrush_clear_area
},
187 {grbrush_fill_area
, debrush_fill_area
},
188 {(DynFun
*)grbrush_get_extra
, (DynFun
*)debrush_get_extra
},
189 {(DynFun
*)grbrush_get_slave
, (DynFun
*)debrush_get_slave
},
194 IMPLCLASS(DEBrush
, GrBrush
, debrush_deinit
, debrush_dynfuntab
);