* Copyright (C) 1989-95 GROUPE BULL
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to
* deal in the Software without restriction, including without limitation the
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
* sell copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* GROUPE BULL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
* Except as contained in this notice, the name of GROUPE BULL shall not be
* used in advertising or otherwise to promote the sale, use or other dealings
* in this Software without prior written authorization from GROUPE BULL.
/*****************************************************************************\
* Developed by Arnaud Le Hors *
\*****************************************************************************/
* The code related to FOR_MSW has been added by
* HeDu (hedu@cul-ipn.uni-kiel.de) 4/94
* The code related to AMIGA has been added by
* Lorens Younes (d93-hyo@nada.kth.se) 4/96
* first some identification numbers:
* the version and revision numbers are determined with the following rule:
* SO Major number = LIB minor version number.
* SO Minor number = LIB sub-minor version number.
* we forget the 3 which is the format number, 2 gives 2, and f gives 6.
* thus we have XpmVersion = 2 and XpmRevision = 6
* which gives SOXPMLIBREV = 2.6
* Then the XpmIncludeVersion number is built from these numbers.
#define XpmIncludeVersion ((XpmFormat * 100 + XpmVersion) * 100 + XpmRevision)
# define SYSV /* uses memcpy string.h etc. */
# include "simx.h" /* defines some X stuff using MSW types */
#define NEED_STRCASECMP /* at least for MSVC++ */
/* let's define Pixel if it is not done yet */
#if ! defined(_XtIntrinsic_h) && ! defined(PIXEL_ALREADY_TYPEDEFED)
typedef unsigned long Pixel; /* Index into colormap */
# define PIXEL_ALREADY_TYPEDEFED
/* Return ErrorStatus codes:
* positive if partial success
#define XpmFileInvalid -2
#define XpmColorFailed -4
char *name; /* Symbolic color name */
char *value; /* Color value */
Pixel pixel; /* Color pixel */
char *name; /* name of the extension */
unsigned int nlines; /* number of lines in this extension */
char **lines; /* pointer to the extension array of strings */
char *string; /* characters string */
char *symbolic; /* symbolic name */
char *m_color; /* monochrom default */
char *g4_color; /* 4 level grayscale default */
char *g_color; /* other level grayscale default */
char *c_color; /* color default */
unsigned int width; /* image width */
unsigned int height; /* image height */
unsigned int cpp; /* number of characters per pixel */
unsigned int ncolors; /* number of colors */
XpmColor *colorTable; /* list of related colors */
unsigned int *data; /* image data */
unsigned long valuemask; /* Specifies which attributes are defined */
char *hints_cmt; /* Comment of the hints section */
char *colors_cmt; /* Comment of the colors section */
char *pixels_cmt; /* Comment of the pixels section */
unsigned int x_hotspot; /* Returns the x hotspot's coordinate */
unsigned int y_hotspot; /* Returns the y hotspot's coordinate */
unsigned int nextensions; /* number of extensions */
XpmExtension *extensions; /* pointer to array of extensions */
typedef int (*XpmAllocColorFunc)(
typedef int (*XpmFreeColorsFunc)(
unsigned long valuemask; /* Specifies which attributes are
Visual *visual; /* Specifies the visual to use */
Colormap colormap; /* Specifies the colormap to use */
unsigned int depth; /* Specifies the depth */
unsigned int width; /* Returns the width of the created
unsigned int height; /* Returns the height of the created
unsigned int x_hotspot; /* Returns the x hotspot's
unsigned int y_hotspot; /* Returns the y hotspot's
unsigned int cpp; /* Specifies the number of char per
Pixel *pixels; /* List of used color pixels */
unsigned int npixels; /* Number of used pixels */
XpmColorSymbol *colorsymbols; /* List of color symbols to override */
unsigned int numsymbols; /* Number of symbols */
char *rgb_fname; /* RGB text file name */
unsigned int nextensions; /* Number of extensions */
XpmExtension *extensions; /* List of extensions */
unsigned int ncolors; /* Number of colors */
XpmColor *colorTable; /* List of colors */
/* 3.2 backward compatibility code */
char *hints_cmt; /* Comment of the hints section */
char *colors_cmt; /* Comment of the colors section */
char *pixels_cmt; /* Comment of the pixels section */
unsigned int mask_pixel; /* Color table index of transparent
/* Color Allocation Directives */
Bool exactColors; /* Only use exact colors for visual */
unsigned int closeness; /* Allowable RGB deviation */
unsigned int red_closeness; /* Allowable red deviation */
unsigned int green_closeness; /* Allowable green deviation */
unsigned int blue_closeness; /* Allowable blue deviation */
int color_key; /* Use colors from this color set */
Pixel *alloc_pixels; /* Returns the list of alloc'ed color
int nalloc_pixels; /* Returns the number of alloc'ed
Bool alloc_close_colors; /* Specify whether close colors should
be allocated using XAllocColor
int bitmap_format; /* Specify the format of 1bit depth
images: ZPixmap or XYBitmap */
XpmAllocColorFunc alloc_color; /* Application color allocator */
XpmFreeColorsFunc free_colors; /* Application color de-allocator */
void *color_closure; /* Application private data to pass to
alloc_color and free_colors */
/* XpmAttributes value masks bits */
#define XpmVisual (1L<<0)
#define XpmColormap (1L<<1)
#define XpmSize (1L<<3) /* width & height */
#define XpmHotspot (1L<<4) /* x_hotspot & y_hotspot */
#define XpmCharsPerPixel (1L<<5)
#define XpmColorSymbols (1L<<6)
#define XpmRgbFilename (1L<<7)
/* 3.2 backward compatibility code */
#define XpmReturnInfos XpmInfos
#define XpmReturnPixels (1L<<9)
#define XpmExtensions (1L<<10)
#define XpmReturnExtensions XpmExtensions
#define XpmExactColors (1L<<11)
#define XpmCloseness (1L<<12)
#define XpmRGBCloseness (1L<<13)
#define XpmColorKey (1L<<14)
#define XpmColorTable (1L<<15)
#define XpmReturnColorTable XpmColorTable
#define XpmReturnAllocPixels (1L<<16)
#define XpmAllocCloseColors (1L<<17)
#define XpmBitmapFormat (1L<<18)
#define XpmAllocColor (1L<<19)
#define XpmFreeColors (1L<<20)
#define XpmColorClosure (1L<<21)
/* XpmInfo value masks bits */
#define XpmComments XpmInfos
#define XpmReturnComments XpmComments
/* XpmAttributes mask_pixel value when there is no mask */
#define XpmUndefPixel 0x80000000
/* int is only 16 bit for MSW */
#define XpmUndefPixel 0x8000
* color keys for visual type, they must fit along with the number key of
* each related element in xpmColorKeys[] defined in XpmI.h
/* macros for forward declarations of functions with prototypes */
#define FUNC(f, t, p) extern t f p
#define LFUNC(f, t, p) static t f p
/* FOR_MSW, all ..Pixmap.. are excluded, only the ..XImage.. are used */
#if !defined(FOR_MSW) && !defined(AMIGA)
FUNC(XpmCreatePixmapFromData, int, (Display *display,
Pixmap *shapemask_return,
XpmAttributes *attributes));
FUNC(XpmCreateDataFromPixmap, int, (Display *display,
XpmAttributes *attributes));
FUNC(XpmReadFileToPixmap, int, (Display *display,
Pixmap *shapemask_return,
XpmAttributes *attributes));
FUNC(XpmWriteFileFromPixmap, int, (Display *display,
XpmAttributes *attributes));
FUNC(XpmCreateImageFromData, int, (Display *display,
XImage **shapemask_return,
XpmAttributes *attributes));
FUNC(XpmCreateDataFromImage, int, (Display *display,
XpmAttributes *attributes));
FUNC(XpmReadFileToImage, int, (Display *display,
XImage **shapeimage_return,
XpmAttributes *attributes));
FUNC(XpmWriteFileFromImage, int, (Display *display,
XpmAttributes *attributes));
FUNC(XpmCreateImageFromBuffer, int, (Display *display,
XImage **shapemask_return,
XpmAttributes *attributes));
#if !defined(FOR_MSW) && !defined(AMIGA)
FUNC(XpmCreatePixmapFromBuffer, int, (Display *display,
Pixmap *shapemask_return,
XpmAttributes *attributes));
FUNC(XpmCreateBufferFromImage, int, (Display *display,
XpmAttributes *attributes));
FUNC(XpmCreateBufferFromPixmap, int, (Display *display,
XpmAttributes *attributes));
FUNC(XpmReadFileToBuffer, int, (const char *filename, char **buffer_return));
FUNC(XpmWriteFileFromBuffer, int, (const char *filename, char *buffer));
FUNC(XpmReadFileToData, int, (const char *filename, char ***data_return));
FUNC(XpmWriteFileFromData, int, (const char *filename, char **data));
FUNC(XpmAttributesSize, int, (void));
FUNC(XpmFreeAttributes, void, (XpmAttributes *attributes));
FUNC(XpmFreeExtensions, void, (XpmExtension *extensions,
FUNC(XpmFreeXpmImage, void, (XpmImage *image));
FUNC(XpmFreeXpmInfo, void, (XpmInfo *info));
FUNC(XpmGetErrorString, char *, (int errcode));
FUNC(XpmLibraryVersion, int, (void));
FUNC(XpmReadFileToXpmImage, int, (const char *filename,
FUNC(XpmWriteFileFromXpmImage, int, (const char *filename,
#if !defined(FOR_MSW) && !defined(AMIGA)
FUNC(XpmCreatePixmapFromXpmImage, int, (Display *display,
Pixmap *shapemask_return,
XpmAttributes *attributes));
FUNC(XpmCreateImageFromXpmImage, int, (Display *display,
XImage **shapeimage_return,
XpmAttributes *attributes));
FUNC(XpmCreateXpmImageFromImage, int, (Display *display,
XpmAttributes *attributes));
#if !defined(FOR_MSW) && !defined(AMIGA)
FUNC(XpmCreateXpmImageFromPixmap, int, (Display *display,
XpmAttributes *attributes));
FUNC(XpmCreateDataFromXpmImage, int, (char ***data_return,
FUNC(XpmCreateXpmImageFromData, int, (char **data,
FUNC(XpmCreateXpmImageFromBuffer, int, (char *buffer,
FUNC(XpmCreateBufferFromXpmImage, int, (char **buffer_return,
FUNC(XpmGetParseError, int, (char *filename,
FUNC(XpmFree, void, (void *ptr));
/* backward compatibility */
#define XpmPixmapColorError XpmColorError
#define XpmPixmapSuccess XpmSuccess
#define XpmPixmapOpenFailed XpmOpenFailed
#define XpmPixmapFileInvalid XpmFileInvalid
#define XpmPixmapNoMemory XpmNoMemory
#define XpmPixmapColorFailed XpmColorFailed
#define XpmReadPixmapFile(dpy, d, file, pix, mask, att) \
XpmReadFileToPixmap(dpy, d, file, pix, mask, att)
#define XpmWritePixmapFile(dpy, file, pix, mask, att) \
XpmWriteFileFromPixmap(dpy, file, pix, mask, att)
#define PixmapColorError XpmColorError
#define PixmapSuccess XpmSuccess
#define PixmapOpenFailed XpmOpenFailed
#define PixmapFileInvalid XpmFileInvalid
#define PixmapNoMemory XpmNoMemory
#define PixmapColorFailed XpmColorFailed
#define ColorSymbol XpmColorSymbol
#define XReadPixmapFile(dpy, d, file, pix, mask, att) \
XpmReadFileToPixmap(dpy, d, file, pix, mask, att)
#define XWritePixmapFile(dpy, file, pix, mask, att) \
XpmWriteFileFromPixmap(dpy, file, pix, mask, att)
#define XCreatePixmapFromData(dpy, d, data, pix, mask, att) \
XpmCreatePixmapFromData(dpy, d, data, pix, mask, att)
#define XCreateDataFromPixmap(dpy, data, pix, mask, att) \
XpmCreateDataFromPixmap(dpy, data, pix, mask, att)