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.
12 #ifndef ION_IONCORE_GR_H
13 #define ION_IONCORE_GR_H
16 #include "rectangle.h"
29 #define GR_FONT_EXTENTS_INIT {0, 0, 0}
37 #define GR_BORDER_WIDTHS_INIT {0, 0, 0, 0, 0, 0, 0}
40 uint top, bottom, left, right;
41 uint tb_ileft, tb_iright;
54 GR_TRANSPARENCY_DEFAULT
65 /* Flags to grbrush_begin */
66 #define GRBRUSH_AMEND 0x0001
67 #define GRBRUSH_NEED_CLIP 0x0004
68 #define GRBRUSH_NO_CLEAR_OK 0x0008 /* implied by GRBRUSH_AMEND */
72 typedef GrBrush *GrGetBrushFn(Window win, WRootWin *rootwin,
75 extern bool gr_register_engine(const char *engine, GrGetBrushFn *fn);
76 extern void gr_unregister_engine(const char *engine);
77 extern bool gr_select_engine(const char *engine);
78 extern void gr_refresh();
79 extern void gr_read_config();
81 /* Stylespecs are of the from attr1-attr2-etc. We require that each attr in
82 * 'spec' matches the one at same index in 'attrib' when '*' matches anything.
83 * The score increment for exact match is 2*3^index and 1*3^index for '*'
84 * match. If all elements of 'spec' match those of 'attrib' exactly, the
85 * accumulated score is returned. Otherwise the matching fails and zero is
86 * returned. For example:
89 * foo-*-baz foo-bar-baz 2+1*3+2*3^2 = 23
90 * foo-bar foo-bar-baz 2+2*3 = 8
91 * foo-baz foo-bar-baz 0
93 * gr_stylespec_score2 continues matching from attrib_p2 (if not NULL) when
94 * it has reached end of attrib.
96 extern uint gr_stylespec_score(const char *spec, const char *attrib);
97 extern uint gr_stylespec_score2(const char *spec, const char *attrib,
98 const char *attrib_p2);
102 extern GrBrush *gr_get_brush(Window win, WRootWin *rootwin,
105 extern GrBrush *grbrush_get_slave(GrBrush *brush, WRootWin *rootwin,
108 extern void grbrush_release(GrBrush *brush);
110 extern bool grbrush_init(GrBrush *brush);
111 extern void grbrush_deinit(GrBrush *brush);
113 extern void grbrush_begin(GrBrush *brush, const WRectangle *geom,
115 extern void grbrush_end(GrBrush *brush);
119 DYNFUN void grbrush_get_border_widths(GrBrush *brush, GrBorderWidths *bdi);
121 DYNFUN void grbrush_draw_border(GrBrush *brush, const WRectangle *geom,
123 DYNFUN void grbrush_draw_borderline(GrBrush *brush, const WRectangle *geom,
124 const char *attrib, GrBorderLine line);
128 DYNFUN void grbrush_get_font_extents(GrBrush *brush, GrFontExtents *fnti);
130 DYNFUN uint grbrush_get_text_width(GrBrush *brush, const char *text, uint len);
132 DYNFUN void grbrush_draw_string(GrBrush *brush, int x, int y,
133 const char *str, int len, bool needfill,
136 /* Textbox drawing */
138 DYNFUN void grbrush_draw_textbox(GrBrush *brush, const WRectangle *geom,
139 const char *text, const char *attr,
142 DYNFUN void grbrush_draw_textboxes(GrBrush *brush, const WRectangle *geom,
143 int n, const GrTextElem *elem,
144 bool needfill, const char *common_attrib);
148 /* Behaviour of the following two functions for "slave brushes" is undefined.
149 * If the parameter rough to grbrush_set_window_shape is set, the actual
150 * shape may be changed for corner smoothing and other superfluous effects.
151 * (This feature is only used by floatframes.)
153 DYNFUN void grbrush_set_window_shape(GrBrush *brush, bool rough,
154 int n, const WRectangle *rects);
156 DYNFUN void grbrush_enable_transparency(GrBrush *brush, GrTransparency mode);
158 DYNFUN void grbrush_fill_area(GrBrush *brush, const WRectangle *geom,
160 DYNFUN void grbrush_clear_area(GrBrush *brush, const WRectangle *geom);
162 DYNFUN bool grbrush_get_extra(GrBrush *brush, const char *key,
163 char type, void *data);
165 #endif /* ION_IONCORE_GR_H */