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