Merge branch 'master' into update-with-master
[oweals/cde.git] / cde / lib / DtHelp / il / ilxpmP.h
1 /*
2  * CDE - Common Desktop Environment
3  *
4  * Copyright (c) 1993-2012, The Open Group. All rights reserved.
5  *
6  * These libraries and programs are free software; you can
7  * redistribute them and/or modify them under the terms of the GNU
8  * Lesser General Public License as published by the Free Software
9  * Foundation; either version 2 of the License, or (at your option)
10  * any later version.
11  *
12  * These libraries and programs are distributed in the hope that
13  * they will be useful, but WITHOUT ANY WARRANTY; without even the
14  * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15  * PURPOSE. See the GNU Lesser General Public License for more
16  * details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with these libraries and programs; if not, write
20  * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
21  * Floor, Boston, MA 02110-1301 USA
22  */
23 /* $XConsortium: ilxpmP.h /main/4 1995/10/23 16:03:34 rswiston $ */
24 /* Copyright 1990,91 GROUPE BULL -- See licence conditions in file COPYRIGHT */
25 /*****************************************************************************\
26 * xpmP.h:                                                                     *
27 *                                                                             *
28 *  XPM library                                                                *
29 *  Private Include file                                                       *
30 *                                                                             *
31 *  Developed by Arnaud Le Hors                                                *
32 \*****************************************************************************/
33
34 #ifndef XPMP_h
35 #define XPMP_h
36
37 #ifdef Debug
38 /* memory leak control tool */
39 #include <mnemosyne.h>
40 #endif
41
42 /*
43 #ifdef VMS
44 #include "decw$include:Xlib.h"
45 #include "decw$include:Intrinsic.h"
46 #include "sys$library:stdio.h"
47 #else
48 #include <X11/Xlib.h>
49 #include <X11/Intrinsic.h>
50 #include <stdio.h>
51 #endif
52 */
53
54 #include "ilxpm.h"
55 #ifndef IL_H
56 #include "il.h"
57 #endif
58
59 /* we keep the same codes as for Bitmap management */
60 /*
61 #ifndef _XUTIL_H_
62 #ifdef VMS
63 #include "decw$include:Xutil.h"
64 #else
65 #include <X11/Xutil.h>
66 #endif
67 #endif
68 */
69
70
71 typedef struct {
72     unsigned int type;
73     union {
74         FILE *file;
75         char **data;
76     }     stream;
77     char *cptr;
78     unsigned int line;
79     int CommentLength;
80     char Comment[BUFSIZ];
81     char *Bcmt, *Ecmt, Bos, Eos;
82     unsigned int InsideString;          /* used during parsing: 0 or 1
83                                          * whether we are inside or not */
84 }      xpmData;
85
86 #define XPMARRAY 0
87 #define XPMFILE  1
88 #define XPMPIPE  2
89
90 typedef unsigned char byte;
91
92 #define EOL '\n'
93 #define TAB '\t'
94 #define SPC ' '
95
96 typedef struct {
97     char *type;                         /* key word */
98     char *Bcmt;                         /* string begining comments */
99     char *Ecmt;                         /* string ending comments */
100     char Bos;                           /* character begining strings */
101     char Eos;                           /* character ending strings */
102     char *Strs;                         /* strings separator */
103     char *Dec;                          /* data declaration string */
104     char *Boa;                          /* string begining assignment */
105     char *Eoa;                          /* string ending assignment */
106 }      xpmDataType;
107
108 extern xpmDataType xpmDataTypes[];
109
110 /*
111  * rgb values and ascii names (from rgb text file) rgb values,
112  * range of 0 -> 65535 color mnemonic of rgb value
113  */
114 typedef struct {
115     int r, g, b;
116     char *name;
117 }      xpmRgbName;
118
119 /* Maximum number of rgb mnemonics allowed in rgb text file. */
120 #define MAX_RGBNAMES 1024
121
122 extern char *xpmColorKeys[];
123
124 #define TRANSPARENT_COLOR "None"        /* this must be a string! */
125
126 /* number of xpmColorKeys */
127 #define NKEYS 5
128
129 /*
130  * key numbers for visual type, they must fit along with the number key of
131  * each corresponding element in xpmColorKeys[] defined in xpm.h
132  */
133 #define MONO    2
134 #define GRAY4   3
135 #define GRAY    4
136 #define COLOR   5
137
138 /* structure containing data related to an Xpm pixmap */
139 typedef struct {
140     char *name;
141     unsigned int width;
142     unsigned int height;
143     unsigned int cpp;
144     unsigned int ncolors;
145     char ***colorTable;
146     unsigned int *pixelindex;
147 /*    XColor *xcolors;  */
148     char **colorStrings;
149     unsigned int mask_pixel;            /* mask pixel's colorTable index */
150     unsigned short     *pPalette;       /* color palette derived for xpm Image */
151     short       nPaletteColors;         /* current entry count in palette */
152 }      xpmInternAttrib;
153
154 #define UNDEF_PIXEL 0x80000000
155
156 /* XPM private routines */
157
158 FUNC(xpmCreateImage, int, (ilObject      object,
159                            xpmInternAttrib * attrib,
160                            ilClientImage * image_return,
161                            ilClientImage * shapeimage_return,
162                            XpmAttributes * attributes));
163
164 FUNC(xpmParseData, int, (xpmData * data,
165                          xpmInternAttrib * attrib_return,
166                          XpmAttributes * attributes));
167
168 /* 
169 FUNC(xpmScanImage, int, (Display * display,
170                          XImage * image,
171                          XImage * shapeimage,
172                          XpmAttributes * attributes,
173                          xpmInternAttrib * attrib));
174
175 FUNC(xpmVisualType, int, (Visual * visual));
176 */
177
178 FUNC(xpmFreeColorTable, int, (char ***colorTable, int ncolors));
179
180 FUNC(xpmInitInternAttrib, int, (xpmInternAttrib * coedata));
181
182 FUNC(xpmFreeInternAttrib, int, (xpmInternAttrib * coedata));
183
184 FUNC(xpmSetAttributes, int, (xpmInternAttrib * attrib,
185                              XpmAttributes * attributes));
186
187 FUNC(xpmGetAttributes, int, (XpmAttributes * attributes,
188                              xpmInternAttrib * attrib));
189
190 /* I/O utility */
191
192 FUNC(xpmNextString, int, (xpmData * mdata));
193 FUNC(xpmNextUI, int, (xpmData * mdata, unsigned int *ui_return));
194 FUNC(xpmGetC, int, (xpmData * mdata));
195 FUNC(xpmUngetC, int, (int c, xpmData * mdata));
196 FUNC(xpmNextWord, unsigned int, (xpmData * mdata, char *buf));
197 FUNC(xpmGetCmt, int, (xpmData * mdata, char **cmt));
198 FUNC(xpmReadFile, int, (char *filename, xpmData * mdata));
199 FUNC(xpmWriteFile, int, (char *filename, xpmData * mdata));
200 FUNC(xpmOpenArray, int, (char **data, xpmData * mdata));
201 FUNC(XpmDataClose, int, (xpmData * mdata));
202
203 /* RGB utility */
204  
205 /*
206 FUNC(xpmReadRgbNames, int, (char *rgb_fname, xpmRgbName * rgbn));
207 FUNC(xpmGetRgbName, char *, (xpmRgbName * rgbn, int rgbn_max,
208                              int red, int green, int blue));
209 FUNC(xpmFreeRgbNames, void, (xpmRgbName * rgbn, int rgbn_max));
210
211 FUNC(xpm_xynormalizeimagebits, int, (unsigned char *bp,
212                                      XImage * img));
213 FUNC(xpm_znormalizeimagebits, int, (unsigned char *bp,
214                                     XImage * img));
215 */
216 /*
217  * Macros
218  * 
219  * The XYNORMALIZE macro determines whether XY format data requires 
220  * normalization and calls a routine to do so if needed. The logic in
221  * this module is designed for LSBFirst byte and bit order, so 
222  * normalization is done as required to present the data in this order.
223  *
224  * The ZNORMALIZE macro performs byte and nibble order normalization if 
225  * required for Z format data.
226  * 
227  * The XYINDEX macro computes the index to the starting byte (char) boundary
228  * for a bitmap_unit containing a pixel with coordinates x and y for image
229  * data in XY format.
230  * 
231  * The ZINDEX* macros compute the index to the starting byte (char) boundary 
232  * for a pixel with coordinates x and y for image data in ZPixmap format.
233  * 
234  */
235
236 /*
237 #define XYNORMALIZE(bp, img) \
238     if ((img->byte_order == MSBFirst) || (img->bitmap_bit_order == MSBFirst)) \
239         xpm_xynormalizeimagebits((unsigned char *)(bp), img)
240
241 #define ZNORMALIZE(bp, img) \
242     if (img->byte_order == MSBFirst) \
243         xpm_znormalizeimagebits((unsigned char *)(bp), img)
244
245 #define XYINDEX(x, y, img) \
246     ((y) * img->bytes_per_line) + \
247     (((x) + img->xoffset) / img->bitmap_unit) * (img->bitmap_unit >> 3)
248
249 #define ZINDEX(x, y, img) ((y) * img->bytes_per_line) + \
250     (((x) * img->bits_per_pixel) >> 3)
251
252 #define ZINDEX32(x, y, img) ((y) * img->bytes_per_line) + ((x) << 2)
253
254 #define ZINDEX16(x, y, img) ((y) * img->bytes_per_line) + ((x) << 1)
255
256 #define ZINDEX8(x, y, img) ((y) * img->bytes_per_line) + (x)
257
258 #define ZINDEX1(x, y, img) ((y) * img->bytes_per_line) + ((x) >> 3)
259
260 */
261
262
263 #if defined(__STDC__)
264 #define Const const
265 #else
266 #define Const                           /**/
267 #endif
268
269 #endif