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