]>
Commit | Line | Data |
---|---|---|
0240e8b1 SC |
1 | /* |
2 | * Copyright (C) 1989-95 GROUPE BULL | |
3 | * | |
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy | |
5 | * of this software and associated documentation files (the "Software"), to | |
6 | * deal in the Software without restriction, including without limitation the | |
7 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or | |
8 | * sell copies of the Software, and to permit persons to whom the Software is | |
9 | * furnished to do so, subject to the following conditions: | |
10 | * | |
11 | * The above copyright notice and this permission notice shall be included in | |
12 | * all copies or substantial portions of the Software. | |
13 | * | |
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | |
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | |
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL | |
17 | * GROUPE BULL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN | |
18 | * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN | |
19 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | |
20 | * | |
21 | * Except as contained in this notice, the name of GROUPE BULL shall not be | |
22 | * used in advertising or otherwise to promote the sale, use or other dealings | |
23 | * in this Software without prior written authorization from GROUPE BULL. | |
24 | */ | |
25 | ||
26 | /*****************************************************************************\ | |
27 | * xpm.h: * | |
28 | * * | |
29 | * XPM library * | |
30 | * Include file * | |
31 | * * | |
32 | * Developed by Arnaud Le Hors * | |
33 | \*****************************************************************************/ | |
34 | ||
35 | /* | |
36 | * The code related to FOR_MSW has been added by | |
37 | * HeDu (hedu@cul-ipn.uni-kiel.de) 4/94 | |
38 | */ | |
39 | ||
40 | /* | |
41 | * The code related to AMIGA has been added by | |
42 | * Lorens Younes (d93-hyo@nada.kth.se) 4/96 | |
43 | */ | |
44 | ||
45 | #ifndef XPM_h | |
46 | #define XPM_h | |
47 | ||
48 | /* | |
49 | * first some identification numbers: | |
50 | * the version and revision numbers are determined with the following rule: | |
51 | * SO Major number = LIB minor version number. | |
52 | * SO Minor number = LIB sub-minor version number. | |
53 | * e.g: Xpm version 3.2f | |
54 | * we forget the 3 which is the format number, 2 gives 2, and f gives 6. | |
55 | * thus we have XpmVersion = 2 and XpmRevision = 6 | |
56 | * which gives SOXPMLIBREV = 2.6 | |
57 | * | |
58 | * Then the XpmIncludeVersion number is built from these numbers. | |
59 | */ | |
60 | #define XpmFormat 3 | |
61 | #define XpmVersion 4 | |
62 | #define XpmRevision 11 | |
63 | #define XpmIncludeVersion ((XpmFormat * 100 + XpmVersion) * 100 + XpmRevision) | |
64 | ||
65 | #ifndef XPM_NUMBERS | |
66 | ||
67 | #ifdef FOR_MSW | |
68 | #define IS_EQUAL_PIXEL( a , b ) ( a == b ) | |
69 | #define IS_ZERO_PIXEL(a) (!(a) ) | |
70 | #define SET_ZERO_PIXEL(a) { (a) = 0 } | |
71 | #define SET_WHITE_PIXEL(a) { (a) = 0 } | |
72 | # define SYSV /* uses memcpy string.h etc. */ | |
73 | # include <malloc.h> | |
74 | # include "simx.h" /* defines some X stuff using MSW types */ | |
75 | # define NEED_STRCASECMP /* at least for MSVC++ */ | |
76 | #elif AMIGA | |
77 | #define IS_EQUAL_PIXEL( a , b ) ( a == b ) | |
78 | #define IS_ZERO_PIXEL(a) (!(a) ) | |
79 | #define SET_ZERO_PIXEL(a) { (a) = 0 } | |
80 | #define SET_WHITE_PIXEL(a) { (a) = 0 } | |
81 | # include "amigax.h" | |
82 | #elif macintosh | |
83 | #define IS_EQUAL_PIXEL( a , b ) ( (a).red == (b).red && (a).green == (b).green && (a).blue == (b).blue ) | |
84 | #define IS_ZERO_PIXEL(a) (!(a).red && !(a).green && !(a).blue ) | |
85 | #define SET_ZERO_PIXEL(a) { (a).red = 0 ; (a).green = 0 ;(a).blue = 0 ;} | |
86 | #define SET_WHITE_PIXEL(a) { (a).red = 0xFFFF ; (a).green = 0xFFFF ;(a).blue = 0xFFFF ;} | |
87 | # include "simx.h" | |
88 | # define NEED_STRCASECMP | |
89 | # define NEED_STRDUP | |
90 | #else | |
91 | #define IS_EQUAL_PIXEL( a , b ) ( a == b ) | |
92 | #define IS_ZERO_PIXEL(a) (!(a) ) | |
93 | #define SET_ZERO_PIXEL(a) { (a) = 0 } | |
94 | #define SET_WHITE_PIXEL(a) { (a) = 0 } | |
95 | # include <X11/Xlib.h> | |
96 | # include <X11/Xutil.h> | |
97 | #endif | |
98 | ||
99 | /* let's define Pixel if it is not done yet */ | |
100 | #if ! defined(_XtIntrinsic_h) && ! defined(PIXEL_ALREADY_TYPEDEFED) | |
101 | typedef unsigned long Pixel; /* Index into colormap */ | |
102 | # define PIXEL_ALREADY_TYPEDEFED | |
103 | #endif | |
104 | ||
105 | /* make sure we know whether function prototypes are needed or not */ | |
106 | #ifndef NeedFunctionPrototypes | |
107 | # if defined(__STDC__) || defined(__cplusplus) || defined(c_plusplus) | |
108 | # define NeedFunctionPrototypes 1 | |
109 | # else | |
110 | # define NeedFunctionPrototypes 0 | |
111 | # endif | |
112 | #endif | |
113 | ||
114 | ||
115 | /* Return ErrorStatus codes: | |
116 | * null if full success | |
117 | * positive if partial success | |
118 | * negative if failure | |
119 | */ | |
120 | ||
121 | #define XpmColorError 1 | |
122 | #define XpmSuccess 0 | |
123 | #define XpmOpenFailed -1 | |
124 | #define XpmFileInvalid -2 | |
125 | #define XpmNoMemory -3 | |
126 | #define XpmColorFailed -4 | |
127 | ||
128 | typedef struct { | |
129 | char *name; /* Symbolic color name */ | |
130 | char *value; /* Color value */ | |
131 | Pixel pixel; /* Color pixel */ | |
132 | } XpmColorSymbol; | |
133 | ||
134 | typedef struct { | |
135 | char *name; /* name of the extension */ | |
136 | unsigned int nlines; /* number of lines in this extension */ | |
137 | char **lines; /* pointer to the extension array of strings */ | |
138 | } XpmExtension; | |
139 | ||
140 | typedef struct { | |
141 | char *string; /* characters string */ | |
142 | char *symbolic; /* symbolic name */ | |
143 | char *m_color; /* monochrom default */ | |
144 | char *g4_color; /* 4 level grayscale default */ | |
145 | char *g_color; /* other level grayscale default */ | |
146 | char *c_color; /* color default */ | |
147 | } XpmColor; | |
148 | ||
149 | typedef struct { | |
150 | unsigned int width; /* image width */ | |
151 | unsigned int height; /* image height */ | |
152 | unsigned int cpp; /* number of characters per pixel */ | |
153 | unsigned int ncolors; /* number of colors */ | |
154 | XpmColor *colorTable; /* list of related colors */ | |
155 | unsigned int *data; /* image data */ | |
156 | } XpmImage; | |
157 | ||
158 | typedef struct { | |
159 | unsigned long valuemask; /* Specifies which attributes are defined */ | |
160 | char *hints_cmt; /* Comment of the hints section */ | |
161 | char *colors_cmt; /* Comment of the colors section */ | |
162 | char *pixels_cmt; /* Comment of the pixels section */ | |
163 | unsigned int x_hotspot; /* Returns the x hotspot's coordinate */ | |
164 | unsigned int y_hotspot; /* Returns the y hotspot's coordinate */ | |
165 | unsigned int nextensions; /* number of extensions */ | |
166 | XpmExtension *extensions; /* pointer to array of extensions */ | |
167 | } XpmInfo; | |
168 | ||
169 | typedef int (*XpmAllocColorFunc)( | |
170 | #if NeedFunctionPrototypes | |
171 | Display* /* display */, | |
172 | Colormap /* colormap */, | |
173 | char* /* colorname */, | |
174 | XColor* /* xcolor */, | |
175 | void* /* closure */ | |
176 | #endif | |
177 | ); | |
178 | ||
179 | typedef int (*XpmFreeColorsFunc)( | |
180 | #if NeedFunctionPrototypes | |
181 | Display* /* display */, | |
182 | Colormap /* colormap */, | |
183 | Pixel* /* pixels */, | |
184 | int /* npixels */, | |
185 | void* /* closure */ | |
186 | #endif | |
187 | ); | |
188 | ||
189 | typedef struct { | |
190 | unsigned long valuemask; /* Specifies which attributes are | |
191 | defined */ | |
192 | ||
193 | Visual *visual; /* Specifies the visual to use */ | |
194 | Colormap colormap; /* Specifies the colormap to use */ | |
195 | unsigned int depth; /* Specifies the depth */ | |
196 | unsigned int width; /* Returns the width of the created | |
197 | pixmap */ | |
198 | unsigned int height; /* Returns the height of the created | |
199 | pixmap */ | |
200 | unsigned int x_hotspot; /* Returns the x hotspot's | |
201 | coordinate */ | |
202 | unsigned int y_hotspot; /* Returns the y hotspot's | |
203 | coordinate */ | |
204 | unsigned int cpp; /* Specifies the number of char per | |
205 | pixel */ | |
206 | Pixel *pixels; /* List of used color pixels */ | |
207 | unsigned int npixels; /* Number of used pixels */ | |
208 | XpmColorSymbol *colorsymbols; /* List of color symbols to override */ | |
209 | unsigned int numsymbols; /* Number of symbols */ | |
210 | char *rgb_fname; /* RGB text file name */ | |
211 | unsigned int nextensions; /* Number of extensions */ | |
212 | XpmExtension *extensions; /* List of extensions */ | |
213 | ||
214 | unsigned int ncolors; /* Number of colors */ | |
215 | XpmColor *colorTable; /* List of colors */ | |
216 | /* 3.2 backward compatibility code */ | |
217 | char *hints_cmt; /* Comment of the hints section */ | |
218 | char *colors_cmt; /* Comment of the colors section */ | |
219 | char *pixels_cmt; /* Comment of the pixels section */ | |
220 | /* end 3.2 bc */ | |
221 | unsigned int mask_pixel; /* Color table index of transparent | |
222 | color */ | |
223 | ||
224 | /* Color Allocation Directives */ | |
225 | Bool exactColors; /* Only use exact colors for visual */ | |
226 | unsigned int closeness; /* Allowable RGB deviation */ | |
227 | unsigned int red_closeness; /* Allowable red deviation */ | |
228 | unsigned int green_closeness; /* Allowable green deviation */ | |
229 | unsigned int blue_closeness; /* Allowable blue deviation */ | |
230 | int color_key; /* Use colors from this color set */ | |
231 | ||
232 | Pixel *alloc_pixels; /* Returns the list of alloc'ed color | |
233 | pixels */ | |
234 | int nalloc_pixels; /* Returns the number of alloc'ed | |
235 | color pixels */ | |
236 | ||
237 | Bool alloc_close_colors; /* Specify whether close colors should | |
238 | be allocated using XAllocColor | |
239 | or not */ | |
240 | int bitmap_format; /* Specify the format of 1bit depth | |
241 | images: ZPixmap or XYBitmap */ | |
242 | ||
243 | /* Color functions */ | |
244 | XpmAllocColorFunc alloc_color; /* Application color allocator */ | |
245 | XpmFreeColorsFunc free_colors; /* Application color de-allocator */ | |
246 | void *color_closure; /* Application private data to pass to | |
247 | alloc_color and free_colors */ | |
248 | ||
249 | } XpmAttributes; | |
250 | ||
251 | /* XpmAttributes value masks bits */ | |
252 | #define XpmVisual (1L<<0) | |
253 | #define XpmColormap (1L<<1) | |
254 | #define XpmDepth (1L<<2) | |
255 | #define XpmSize (1L<<3) /* width & height */ | |
256 | #define XpmHotspot (1L<<4) /* x_hotspot & y_hotspot */ | |
257 | #define XpmCharsPerPixel (1L<<5) | |
258 | #define XpmColorSymbols (1L<<6) | |
259 | #define XpmRgbFilename (1L<<7) | |
260 | /* 3.2 backward compatibility code */ | |
261 | #define XpmInfos (1L<<8) | |
262 | #define XpmReturnInfos XpmInfos | |
263 | /* end 3.2 bc */ | |
264 | #define XpmReturnPixels (1L<<9) | |
265 | #define XpmExtensions (1L<<10) | |
266 | #define XpmReturnExtensions XpmExtensions | |
267 | ||
268 | #define XpmExactColors (1L<<11) | |
269 | #define XpmCloseness (1L<<12) | |
270 | #define XpmRGBCloseness (1L<<13) | |
271 | #define XpmColorKey (1L<<14) | |
272 | ||
273 | #define XpmColorTable (1L<<15) | |
274 | #define XpmReturnColorTable XpmColorTable | |
275 | ||
276 | #define XpmReturnAllocPixels (1L<<16) | |
277 | #define XpmAllocCloseColors (1L<<17) | |
278 | #define XpmBitmapFormat (1L<<18) | |
279 | ||
280 | #define XpmAllocColor (1L<<19) | |
281 | #define XpmFreeColors (1L<<20) | |
282 | #define XpmColorClosure (1L<<21) | |
283 | ||
284 | ||
285 | /* XpmInfo value masks bits */ | |
286 | #define XpmComments XpmInfos | |
287 | #define XpmReturnComments XpmComments | |
288 | ||
289 | /* XpmAttributes mask_pixel value when there is no mask */ | |
290 | #ifndef FOR_MSW | |
291 | #define XpmUndefPixel 0x80000000 | |
292 | #else | |
293 | /* int is only 16 bit for MSW */ | |
294 | #define XpmUndefPixel 0x8000 | |
295 | #endif | |
296 | ||
297 | /* | |
298 | * color keys for visual type, they must fit along with the number key of | |
299 | * each related element in xpmColorKeys[] defined in XpmI.h | |
300 | */ | |
301 | #define XPM_MONO 2 | |
302 | #define XPM_GREY4 3 | |
303 | #define XPM_GRAY4 3 | |
304 | #define XPM_GREY 4 | |
305 | #define XPM_GRAY 4 | |
306 | #define XPM_COLOR 5 | |
307 | ||
308 | ||
309 | /* macros for forward declarations of functions with prototypes */ | |
310 | #if NeedFunctionPrototypes | |
311 | #define FUNC(f, t, p) extern t f p | |
312 | #define LFUNC(f, t, p) static t f p | |
313 | #else | |
314 | #define FUNC(f, t, p) extern t f() | |
315 | #define LFUNC(f, t, p) static t f() | |
316 | #endif | |
317 | ||
318 | ||
319 | /* | |
320 | * functions declarations | |
321 | */ | |
322 | ||
323 | #ifdef __cplusplus | |
324 | extern "C" { | |
325 | #endif | |
326 | ||
327 | ||
328 | FUNC(XpmCreateImageFromData, int, (Display *display, | |
329 | char **data, | |
330 | XImage **image_return, | |
331 | XImage **shapemask_return, | |
332 | XpmAttributes *attributes)); | |
333 | ||
334 | FUNC(XpmCreateDataFromImage, int, (Display *display, | |
335 | char ***data_return, | |
336 | XImage *image, | |
337 | XImage *shapeimage, | |
338 | XpmAttributes *attributes)); | |
339 | ||
340 | FUNC(XpmReadFileToImage, int, (Display *display, | |
341 | char *filename, | |
342 | XImage **image_return, | |
343 | XImage **shapeimage_return, | |
344 | XpmAttributes *attributes)); | |
345 | ||
346 | FUNC(XpmWriteFileFromImage, int, (Display *display, | |
347 | char *filename, | |
348 | XImage *image, | |
349 | XImage *shapeimage, | |
350 | XpmAttributes *attributes)); | |
351 | ||
352 | FUNC(XpmCreateImageFromBuffer, int, (Display *display, | |
353 | char *buffer, | |
354 | XImage **image_return, | |
355 | XImage **shapemask_return, | |
356 | XpmAttributes *attributes)); | |
357 | ||
358 | FUNC(XpmReadFileToBuffer, int, (char *filename, char **buffer_return)); | |
359 | FUNC(XpmWriteFileFromBuffer, int, (char *filename, char *buffer)); | |
360 | ||
361 | FUNC(XpmReadFileToData, int, (char *filename, char ***data_return)); | |
362 | FUNC(XpmWriteFileFromData, int, (char *filename, char **data)); | |
363 | ||
364 | FUNC(XpmAttributesSize, int, ()); | |
365 | FUNC(XpmFreeAttributes, void, (XpmAttributes *attributes)); | |
366 | FUNC(XpmFreeExtensions, void, (XpmExtension *extensions, | |
367 | int nextensions)); | |
368 | ||
369 | FUNC(XpmFreeXpmImage, void, (XpmImage *image)); | |
370 | FUNC(XpmFreeXpmInfo, void, (XpmInfo *info)); | |
371 | FUNC(XpmGetErrorString, char *, (int errcode)); | |
372 | FUNC(XpmLibraryVersion, int, ()); | |
373 | ||
374 | /* XpmImage functions */ | |
375 | FUNC(XpmReadFileToXpmImage, int, (char *filename, | |
376 | XpmImage *image, | |
377 | XpmInfo *info)); | |
378 | ||
379 | FUNC(XpmWriteFileFromXpmImage, int, (char *filename, | |
380 | XpmImage *image, | |
381 | XpmInfo *info)); | |
382 | ||
383 | FUNC(XpmCreateImageFromXpmImage, int, (Display *display, | |
384 | XpmImage *image, | |
385 | XImage **image_return, | |
386 | XImage **shapeimage_return, | |
387 | XpmAttributes *attributes)); | |
388 | ||
389 | FUNC(XpmCreateXpmImageFromImage, int, (Display *display, | |
390 | XImage *image, | |
391 | XImage *shapeimage, | |
392 | XpmImage *xpmimage, | |
393 | XpmAttributes *attributes)); | |
394 | ||
395 | FUNC(XpmCreateDataFromXpmImage, int, (char ***data_return, | |
396 | XpmImage *image, | |
397 | XpmInfo *info)); | |
398 | ||
399 | FUNC(XpmCreateXpmImageFromData, int, (char **data, | |
400 | XpmImage *image, | |
401 | XpmInfo *info)); | |
402 | ||
403 | FUNC(XpmCreateXpmImageFromBuffer, int, (char *buffer, | |
404 | XpmImage *image, | |
405 | XpmInfo *info)); | |
406 | ||
407 | FUNC(XpmCreateBufferFromXpmImage, int, (char **buffer_return, | |
408 | XpmImage *image, | |
409 | XpmInfo *info)); | |
410 | ||
411 | FUNC(XpmGetParseError, int, (char *filename, | |
412 | int *linenum_return, | |
413 | int *charnum_return)); | |
414 | ||
415 | FUNC(XpmFree, void, (void *ptr)); | |
416 | ||
417 | #ifdef __cplusplus | |
418 | } /* for C++ V2.0 */ | |
419 | #endif | |
420 | ||
421 | ||
422 | /* backward compatibility */ | |
423 | ||
424 | /* for version 3.0c */ | |
425 | #define XpmPixmapColorError XpmColorError | |
426 | #define XpmPixmapSuccess XpmSuccess | |
427 | #define XpmPixmapOpenFailed XpmOpenFailed | |
428 | #define XpmPixmapFileInvalid XpmFileInvalid | |
429 | #define XpmPixmapNoMemory XpmNoMemory | |
430 | #define XpmPixmapColorFailed XpmColorFailed | |
431 | ||
432 | #define XpmReadPixmapFile(dpy, d, file, pix, mask, att) \ | |
433 | XpmReadFileToPixmap(dpy, d, file, pix, mask, att) | |
434 | #define XpmWritePixmapFile(dpy, file, pix, mask, att) \ | |
435 | XpmWriteFileFromPixmap(dpy, file, pix, mask, att) | |
436 | ||
437 | /* for version 3.0b */ | |
438 | #define PixmapColorError XpmColorError | |
439 | #define PixmapSuccess XpmSuccess | |
440 | #define PixmapOpenFailed XpmOpenFailed | |
441 | #define PixmapFileInvalid XpmFileInvalid | |
442 | #define PixmapNoMemory XpmNoMemory | |
443 | #define PixmapColorFailed XpmColorFailed | |
444 | ||
445 | #define ColorSymbol XpmColorSymbol | |
446 | ||
447 | #define XReadPixmapFile(dpy, d, file, pix, mask, att) \ | |
448 | XpmReadFileToPixmap(dpy, d, file, pix, mask, att) | |
449 | #define XWritePixmapFile(dpy, file, pix, mask, att) \ | |
450 | XpmWriteFileFromPixmap(dpy, file, pix, mask, att) | |
451 | #define XCreatePixmapFromData(dpy, d, data, pix, mask, att) \ | |
452 | XpmCreatePixmapFromData(dpy, d, data, pix, mask, att) | |
453 | #define XCreateDataFromPixmap(dpy, data, pix, mask, att) \ | |
454 | XpmCreateDataFromPixmap(dpy, data, pix, mask, att) | |
455 | ||
456 | #endif /* XPM_NUMBERS */ | |
457 | #endif |