Back to index

plt-scheme  4.2.1
xpm.h
Go to the documentation of this file.
00001 /*
00002  * Copyright (C) 1989-95 GROUPE BULL
00003  *
00004  * Permission is hereby granted, free of charge, to any person obtaining a copy
00005  * of this software and associated documentation files (the "Software"), to
00006  * deal in the Software without restriction, including without limitation the
00007  * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
00008  * sell copies of the Software, and to permit persons to whom the Software is
00009  * furnished to do so, subject to the following conditions:
00010  *
00011  * The above copyright notice and this permission notice shall be included in
00012  * all copies or substantial portions of the Software.
00013  *
00014  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
00015  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
00016  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
00017  * GROUPE BULL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
00018  * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
00019  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
00020  *
00021  * Except as contained in this notice, the name of GROUPE BULL shall not be
00022  * used in advertising or otherwise to promote the sale, use or other dealings
00023  * in this Software without prior written authorization from GROUPE BULL.
00024  */
00025 
00026 /*****************************************************************************\
00027 * xpm.h:                                                                      *
00028 *                                                                             *
00029 *  XPM library                                                                *
00030 *  Include file                                                               *
00031 *                                                                             *
00032 *  Developed by Arnaud Le Hors                                                *
00033 \*****************************************************************************/
00034 
00035 /*
00036  * The code related to FOR_MSW has been added by
00037  * HeDu (hedu@cul-ipn.uni-kiel.de) 4/94
00038  */
00039 
00040 #ifndef XPM_h
00041 #define XPM_h
00042 
00043 /*
00044  * first some identification numbers:
00045  * the version and revision numbers are determined with the following rule:
00046  * SO Major number = LIB minor version number.
00047  * SO Minor number = LIB sub-minor version number.
00048  * e.g: Xpm version 3.2f
00049  *      we forget the 3 which is the format number, 2 gives 2, and f gives 6.
00050  *      thus we have XpmVersion = 2 and XpmRevision = 6
00051  *      which gives  SOXPMLIBREV = 2.6
00052  *
00053  * Then the XpmIncludeVersion number is built from these numbers.
00054  */
00055 #define XpmFormat 3
00056 #define XpmVersion 4
00057 #define XpmRevision 7
00058 #define XpmIncludeVersion ((XpmFormat * 100 + XpmVersion) * 100 + XpmRevision)
00059 
00060 #ifndef XPM_NUMBERS
00061 
00062 #ifdef FOR_MSW
00063 #define SYSV                /* uses memcpy string.h etc. */
00064 #include <malloc.h>
00065 #include "simx.h"           /* defines some X stuff using MSW types */
00066 #define NEED_STRCASECMP            /* at least for MSVC++ */
00067 #else /* FOR_MSW */
00068 #include <X11/Xlib.h>
00069 #include <X11/Xutil.h>
00070 #endif /* FOR_MSW */
00071 
00072 /* let's define Pixel if it is not done yet */
00073 #if ! defined(_XtIntrinsic_h) && ! defined(PIXEL_ALREADY_TYPEDEFED)
00074 typedef unsigned long Pixel;       /* Index into colormap */
00075 #define PIXEL_ALREADY_TYPEDEFED
00076 #endif
00077 
00078 /* Return ErrorStatus codes:
00079  * null     if full success
00080  * positive if partial success
00081  * negative if failure
00082  */
00083 
00084 #define XpmColorError    1
00085 #define XpmSuccess       0
00086 #define XpmOpenFailed   -1
00087 #define XpmFileInvalid  -2
00088 #define XpmNoMemory     -3
00089 #define XpmColorFailed  -4
00090 
00091 /* the following should help people wanting to use their own functions */
00092 #define XpmFree(ptr) free(ptr)
00093 
00094 typedef struct {
00095     char *name;                    /* Symbolic color name */
00096     char *value;            /* Color value */
00097     Pixel pixel;            /* Color pixel */
00098 }      XpmColorSymbol;
00099 
00100 typedef struct {
00101     char *name;                    /* name of the extension */
00102     unsigned int nlines;    /* number of lines in this extension */
00103     char **lines;           /* pointer to the extension array of strings */
00104 }      XpmExtension;
00105 
00106 typedef struct {
00107     char *string;           /* characters string */
00108     char *symbolic;         /* symbolic name */
00109     char *m_color;          /* monochrom default */
00110     char *g4_color;         /* 4 level grayscale default */
00111     char *g_color;          /* other level grayscale default */
00112     char *c_color;          /* color default */
00113 }      XpmColor;
00114 
00115 typedef struct {
00116     unsigned int width;            /* image width */
00117     unsigned int height;    /* image height */
00118     unsigned int cpp;              /* number of characters per pixel */
00119     unsigned int ncolors;   /* number of colors */
00120     XpmColor *colorTable;   /* list of related colors */
00121     unsigned int *data;            /* image data */
00122 }      XpmImage;
00123 
00124 typedef struct {
00125     unsigned long valuemask;       /* Specifies which attributes are defined */
00126     char *hints_cmt;        /* Comment of the hints section */
00127     char *colors_cmt;              /* Comment of the colors section */
00128     char *pixels_cmt;              /* Comment of the pixels section */
00129     unsigned int x_hotspot; /* Returns the x hotspot's coordinate */
00130     unsigned int y_hotspot; /* Returns the y hotspot's coordinate */
00131     unsigned int nextensions;      /* number of extensions */
00132     XpmExtension *extensions;      /* pointer to array of extensions */
00133 }      XpmInfo;
00134 
00135 typedef struct {
00136     unsigned long valuemask;              /* Specifies which attributes are
00137                                     * defined */
00138 
00139     Visual *visual;                /* Specifies the visual to use */
00140     Colormap colormap;                    /* Specifies the colormap to use */
00141     unsigned int depth;                   /* Specifies the depth */
00142     unsigned int width;                   /* Returns the width of the created
00143                                     * pixmap */
00144     unsigned int height;           /* Returns the height of the created
00145                                     * pixmap */
00146     unsigned int x_hotspot;        /* Returns the x hotspot's
00147                                     * coordinate */
00148     unsigned int y_hotspot;        /* Returns the y hotspot's
00149                                     * coordinate */
00150     unsigned int cpp;                     /* Specifies the number of char per
00151                                     * pixel */
00152     Pixel *pixels;                 /* List of used color pixels */
00153     unsigned int npixels;          /* Number of used pixels */
00154     XpmColorSymbol *colorsymbols;  /* Array of color symbols to
00155                                     * override */
00156     unsigned int numsymbols;              /* Number of symbols */
00157     char *rgb_fname;               /* RGB text file name */
00158     unsigned int nextensions;             /* number of extensions */
00159     XpmExtension *extensions;             /* pointer to array of extensions */
00160 
00161     unsigned int ncolors;               /* Number of colors */
00162     XpmColor *colorTable;               /* Color table pointer */
00163 /* 3.2 backward compatibility code */
00164     char *hints_cmt;                    /* Comment of the hints section */
00165     char *colors_cmt;                   /* Comment of the colors section */
00166     char *pixels_cmt;                   /* Comment of the pixels section */
00167 /* end 3.2 bc */
00168     unsigned int mask_pixel;            /* Transparent pixel's color table
00169                                          * index */
00170 
00171     /* Color Allocation Directives */
00172     unsigned int exactColors;             /* Only use exact colors for visual */
00173     unsigned int closeness;        /* Allowable RGB deviation */
00174     unsigned int red_closeness;           /* Allowable red deviation */
00175     unsigned int green_closeness;  /* Allowable green deviation */
00176     unsigned int blue_closeness;   /* Allowable blue deviation */
00177     int color_key;                 /* Use colors from this color set */
00178 
00179     Pixel *alloc_pixels;           /* Returns the list of alloc'ed color
00180                                       pixels */
00181     unsigned int nalloc_pixels;           /* Returns the number of alloc'ed
00182                                       color pixels */
00183 
00184 }      XpmAttributes;
00185 
00186 /* XpmAttributes value masks bits */
00187 #define XpmVisual       (1L<<0)
00188 #define XpmColormap     (1L<<1)
00189 #define XpmDepth        (1L<<2)
00190 #define XpmSize                (1L<<3)    /* width & height */
00191 #define XpmHotspot      (1L<<4)    /* x_hotspot & y_hotspot */
00192 #define XpmCharsPerPixel   (1L<<5)
00193 #define XpmColorSymbols        (1L<<6)
00194 #define XpmRgbFilename         (1L<<7)
00195 /* 3.2 backward compatibility code */
00196 #define XpmInfos        (1L<<8)
00197 #define XpmReturnInfos         XpmInfos
00198 /* end 3.2 bc */
00199 #define XpmReturnPixels        (1L<<9)
00200 #define XpmExtensions      (1L<<10)
00201 #define XpmReturnExtensions XpmExtensions
00202 
00203 #define XpmExactColors     (1L<<11)
00204 #define XpmCloseness    (1L<<12)
00205 #define XpmRGBCloseness        (1L<<13)
00206 #define XpmColorKey     (1L<<14)
00207 
00208 #define XpmColorTable      (1L<<15)
00209 #define XpmReturnColorTable XpmColorTable
00210 
00211 #define XpmReturnAllocPixels (1L<<16)
00212 
00213 /* XpmInfo value masks bits */
00214 #define XpmComments        XpmInfos
00215 #define XpmReturnComments  XpmComments
00216 
00217 /* XpmAttributes mask_pixel value when there is no mask */
00218 #ifndef FOR_MSW
00219 #define XpmUndefPixel 0x80000000
00220 #else
00221 /* int is only 16 bit for MSW */
00222 #define XpmUndefPixel 0x8000
00223 #endif
00224 
00225 /*
00226  * color keys for visual type, they must fit along with the number key of
00227  * each related element in xpmColorKeys[] defined in xpmP.h
00228  */
00229 #define XPM_MONO     2
00230 #define XPM_GREY4    3
00231 #define XPM_GRAY4    3
00232 #define XPM_GREY     4
00233 #define XPM_GRAY     4
00234 #define XPM_COLOR    5
00235 
00236 
00237 /*
00238  * minimal portability layer between ansi and KR C
00239  */
00240 
00241 /* forward declaration of functions with prototypes */
00242 
00243 #if defined(__STDC__) || defined(__cplusplus) || defined(c_plusplus)
00244  /* ANSI || C++ */
00245 #define FUNC(f, t, p) extern t f p
00246 #define LFUNC(f, t, p) static t f p
00247 #else  /* K&R */
00248 #define FUNC(f, t, p) extern t f()
00249 #define LFUNC(f, t, p) static t f()
00250 #endif /* end of K&R */
00251 
00252 
00253 /*
00254  * functions declarations
00255  */
00256 
00257 #ifdef __cplusplus
00258 extern "C" {
00259 #endif
00260 
00261 /* FOR_MSW, all ..Pixmap.. are excluded, only the ..XImage.. are used */
00262 
00263 #ifndef FOR_MSW
00264     FUNC(XpmCreatePixmapFromData, int, (Display *display,
00265                                    Drawable d,
00266                                    char **data,
00267                                    Pixmap *pixmap_return,
00268                                    Pixmap *shapemask_return,
00269                                    XpmAttributes *attributes));
00270 
00271     FUNC(XpmCreateDataFromPixmap, int, (Display *display,
00272                                    char ***data_return,
00273                                    Pixmap pixmap,
00274                                    Pixmap shapemask,
00275                                    XpmAttributes *attributes));
00276 
00277     FUNC(XpmReadFileToPixmap, int, (Display *display,
00278                                 Drawable d,
00279                                 char *filename,
00280                                 Pixmap *pixmap_return,
00281                                 Pixmap *shapemask_return,
00282                                 XpmAttributes *attributes));
00283 
00284     FUNC(XpmWriteFileFromPixmap, int, (Display *display,
00285                                    char *filename,
00286                                    Pixmap pixmap,
00287                                    Pixmap shapemask,
00288                                    XpmAttributes *attributes));
00289 #endif  /* ndef FOR_MSW */
00290 
00291     FUNC(XpmCreateImageFromData, int, (Display *display,
00292                                    char **data,
00293                                    XImage **image_return,
00294                                    XImage **shapemask_return,
00295                                    XpmAttributes *attributes));
00296 
00297     FUNC(XpmCreateDataFromImage, int, (Display *display,
00298                                    char ***data_return,
00299                                    XImage *image,
00300                                    XImage *shapeimage,
00301                                    XpmAttributes *attributes));
00302 
00303     FUNC(XpmReadFileToImage, int, (Display *display,
00304                                char *filename,
00305                                XImage **image_return,
00306                                XImage **shapeimage_return,
00307                                XpmAttributes *attributes));
00308 
00309     FUNC(XpmWriteFileFromImage, int, (Display *display,
00310                                   char *filename,
00311                                   XImage *image,
00312                                   XImage *shapeimage,
00313                                   XpmAttributes *attributes));
00314 
00315     FUNC(XpmCreateImageFromBuffer, int, (Display *display,
00316                                     char *buffer,
00317                                     XImage **image_return,
00318                                     XImage **shapemask_return,
00319                                     XpmAttributes *attributes));
00320 #ifndef FOR_MSW
00321     FUNC(XpmCreatePixmapFromBuffer, int, (Display *display,
00322                                      Drawable d,
00323                                      char *buffer,
00324                                      Pixmap *pixmap_return,
00325                                      Pixmap *shapemask_return,
00326                                      XpmAttributes *attributes));
00327 
00328     FUNC(XpmCreateBufferFromImage, int, (Display *display,
00329                                     char **buffer_return,
00330                                     XImage *image,
00331                                     XImage *shapeimage,
00332                                     XpmAttributes *attributes));
00333 
00334     FUNC(XpmCreateBufferFromPixmap, int, (Display *display,
00335                                      char **buffer_return,
00336                                      Pixmap pixmap,
00337                                      Pixmap shapemask,
00338                                      XpmAttributes *attributes));
00339 #endif  /* ndef FOR_MSW */
00340     FUNC(XpmReadFileToBuffer, int, (char *filename, char **buffer_return));
00341     FUNC(XpmWriteFileFromBuffer, int, (char *filename, char *buffer));
00342 
00343     FUNC(XpmReadFileToData, int, (char *filename, char ***data_return));
00344     FUNC(XpmWriteFileFromData, int, (char *filename, char **data));
00345 
00346     FUNC(XpmAttributesSize, int, ());
00347     FUNC(XpmFreeAttributes, void, (XpmAttributes *attributes));
00348     FUNC(XpmFreeExtensions, void, (XpmExtension *extensions,
00349                                int nextensions));
00350 
00351     FUNC(XpmFreeXpmImage, void, (XpmImage *image));
00352     FUNC(XpmFreeXpmInfo, void, (XpmInfo *info));
00353     FUNC(XpmGetErrorString, char *, (int errcode));
00354     FUNC(XpmLibraryVersion, int, ());
00355 
00356     /* XpmImage functions */
00357     FUNC(XpmReadFileToXpmImage, int, (char *filename,
00358                                   XpmImage *image,
00359                                   XpmInfo *info));
00360 
00361     FUNC(XpmWriteFileFromXpmImage, int, (char *filename,
00362                                     XpmImage *image,
00363                                     XpmInfo *info));
00364 #ifndef FOR_MSW
00365     FUNC(XpmCreatePixmapFromXpmImage, int, (Display *display,
00366                                        Drawable d,
00367                                        XpmImage *image,
00368                                        Pixmap *pixmap_return,
00369                                        Pixmap *shapemask_return,
00370                                        XpmAttributes *attributes));
00371 #endif
00372     FUNC(XpmCreateImageFromXpmImage, int, (Display *display,
00373                                       XpmImage *image,
00374                                       XImage **image_return,
00375                                       XImage **shapeimage_return,
00376                                       XpmAttributes *attributes));
00377 
00378     FUNC(XpmCreateXpmImageFromImage, int, (Display *display,
00379                                       XImage *image,
00380                                       XImage *shapeimage,
00381                                       XpmImage *xpmimage,
00382                                       XpmAttributes *attributes));
00383 #ifndef FOR_MSW
00384     FUNC(XpmCreateXpmImageFromPixmap, int, (Display *display,
00385                                        Pixmap pixmap,
00386                                        Pixmap shapemask,
00387                                        XpmImage *xpmimage,
00388                                        XpmAttributes *attributes));
00389 #endif
00390     FUNC(XpmCreateDataFromXpmImage, int, (char ***data_return,
00391                                      XpmImage *image,
00392                                      XpmInfo *info));
00393 
00394     FUNC(XpmCreateXpmImageFromData, int, (char **data,
00395                                      XpmImage *image,
00396                                      XpmInfo *info));
00397 
00398     FUNC(XpmCreateXpmImageFromBuffer, int, (char *buffer,
00399                                        XpmImage *image,
00400                                        XpmInfo *info));
00401 
00402     FUNC(XpmCreateBufferFromXpmImage, int, (char **buffer_return,
00403                                        XpmImage *image,
00404                                        XpmInfo *info));
00405 
00406 #ifdef __cplusplus
00407 } /* for C++ V2.0 */
00408 #endif
00409 
00410 
00411 /* backward compatibility */
00412 
00413 /* for version 3.0c */
00414 #define XpmPixmapColorError  XpmColorError
00415 #define XpmPixmapSuccess     XpmSuccess
00416 #define XpmPixmapOpenFailed  XpmOpenFailed
00417 #define XpmPixmapFileInvalid XpmFileInvalid
00418 #define XpmPixmapNoMemory    XpmNoMemory
00419 #define XpmPixmapColorFailed XpmColorFailed
00420 
00421 #define XpmReadPixmapFile(dpy, d, file, pix, mask, att) \
00422     XpmReadFileToPixmap(dpy, d, file, pix, mask, att)
00423 #define XpmWritePixmapFile(dpy, file, pix, mask, att) \
00424     XpmWriteFileFromPixmap(dpy, file, pix, mask, att)
00425 
00426 /* for version 3.0b */
00427 #define PixmapColorError  XpmColorError
00428 #define PixmapSuccess     XpmSuccess
00429 #define PixmapOpenFailed  XpmOpenFailed
00430 #define PixmapFileInvalid XpmFileInvalid
00431 #define PixmapNoMemory    XpmNoMemory
00432 #define PixmapColorFailed XpmColorFailed
00433 
00434 #define ColorSymbol XpmColorSymbol
00435 
00436 #define XReadPixmapFile(dpy, d, file, pix, mask, att) \
00437     XpmReadFileToPixmap(dpy, d, file, pix, mask, att)
00438 #define XWritePixmapFile(dpy, file, pix, mask, att) \
00439     XpmWriteFileFromPixmap(dpy, file, pix, mask, att)
00440 #define XCreatePixmapFromData(dpy, d, data, pix, mask, att) \
00441     XpmCreatePixmapFromData(dpy, d, data, pix, mask, att)
00442 #define XCreateDataFromPixmap(dpy, data, pix, mask, att) \
00443     XpmCreateDataFromPixmap(dpy, data, pix, mask, att)
00444 
00445 #endif /* XPM_NUMBERS */
00446 #endif