]> git.saurik.com Git - wxWidgets.git/blob - src/xpm/xpm.h
compilation fix
[wxWidgets.git] / src / xpm / xpm.h
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 #if (defined(_WINDOWS) || defined(__WXMSW__) || defined(WIN32)) && !defined(FOR_MSW)
49 #define FOR_MSW
50 #endif
51 /* Piggyback on MSW for now */
52 #if (defined(__OS2__) || defined(__WXPM__) || defined(OS232)) && !defined(FOR_MSW)
53 #define FOR_MSW
54 #endif
55
56 /*
57 * first some identification numbers:
58 * the version and revision numbers are determined with the following rule:
59 * SO Major number = LIB minor version number.
60 * SO Minor number = LIB sub-minor version number.
61 * e.g: Xpm version 3.2f
62 * we forget the 3 which is the format number, 2 gives 2, and f gives 6.
63 * thus we have XpmVersion = 2 and XpmRevision = 6
64 * which gives SOXPMLIBREV = 2.6
65 *
66 * Then the XpmIncludeVersion number is built from these numbers.
67 */
68 #define XpmFormat 3
69 #define XpmVersion 4
70 #define XpmRevision 11
71 #define XpmIncludeVersion ((XpmFormat * 100 + XpmVersion) * 100 + XpmRevision)
72
73 #ifndef XPM_NUMBERS
74
75 #ifdef FOR_MSW
76 # define SYSV /* uses memcpy string.h etc. */
77 # include <malloc.h>
78 # include "simx.h" /* defines some X stuff using MSW types */
79 #define NEED_STRCASECMP /* at least for MSVC++ */
80 #else /* FOR_MSW */
81 # ifdef AMIGA
82 # include "amigax.h"
83 # else /* not AMIGA */
84 # include <X11/Xlib.h>
85 # include <X11/Xutil.h>
86 # endif /* not AMIGA */
87 #endif /* FOR_MSW */
88
89 /* let's define Pixel if it is not done yet */
90 #if ! defined(_XtIntrinsic_h) && ! defined(PIXEL_ALREADY_TYPEDEFED)
91 typedef unsigned long Pixel; /* Index into colormap */
92 # define PIXEL_ALREADY_TYPEDEFED
93 #endif
94
95 /* make sure we know whether function prototypes are needed or not */
96 #ifndef NeedFunctionPrototypes
97 # if defined(__STDC__) || defined(__cplusplus) || defined(c_plusplus)
98 # define NeedFunctionPrototypes 1
99 # else
100 # define NeedFunctionPrototypes 0
101 # endif
102 #endif
103
104 /* DW: bug in makefile seems to not want to define these, but they are needed! */
105 /* Guillermo, maybe you can look at it */
106 #ifdef FOR_MSW
107 # define FUNC(f, t, p) extern t f p
108 # define LFUNC(f, t, p) static t f p
109 #endif
110
111 /* Return ErrorStatus codes:
112 * null if full success
113 * positive if partial success
114 * negative if failure
115 */
116
117 #define XpmColorError 1
118 #define XpmSuccess 0
119 #define XpmOpenFailed -1
120 #define XpmFileInvalid -2
121 #define XpmNoMemory -3
122 #define XpmColorFailed -4
123
124 typedef struct {
125 char *name; /* Symbolic color name */
126 char *value; /* Color value */
127 Pixel pixel; /* Color pixel */
128 } XpmColorSymbol;
129
130 typedef struct {
131 char *name; /* name of the extension */
132 unsigned int nlines; /* number of lines in this extension */
133 char **lines; /* pointer to the extension array of strings */
134 } XpmExtension;
135
136 typedef struct {
137 char *string; /* characters string */
138 char *symbolic; /* symbolic name */
139 char *m_color; /* monochrom default */
140 char *g4_color; /* 4 level grayscale default */
141 char *g_color; /* other level grayscale default */
142 char *c_color; /* color default */
143 } XpmColor;
144
145 typedef struct {
146 unsigned int width; /* image width */
147 unsigned int height; /* image height */
148 unsigned int cpp; /* number of characters per pixel */
149 unsigned int ncolors; /* number of colors */
150 XpmColor *colorTable; /* list of related colors */
151 unsigned int *data; /* image data */
152 } XpmImage;
153
154 typedef struct {
155 unsigned long valuemask; /* Specifies which attributes are defined */
156 char *hints_cmt; /* Comment of the hints section */
157 char *colors_cmt; /* Comment of the colors section */
158 char *pixels_cmt; /* Comment of the pixels section */
159 unsigned int x_hotspot; /* Returns the x hotspot's coordinate */
160 unsigned int y_hotspot; /* Returns the y hotspot's coordinate */
161 unsigned int nextensions; /* number of extensions */
162 XpmExtension *extensions; /* pointer to array of extensions */
163 } XpmInfo;
164
165 typedef int (*XpmAllocColorFunc)(
166 #if NeedFunctionPrototypes
167 Display* /* display */,
168 Colormap /* colormap */,
169 char* /* colorname */,
170 XColor* /* xcolor */,
171 void* /* closure */
172 #endif
173 );
174
175 typedef int (*XpmFreeColorsFunc)(
176 #if NeedFunctionPrototypes
177 Display* /* display */,
178 Colormap /* colormap */,
179 Pixel* /* pixels */,
180 int /* npixels */,
181 void* /* closure */
182 #endif
183 );
184
185 typedef struct {
186 unsigned long valuemask; /* Specifies which attributes are
187 defined */
188
189 Visual *visual; /* Specifies the visual to use */
190 Colormap colormap; /* Specifies the colormap to use */
191 unsigned int depth; /* Specifies the depth */
192 unsigned int width; /* Returns the width of the created
193 pixmap */
194 unsigned int height; /* Returns the height of the created
195 pixmap */
196 unsigned int x_hotspot; /* Returns the x hotspot's
197 coordinate */
198 unsigned int y_hotspot; /* Returns the y hotspot's
199 coordinate */
200 unsigned int cpp; /* Specifies the number of char per
201 pixel */
202 Pixel *pixels; /* List of used color pixels */
203 unsigned int npixels; /* Number of used pixels */
204 XpmColorSymbol *colorsymbols; /* List of color symbols to override */
205 unsigned int numsymbols; /* Number of symbols */
206 char *rgb_fname; /* RGB text file name */
207 unsigned int nextensions; /* Number of extensions */
208 XpmExtension *extensions; /* List of extensions */
209
210 unsigned int ncolors; /* Number of colors */
211 XpmColor *colorTable; /* List of colors */
212 /* 3.2 backward compatibility code */
213 char *hints_cmt; /* Comment of the hints section */
214 char *colors_cmt; /* Comment of the colors section */
215 char *pixels_cmt; /* Comment of the pixels section */
216 /* end 3.2 bc */
217 unsigned int mask_pixel; /* Color table index of transparent
218 color */
219
220 /* Color Allocation Directives */
221 Bool exactColors; /* Only use exact colors for visual */
222 unsigned int closeness; /* Allowable RGB deviation */
223 unsigned int red_closeness; /* Allowable red deviation */
224 unsigned int green_closeness; /* Allowable green deviation */
225 unsigned int blue_closeness; /* Allowable blue deviation */
226 int color_key; /* Use colors from this color set */
227
228 Pixel *alloc_pixels; /* Returns the list of alloc'ed color
229 pixels */
230 int nalloc_pixels; /* Returns the number of alloc'ed
231 color pixels */
232
233 Bool alloc_close_colors; /* Specify whether close colors should
234 be allocated using XAllocColor
235 or not */
236 int bitmap_format; /* Specify the format of 1bit depth
237 images: ZPixmap or XYBitmap */
238
239 /* Color functions */
240 XpmAllocColorFunc alloc_color; /* Application color allocator */
241 XpmFreeColorsFunc free_colors; /* Application color de-allocator */
242 void *color_closure; /* Application private data to pass to
243 alloc_color and free_colors */
244
245 } XpmAttributes;
246
247 /* XpmAttributes value masks bits */
248 #define XpmVisual (1L<<0)
249 #define XpmColormap (1L<<1)
250 #define XpmDepth (1L<<2)
251 #define XpmSize (1L<<3) /* width & height */
252 #define XpmHotspot (1L<<4) /* x_hotspot & y_hotspot */
253 #define XpmCharsPerPixel (1L<<5)
254 #define XpmColorSymbols (1L<<6)
255 #define XpmRgbFilename (1L<<7)
256 /* 3.2 backward compatibility code */
257 #define XpmInfos (1L<<8)
258 #define XpmReturnInfos XpmInfos
259 /* end 3.2 bc */
260 #define XpmReturnPixels (1L<<9)
261 #define XpmExtensions (1L<<10)
262 #define XpmReturnExtensions XpmExtensions
263
264 #define XpmExactColors (1L<<11)
265 #define XpmCloseness (1L<<12)
266 #define XpmRGBCloseness (1L<<13)
267 #define XpmColorKey (1L<<14)
268
269 #define XpmColorTable (1L<<15)
270 #define XpmReturnColorTable XpmColorTable
271
272 #define XpmReturnAllocPixels (1L<<16)
273 #define XpmAllocCloseColors (1L<<17)
274 #define XpmBitmapFormat (1L<<18)
275
276 #define XpmAllocColor (1L<<19)
277 #define XpmFreeColors (1L<<20)
278 #define XpmColorClosure (1L<<21)
279
280
281 /* XpmInfo value masks bits */
282 #define XpmComments XpmInfos
283 #define XpmReturnComments XpmComments
284
285 /* XpmAttributes mask_pixel value when there is no mask */
286 #ifndef FOR_MSW
287 #define XpmUndefPixel 0x80000000
288 #else
289 /* int is only 16 bit for MSW */
290 #define XpmUndefPixel 0x8000
291 #endif
292
293 /*
294 * color keys for visual type, they must fit along with the number key of
295 * each related element in xpmColorKeys[] defined in XpmI.h
296 */
297 #define XPM_MONO 2
298 #define XPM_GREY4 3
299 #define XPM_GRAY4 3
300 #define XPM_GREY 4
301 #define XPM_GRAY 4
302 #define XPM_COLOR 5
303
304
305 /* macros for forward declarations of functions with prototypes */
306 #if NeedFunctionPrototypes
307 # define FUNC(f, t, p) extern t f p
308 # define LFUNC(f, t, p) static t f p
309 #endif
310
311
312 /*
313 * functions declarations
314 */
315
316 #ifdef __cplusplus
317 extern "C" {
318 #endif
319
320 /* FOR_MSW, all ..Pixmap.. are excluded, only the ..XImage.. are used */
321 /* Same for Amiga! */
322
323 #if !defined(FOR_MSW) && !defined(AMIGA)
324 FUNC(XpmCreatePixmapFromData, int, (Display *display,
325 Drawable d,
326 char **data,
327 Pixmap *pixmap_return,
328 Pixmap *shapemask_return,
329 XpmAttributes *attributes));
330
331 FUNC(XpmCreateDataFromPixmap, int, (Display *display,
332 char ***data_return,
333 Pixmap pixmap,
334 Pixmap shapemask,
335 XpmAttributes *attributes));
336
337 FUNC(XpmReadFileToPixmap, int, (Display *display,
338 Drawable d,
339 char *filename,
340 Pixmap *pixmap_return,
341 Pixmap *shapemask_return,
342 XpmAttributes *attributes));
343
344 FUNC(XpmWriteFileFromPixmap, int, (Display *display,
345 char *filename,
346 Pixmap pixmap,
347 Pixmap shapemask,
348 XpmAttributes *attributes));
349 #endif
350
351 FUNC(XpmCreateImageFromData, int, (Display *display,
352 char **data,
353 XImage **image_return,
354 XImage **shapemask_return,
355 XpmAttributes *attributes));
356
357 FUNC(XpmCreateDataFromImage, int, (Display *display,
358 char ***data_return,
359 XImage *image,
360 XImage *shapeimage,
361 XpmAttributes *attributes));
362
363 FUNC(XpmReadFileToImage, int, (Display *display,
364 char *filename,
365 XImage **image_return,
366 XImage **shapeimage_return,
367 XpmAttributes *attributes));
368
369 FUNC(XpmWriteFileFromImage, int, (Display *display,
370 char *filename,
371 XImage *image,
372 XImage *shapeimage,
373 XpmAttributes *attributes));
374
375 FUNC(XpmCreateImageFromBuffer, int, (Display *display,
376 char *buffer,
377 XImage **image_return,
378 XImage **shapemask_return,
379 XpmAttributes *attributes));
380 #if !defined(FOR_MSW) && !defined(AMIGA)
381 FUNC(XpmCreatePixmapFromBuffer, int, (Display *display,
382 Drawable d,
383 char *buffer,
384 Pixmap *pixmap_return,
385 Pixmap *shapemask_return,
386 XpmAttributes *attributes));
387
388 FUNC(XpmCreateBufferFromImage, int, (Display *display,
389 char **buffer_return,
390 XImage *image,
391 XImage *shapeimage,
392 XpmAttributes *attributes));
393
394 FUNC(XpmCreateBufferFromPixmap, int, (Display *display,
395 char **buffer_return,
396 Pixmap pixmap,
397 Pixmap shapemask,
398 XpmAttributes *attributes));
399 #endif
400 FUNC(XpmReadFileToBuffer, int, (char *filename, char **buffer_return));
401 FUNC(XpmWriteFileFromBuffer, int, (char *filename, char *buffer));
402
403 FUNC(XpmReadFileToData, int, (char *filename, char ***data_return));
404 FUNC(XpmWriteFileFromData, int, (char *filename, char **data));
405
406 FUNC(XpmAttributesSize, int, ());
407 FUNC(XpmFreeAttributes, void, (XpmAttributes *attributes));
408 FUNC(XpmFreeExtensions, void, (XpmExtension *extensions,
409 int nextensions));
410
411 FUNC(XpmFreeXpmImage, void, (XpmImage *image));
412 FUNC(XpmFreeXpmInfo, void, (XpmInfo *info));
413 FUNC(XpmGetErrorString, char *, (int errcode));
414 FUNC(XpmLibraryVersion, int, ());
415
416 /* XpmImage functions */
417 FUNC(XpmReadFileToXpmImage, int, (char *filename,
418 XpmImage *image,
419 XpmInfo *info));
420
421 FUNC(XpmWriteFileFromXpmImage, int, (char *filename,
422 XpmImage *image,
423 XpmInfo *info));
424 #if !defined(FOR_MSW) && !defined(AMIGA)
425 FUNC(XpmCreatePixmapFromXpmImage, int, (Display *display,
426 Drawable d,
427 XpmImage *image,
428 Pixmap *pixmap_return,
429 Pixmap *shapemask_return,
430 XpmAttributes *attributes));
431 #endif
432 FUNC(XpmCreateImageFromXpmImage, int, (Display *display,
433 XpmImage *image,
434 XImage **image_return,
435 XImage **shapeimage_return,
436 XpmAttributes *attributes));
437
438 FUNC(XpmCreateXpmImageFromImage, int, (Display *display,
439 XImage *image,
440 XImage *shapeimage,
441 XpmImage *xpmimage,
442 XpmAttributes *attributes));
443 #if !defined(FOR_MSW) && !defined(AMIGA)
444 FUNC(XpmCreateXpmImageFromPixmap, int, (Display *display,
445 Pixmap pixmap,
446 Pixmap shapemask,
447 XpmImage *xpmimage,
448 XpmAttributes *attributes));
449 #endif
450 FUNC(XpmCreateDataFromXpmImage, int, (char ***data_return,
451 XpmImage *image,
452 XpmInfo *info));
453
454 FUNC(XpmCreateXpmImageFromData, int, (char **data,
455 XpmImage *image,
456 XpmInfo *info));
457
458 FUNC(XpmCreateXpmImageFromBuffer, int, (char *buffer,
459 XpmImage *image,
460 XpmInfo *info));
461
462 FUNC(XpmCreateBufferFromXpmImage, int, (char **buffer_return,
463 XpmImage *image,
464 XpmInfo *info));
465
466 FUNC(XpmGetParseError, int, (char *filename,
467 int *linenum_return,
468 int *charnum_return));
469
470 FUNC(XpmFree, void, (void *ptr));
471
472 #ifdef __cplusplus
473 } /* for C++ V2.0 */
474 #endif
475
476
477 /* backward compatibility */
478
479 /* for version 3.0c */
480 #define XpmPixmapColorError XpmColorError
481 #define XpmPixmapSuccess XpmSuccess
482 #define XpmPixmapOpenFailed XpmOpenFailed
483 #define XpmPixmapFileInvalid XpmFileInvalid
484 #define XpmPixmapNoMemory XpmNoMemory
485 #define XpmPixmapColorFailed XpmColorFailed
486
487 #define XpmReadPixmapFile(dpy, d, file, pix, mask, att) \
488 XpmReadFileToPixmap(dpy, d, file, pix, mask, att)
489 #define XpmWritePixmapFile(dpy, file, pix, mask, att) \
490 XpmWriteFileFromPixmap(dpy, file, pix, mask, att)
491
492 /* for version 3.0b */
493 #define PixmapColorError XpmColorError
494 #define PixmapSuccess XpmSuccess
495 #define PixmapOpenFailed XpmOpenFailed
496 #define PixmapFileInvalid XpmFileInvalid
497 #define PixmapNoMemory XpmNoMemory
498 #define PixmapColorFailed XpmColorFailed
499
500 #define ColorSymbol XpmColorSymbol
501
502 #define XReadPixmapFile(dpy, d, file, pix, mask, att) \
503 XpmReadFileToPixmap(dpy, d, file, pix, mask, att)
504 #define XWritePixmapFile(dpy, file, pix, mask, att) \
505 XpmWriteFileFromPixmap(dpy, file, pix, mask, att)
506 #define XCreatePixmapFromData(dpy, d, data, pix, mask, att) \
507 XpmCreatePixmapFromData(dpy, d, data, pix, mask, att)
508 #define XCreateDataFromPixmap(dpy, data, pix, mask, att) \
509 XpmCreateDataFromPixmap(dpy, data, pix, mask, att)
510
511 #endif /* XPM_NUMBERS */
512 #endif