chiark / gitweb /
New option: movres.ignore_transience.
[e16] / dox / dox.h
1 /*
2  * Copyright (C) 2000-2007 Carsten Haitzler, Geoff Harrison and various contributors
3  * Copyright (C) 2007-2008 Kim Woelders
4  *
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:
11  *
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.
16  *
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.
23  */
24 #include "config.h"
25
26 #include <X11/Xlib.h>
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>
33 #include <stdio.h>
34 #include <stdlib.h>
35 #include <unistd.h>
36 #include <stdarg.h>
37 #include <string.h>
38 #include <fcntl.h>
39 #include <dirent.h>
40 #include <signal.h>
41 #include <time.h>
42 #include <math.h>
43 #include <pwd.h>
44 #include <sys/stat.h>
45 #include <sys/types.h>
46 #include <sys/wait.h>
47 #include <sys/stat.h>
48 #include <sys/resource.h>
49 #include <sys/ipc.h>
50 #include <sys/shm.h>
51
52 #include <Imlib2.h>
53
54 #define EAllocColor(pxc) \
55         XAllocColor(disp, VRoot.cmap, pxc)
56
57 #ifndef MAX
58 #define MAX(a,b)  ((a)>(b)?(a):(b))
59 #endif
60
61 #if defined(HAVE_WCTYPE_H) && defined(HAVE_WCHAR_T) && !defined(__FreeBSD__)
62 #define USE_WORD_MB
63 #endif
64
65 #define USE_XFONT 0
66
67 typedef struct _efont Efont;
68
69 typedef struct _root {
70    Window              win;
71    Visual             *vis;
72    unsigned int        depth;
73    Colormap            cmap;
74    int                 scr;
75    unsigned int        w, h;
76 } Root;
77
78 typedef struct _textstate {
79    char               *fontname;
80    XColor              fg_col;
81    XColor              bg_col;
82    int                 effect;
83    Efont              *efont;
84 #if USE_XFONT
85    XFontStruct        *xfont;
86 #endif
87    XFontSet            xfontset;
88    int                 xfontset_ascent;
89    int                 height;
90 } TextState;
91
92 typedef struct _link {
93    char               *name;
94    int                 x, y, w, h;
95    struct _link       *next;
96 } Link;
97
98 /* dox.c */
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);
102
103 /* ttfont.c */
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);
115
116 /* text.c */
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,
122                              int justification);
123
124 /* file.c */
125 int                 exists(char *s);
126 void                freestrlist(char **l, int num);
127 void                word(char *s, int num, char *wd);
128
129 #ifdef USE_WORD_MB
130 void                word_mb(char *s, int num, char *wd, int *spaceflag);
131 #endif
132 int                 findLocalizedFile(char *fname);
133
134 /* format.c */
135 int                 GetObjects(FILE * f);
136 int                 FixPage(int p);
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);
140
141 extern Display     *disp;
142 extern Root         VRoot;
143 extern char        *docdir;
144
145 #define Emalloc     malloc
146 #define Erealloc    realloc
147 #if HAVE_FREE_NULL_BUG
148 #define Efree(p)    if (p) free(p)
149 #else
150 #define Efree       free
151 #endif
152
153 #define EMALLOC(type, num) (type*)Emalloc((num)*sizeof(type))
154 #define EREALLOC(type, ptr, num) (type*)Erealloc(ptr, (num)*sizeof(type))
155
156 #define Esnprintf snprintf