4 * Copyright (c) Tuomo Valkonen 1999-2007.
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.
12 #ifndef ION_IONCORE_GR_H
13 #define ION_IONCORE_GR_H
15 #include <libtu/stringstore.h>
18 #include "rectangle.h"
31 #define GR_FONT_EXTENTS_INIT {0, 0, 0}
39 #define GR_BORDER_WIDTHS_INIT {0, 0, 0, 0, 0, 0, 0}
42 uint top, bottom, left, right;
43 uint tb_ileft, tb_iright;
47 typedef StringId GrAttr;
49 #define GRATTR_NONE STRINGID_NONE
51 #define GR_STYLESPEC_INIT {0, NULL}
63 #define GR_TEXTELEM_INIT {NULL, 0, GR_STYLESPEC_INIT}
74 GR_TRANSPARENCY_DEFAULT
85 /* Flags to grbrush_begin */
86 #define GRBRUSH_AMEND 0x0001
87 #define GRBRUSH_NEED_CLIP 0x0004
88 #define GRBRUSH_NO_CLEAR_OK 0x0008 /* implied by GRBRUSH_AMEND */
89 #define GRBRUSH_KEEP_ATTR 0x0010
93 typedef GrBrush *GrGetBrushFn(Window win, WRootWin *rootwin,
96 extern bool gr_register_engine(const char *engine, GrGetBrushFn *fn);
97 extern void gr_unregister_engine(const char *engine);
98 extern bool gr_select_engine(const char *engine);
99 extern void gr_refresh();
100 extern void gr_read_config();
102 /* Every star ('*') element of 'spec' increases score by one.
103 * Every other element of 'spec' found in 'attr' increases the score by the
104 * number set in attr times two. Any element of 'spec' (other than star),
105 * not found in 'attr', forces score to zero.
107 extern uint gr_stylespec_score(const GrStyleSpec *spec, const GrStyleSpec *attr);
108 extern uint gr_stylespec_score2(const GrStyleSpec *spec, const GrStyleSpec *attr,
109 const GrStyleSpec *attr2);
111 extern void gr_stylespec_init(GrStyleSpec *spec);
112 extern bool gr_stylespec_set(GrStyleSpec *spec, GrAttr a);
113 extern void gr_stylespec_unset(GrStyleSpec *spec, GrAttr a);
114 extern bool gr_stylespec_add(GrStyleSpec *spec, GrAttr a, uint score);
115 extern bool gr_stylespec_append(GrStyleSpec *dst, const GrStyleSpec *src);
116 extern void gr_stylespec_unalloc(GrStyleSpec *spec);
117 extern bool gr_stylespec_equals(const GrStyleSpec *s1, const GrStyleSpec *s2);
118 extern bool gr_stylespec_load(GrStyleSpec *spec, const char *str);
119 extern bool gr_stylespec_load_(GrStyleSpec *spec, const char *str,
120 bool no_order_score);
124 extern GrBrush *gr_get_brush(Window win, WRootWin *rootwin,
127 DYNFUN GrBrush *grbrush_get_slave(GrBrush *brush, WRootWin *rootwin,
130 extern void grbrush_release(GrBrush *brush);
132 extern bool grbrush_init(GrBrush *brush);
133 extern void grbrush_deinit(GrBrush *brush);
135 DYNFUN void grbrush_begin(GrBrush *brush, const WRectangle *geom,
137 DYNFUN void grbrush_end(GrBrush *brush);
141 DYNFUN void grbrush_init_attr(GrBrush *brush, const GrStyleSpec *spec);
142 DYNFUN void grbrush_set_attr(GrBrush *brush, GrAttr attr);
143 DYNFUN void grbrush_unset_attr(GrBrush *brush, GrAttr attr);
147 DYNFUN void grbrush_get_border_widths(GrBrush *brush, GrBorderWidths *bdi);
149 DYNFUN void grbrush_draw_border(GrBrush *brush, const WRectangle *geom);
150 DYNFUN void grbrush_draw_borderline(GrBrush *brush, const WRectangle *geom,
155 DYNFUN void grbrush_get_font_extents(GrBrush *brush, GrFontExtents *fnti);
157 DYNFUN uint grbrush_get_text_width(GrBrush *brush, const char *text, uint len);
159 DYNFUN void grbrush_draw_string(GrBrush *brush, int x, int y,
160 const char *str, int len, bool needfill);
162 /* Textbox drawing */
164 DYNFUN void grbrush_draw_textbox(GrBrush *brush, const WRectangle *geom,
165 const char *text, bool needfill);
167 DYNFUN void grbrush_draw_textboxes(GrBrush *brush, const WRectangle *geom,
168 int n, const GrTextElem *elem,
173 /* Behaviour of the following two functions for "slave brushes" is undefined.
174 * If the parameter rough to grbrush_set_window_shape is set, the actual
175 * shape may be changed for corner smoothing and other superfluous effects.
176 * (This feature is only used by floatframes.)
178 DYNFUN void grbrush_set_window_shape(GrBrush *brush, bool rough,
179 int n, const WRectangle *rects);
181 DYNFUN void grbrush_enable_transparency(GrBrush *brush, GrTransparency mode);
183 DYNFUN void grbrush_fill_area(GrBrush *brush, const WRectangle *geom);
184 DYNFUN void grbrush_clear_area(GrBrush *brush, const WRectangle *geom);
186 DYNFUN bool grbrush_get_extra(GrBrush *brush, const char *key,
187 char type, void *data);
189 #endif /* ION_IONCORE_GR_H */