2 * Copyright (C) 2000-2007 Carsten Haitzler, Geoff Harrison and various contributors
3 * Copyright (C) 2007-2008 Kim Woelders
5 * Permission is hereby granted, free of charge, to any person obtaining a copy
6 * of this software and associated documentation files (the "Software"), to
7 * deal in the Software without restriction, including without limitation the
8 * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
9 * sell copies of the Software, and to permit persons to whom the Software is
10 * furnished to do so, subject to the following conditions:
12 * The above copyright notice and this permission notice shall be included in
13 * all copies of the Software, its documentation and marketing & publicity
14 * materials, and acknowledgment shall be given in the documentation, materials
15 * and software packages that this Software was used.
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20 * THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
21 * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
22 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
27 #include <X11/Xutil.h>
28 #include <X11/Xproto.h>
29 #include <X11/Xlocale.h>
30 #include <X11/cursorfont.h>
31 #include <X11/extensions/shape.h>
32 #include <X11/extensions/XShm.h>
45 #include <sys/types.h>
48 #include <sys/resource.h>
54 #define EAllocColor(pxc) \
55 XAllocColor(disp, VRoot.cmap, pxc)
58 #define MAX(a,b) ((a)>(b)?(a):(b))
61 #if defined(HAVE_WCTYPE_H) && defined(HAVE_WCHAR_T) && !defined(__FreeBSD__)
67 typedef struct _efont Efont;
69 typedef struct _root {
78 typedef struct _textstate {
92 typedef struct _link {
99 Imlib_Image ImageLoadDoc(const char *file);
100 void ESetColor(XColor * pxc, int r, int g, int b);
101 void EGetColor(XColor * pxc, int *pr, int *pg, int *pb);
104 void Efont_extents(Efont * f, const char *text,
105 int *font_ascent_return,
106 int *font_descent_return, int *width_return,
107 int *max_ascent_return,
108 int *max_descent_return,
109 int *lbearing_return, int *rbearing_return);
110 Efont *Efont_load(const char *file, int size);
111 void Efont_free(Efont * f);
112 void EFont_draw_string(Display * disp, Drawable win, GC gc,
113 int x, int y, const char *text,
114 Efont * font, Visual * vis, Colormap cm);
117 void TextStateLoadFont(TextState * ts);
118 void TextSize(TextState * ts, const char *text,
119 int *width, int *height, int fsize);
120 void TextDraw(TextState * ts, Window win, char *text,
121 int x, int y, int w, int h, int fsize,
126 void freestrlist(char **l, int num);
127 void word(char *s, int num, char *wd);
130 void word_mb(char *s, int num, char *wd, int *spaceflag);
132 int findLocalizedFile(char *fname);
135 int GetObjects(FILE * f);
137 int GetPage(char *name);
138 void GetLinkColors(int page_num, int *r, int *g, int *b);
139 Link *RenderPage(Window win, int page_num, int w, int h);
141 extern Display *disp;
145 #define Emalloc malloc
146 #define Erealloc realloc
147 #if HAVE_FREE_NULL_BUG
148 #define Efree(p) if (p) free(p)
153 #define EMALLOC(type, num) (type*)Emalloc((num)*sizeof(type))
154 #define EREALLOC(type, ptr, num) (type*)Erealloc(ptr, (num)*sizeof(type))
156 #define Esnprintf snprintf