4 * Copyright (c) Tuomo Valkonen 1999-2009.
6 * See the included file LICENSE for details.
9 #ifndef ION_IONCORE_GR_H
10 #define ION_IONCORE_GR_H
12 #include <libtu/stringstore.h>
15 #include "rectangle.h"
28 #define GR_FONT_EXTENTS_INIT {0, 0, 0}
36 #define GR_BORDER_WIDTHS_INIT {0, 0, 0, 0, 0, 0, 0}
39 uint top
, bottom
, left
, right
;
40 uint tb_ileft
, tb_iright
;
44 typedef StringId GrAttr
;
46 #define GRATTR_NONE STRINGID_NONE
48 #define GR_STYLESPEC_INIT {0, NULL}
60 #define GR_TEXTELEM_INIT {NULL, 0, GR_STYLESPEC_INIT}
71 GR_TRANSPARENCY_DEFAULT
82 /* Flags to grbrush_begin */
83 #define GRBRUSH_AMEND 0x0001
84 #define GRBRUSH_NEED_CLIP 0x0004
85 #define GRBRUSH_NO_CLEAR_OK 0x0008 /* implied by GRBRUSH_AMEND */
86 #define GRBRUSH_KEEP_ATTR 0x0010
90 typedef GrBrush
*GrGetBrushFn(Window win
, WRootWin
*rootwin
,
93 extern bool gr_register_engine(const char *engine
, GrGetBrushFn
*fn
);
94 extern void gr_unregister_engine(const char *engine
);
95 extern bool gr_select_engine(const char *engine
);
96 extern void gr_refresh();
97 extern void gr_read_config();
99 /* Every star ('*') element of 'spec' increases score by one.
100 * Every other element of 'spec' found in 'attr' increases the score by the
101 * number set in attr times two. Any element of 'spec' (other than star),
102 * not found in 'attr', forces score to zero.
104 extern uint
gr_stylespec_score(const GrStyleSpec
*spec
, const GrStyleSpec
*attr
);
105 extern uint
gr_stylespec_score2(const GrStyleSpec
*spec
, const GrStyleSpec
*attr
,
106 const GrStyleSpec
*attr2
);
108 extern void gr_stylespec_init(GrStyleSpec
*spec
);
109 extern bool gr_stylespec_set(GrStyleSpec
*spec
, GrAttr a
);
110 extern bool gr_stylespec_isset(const GrStyleSpec
*spec
, GrAttr a
);
111 extern void gr_stylespec_unset(GrStyleSpec
*spec
, GrAttr a
);
112 extern bool gr_stylespec_add(GrStyleSpec
*spec
, GrAttr a
, uint score
);
113 extern bool gr_stylespec_append(GrStyleSpec
*dst
, const GrStyleSpec
*src
);
114 extern void gr_stylespec_unalloc(GrStyleSpec
*spec
);
115 extern bool gr_stylespec_equals(const GrStyleSpec
*s1
, const GrStyleSpec
*s2
);
116 extern bool gr_stylespec_load(GrStyleSpec
*spec
, const char *str
);
117 extern bool gr_stylespec_load_(GrStyleSpec
*spec
, const char *str
,
118 bool no_order_score
);
122 extern GrBrush
*gr_get_brush(Window win
, WRootWin
*rootwin
,
125 DYNFUN GrBrush
*grbrush_get_slave(GrBrush
*brush
, WRootWin
*rootwin
,
128 extern void grbrush_release(GrBrush
*brush
);
130 extern bool grbrush_init(GrBrush
*brush
);
131 extern void grbrush_deinit(GrBrush
*brush
);
133 DYNFUN
void grbrush_begin(GrBrush
*brush
, const WRectangle
*geom
,
135 DYNFUN
void grbrush_end(GrBrush
*brush
);
139 DYNFUN
void grbrush_init_attr(GrBrush
*brush
, const GrStyleSpec
*spec
);
140 DYNFUN
void grbrush_set_attr(GrBrush
*brush
, GrAttr attr
);
141 DYNFUN
void grbrush_unset_attr(GrBrush
*brush
, GrAttr attr
);
145 DYNFUN
void grbrush_get_border_widths(GrBrush
*brush
, GrBorderWidths
*bdi
);
147 DYNFUN
void grbrush_draw_border(GrBrush
*brush
, const WRectangle
*geom
);
148 DYNFUN
void grbrush_draw_borderline(GrBrush
*brush
, const WRectangle
*geom
,
153 DYNFUN
void grbrush_get_font_extents(GrBrush
*brush
, GrFontExtents
*fnti
);
155 DYNFUN uint
grbrush_get_text_width(GrBrush
*brush
, const char *text
, uint len
);
157 DYNFUN
void grbrush_draw_string(GrBrush
*brush
, int x
, int y
,
158 const char *str
, int len
, bool needfill
);
160 /* Textbox drawing */
162 DYNFUN
void grbrush_draw_textbox(GrBrush
*brush
, const WRectangle
*geom
,
163 const char *text
, bool needfill
);
165 DYNFUN
void grbrush_draw_textboxes(GrBrush
*brush
, const WRectangle
*geom
,
166 int n
, const GrTextElem
*elem
,
171 /* Behaviour of the following two functions for "slave brushes" is undefined.
172 * If the parameter rough to grbrush_set_window_shape is set, the actual
173 * shape may be changed for corner smoothing and other superfluous effects.
174 * (This feature is only used by floatframes.)
176 DYNFUN
void grbrush_set_window_shape(GrBrush
*brush
, bool rough
,
177 int n
, const WRectangle
*rects
);
179 DYNFUN
void grbrush_enable_transparency(GrBrush
*brush
, GrTransparency mode
);
181 DYNFUN
void grbrush_fill_area(GrBrush
*brush
, const WRectangle
*geom
);
182 DYNFUN
void grbrush_clear_area(GrBrush
*brush
, const WRectangle
*geom
);
184 DYNFUN
bool grbrush_get_extra(GrBrush
*brush
, const char *key
,
185 char type
, void *data
);
187 #endif /* ION_IONCORE_GR_H */