Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:14:34

0001 /*
0002  * Copyright (C) 1989-95 GROUPE BULL
0003  *
0004  * Permission is hereby granted, free of charge, to any person obtaining a copy
0005  * of this software and associated documentation files (the "Software"), to
0006  * deal in the Software without restriction, including without limitation the
0007  * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
0008  * sell copies of the Software, and to permit persons to whom the Software is
0009  * furnished to do so, subject to the following conditions:
0010  *
0011  * The above copyright notice and this permission notice shall be included in
0012  * all copies or substantial portions of the Software.
0013  *
0014  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
0015  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
0016  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
0017  * GROUPE BULL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
0018  * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
0019  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
0020  *
0021  * Except as contained in this notice, the name of GROUPE BULL shall not be
0022  * used in advertising or otherwise to promote the sale, use or other dealings
0023  * in this Software without prior written authorization from GROUPE BULL.
0024  */
0025 
0026 /*****************************************************************************\
0027 * xpm.h:                                                                      *
0028 *                                                                             *
0029 *  XPM library                                                                *
0030 *  Include file                                                               *
0031 *                                                                             *
0032 *  Developed by Arnaud Le Hors                                                *
0033 \*****************************************************************************/
0034 
0035 /*
0036  * The code related to FOR_MSW has been added by
0037  * HeDu (hedu@cul-ipn.uni-kiel.de) 4/94
0038  */
0039 
0040 /*
0041  * The code related to AMIGA has been added by
0042  * Lorens Younes (d93-hyo@nada.kth.se) 4/96
0043  */
0044 
0045 #ifndef XPM_h
0046 #define XPM_h
0047 
0048 /*
0049  * first some identification numbers:
0050  * the version and revision numbers are determined with the following rule:
0051  * SO Major number = LIB minor version number.
0052  * SO Minor number = LIB sub-minor version number.
0053  * e.g: Xpm version 3.2f
0054  *      we forget the 3 which is the format number, 2 gives 2, and f gives 6.
0055  *      thus we have XpmVersion = 2 and XpmRevision = 6
0056  *      which gives  SOXPMLIBREV = 2.6
0057  *
0058  * Then the XpmIncludeVersion number is built from these numbers.
0059  */
0060 #define XpmFormat 3
0061 #define XpmVersion 4
0062 #define XpmRevision 11
0063 #define XpmIncludeVersion ((XpmFormat * 100 + XpmVersion) * 100 + XpmRevision)
0064 
0065 #ifndef XPM_NUMBERS
0066 
0067 #ifdef FOR_MSW
0068 # define SYSV           /* uses memcpy string.h etc. */
0069 # include <malloc.h>
0070 # include "simx.h"      /* defines some X stuff using MSW types */
0071 #define NEED_STRCASECMP     /* at least for MSVC++ */
0072 #else /* FOR_MSW */
0073 # ifdef AMIGA
0074 #  include "amigax.h"
0075 # else /* not AMIGA */
0076 #  include <X11/Xfuncproto.h>
0077 #  include <X11/Xlib.h>
0078 #  include <X11/Xutil.h>
0079 # endif /* not AMIGA */
0080 #endif /* FOR_MSW */
0081 
0082 /* let's define Pixel if it is not done yet */
0083 #if ! defined(_XtIntrinsic_h) && ! defined(PIXEL_ALREADY_TYPEDEFED)
0084 typedef unsigned long Pixel;    /* Index into colormap */
0085 # define PIXEL_ALREADY_TYPEDEFED
0086 #endif
0087 
0088 /* Return ErrorStatus codes:
0089  * null     if full success
0090  * positive if partial success
0091  * negative if failure
0092  */
0093 
0094 #define XpmColorError    1
0095 #define XpmSuccess       0
0096 #define XpmOpenFailed   -1
0097 #define XpmFileInvalid  -2
0098 #define XpmNoMemory     -3
0099 #define XpmColorFailed  -4
0100 
0101 typedef struct {
0102     char *name;         /* Symbolic color name */
0103     char *value;        /* Color value */
0104     Pixel pixel;        /* Color pixel */
0105 }      XpmColorSymbol;
0106 
0107 typedef struct {
0108     char *name;         /* name of the extension */
0109     unsigned int nlines;    /* number of lines in this extension */
0110     char **lines;       /* pointer to the extension array of strings */
0111 }      XpmExtension;
0112 
0113 typedef struct {
0114     char *string;       /* characters string */
0115     char *symbolic;     /* symbolic name */
0116     char *m_color;      /* monochrom default */
0117     char *g4_color;     /* 4 level grayscale default */
0118     char *g_color;      /* other level grayscale default */
0119     char *c_color;      /* color default */
0120 }      XpmColor;
0121 
0122 typedef struct {
0123     unsigned int width;     /* image width */
0124     unsigned int height;    /* image height */
0125     unsigned int cpp;       /* number of characters per pixel */
0126     unsigned int ncolors;   /* number of colors */
0127     XpmColor *colorTable;   /* list of related colors */
0128     unsigned int *data;     /* image data */
0129 }      XpmImage;
0130 
0131 typedef struct {
0132     unsigned long valuemask;    /* Specifies which attributes are defined */
0133     char *hints_cmt;        /* Comment of the hints section */
0134     char *colors_cmt;       /* Comment of the colors section */
0135     char *pixels_cmt;       /* Comment of the pixels section */
0136     unsigned int x_hotspot; /* Returns the x hotspot's coordinate */
0137     unsigned int y_hotspot; /* Returns the y hotspot's coordinate */
0138     unsigned int nextensions;   /* number of extensions */
0139     XpmExtension *extensions;   /* pointer to array of extensions */
0140 }      XpmInfo;
0141 
0142 typedef int (*XpmAllocColorFunc)(
0143     Display*            /* display */,
0144     Colormap            /* colormap */,
0145     char*           /* colorname */,
0146     XColor*         /* xcolor */,
0147     void*           /* closure */
0148 );
0149 
0150 typedef int (*XpmFreeColorsFunc)(
0151     Display*            /* display */,
0152     Colormap            /* colormap */,
0153     Pixel*          /* pixels */,
0154     int             /* npixels */,
0155     void*           /* closure */
0156 );
0157 
0158 typedef struct {
0159     unsigned long valuemask;        /* Specifies which attributes are
0160                        defined */
0161 
0162     Visual *visual;         /* Specifies the visual to use */
0163     Colormap colormap;          /* Specifies the colormap to use */
0164     unsigned int depth;         /* Specifies the depth */
0165     unsigned int width;         /* Returns the width of the created
0166                        pixmap */
0167     unsigned int height;        /* Returns the height of the created
0168                        pixmap */
0169     unsigned int x_hotspot;     /* Returns the x hotspot's
0170                        coordinate */
0171     unsigned int y_hotspot;     /* Returns the y hotspot's
0172                        coordinate */
0173     unsigned int cpp;           /* Specifies the number of char per
0174                        pixel */
0175     Pixel *pixels;          /* List of used color pixels */
0176     unsigned int npixels;       /* Number of used pixels */
0177     XpmColorSymbol *colorsymbols;   /* List of color symbols to override */
0178     unsigned int numsymbols;        /* Number of symbols */
0179     char *rgb_fname;            /* RGB text file name */
0180     unsigned int nextensions;       /* Number of extensions */
0181     XpmExtension *extensions;       /* List of extensions */
0182 
0183     unsigned int ncolors;               /* Number of colors */
0184     XpmColor *colorTable;               /* List of colors */
0185 /* 3.2 backward compatibility code */
0186     char *hints_cmt;                    /* Comment of the hints section */
0187     char *colors_cmt;                   /* Comment of the colors section */
0188     char *pixels_cmt;                   /* Comment of the pixels section */
0189 /* end 3.2 bc */
0190     unsigned int mask_pixel;            /* Color table index of transparent
0191                                            color */
0192 
0193     /* Color Allocation Directives */
0194     Bool exactColors;           /* Only use exact colors for visual */
0195     unsigned int closeness;     /* Allowable RGB deviation */
0196     unsigned int red_closeness;     /* Allowable red deviation */
0197     unsigned int green_closeness;   /* Allowable green deviation */
0198     unsigned int blue_closeness;    /* Allowable blue deviation */
0199     int color_key;          /* Use colors from this color set */
0200 
0201     Pixel *alloc_pixels;        /* Returns the list of alloc'ed color
0202                        pixels */
0203     int nalloc_pixels;          /* Returns the number of alloc'ed
0204                        color pixels */
0205 
0206     Bool alloc_close_colors;        /* Specify whether close colors should
0207                        be allocated using XAllocColor
0208                        or not */
0209     int bitmap_format;          /* Specify the format of 1bit depth
0210                        images: ZPixmap or XYBitmap */
0211 
0212     /* Color functions */
0213     XpmAllocColorFunc alloc_color;  /* Application color allocator */
0214     XpmFreeColorsFunc free_colors;  /* Application color de-allocator */
0215     void *color_closure;        /* Application private data to pass to
0216                        alloc_color and free_colors */
0217 
0218 }      XpmAttributes;
0219 
0220 /* XpmAttributes value masks bits */
0221 #define XpmVisual      (1L<<0)
0222 #define XpmColormap    (1L<<1)
0223 #define XpmDepth       (1L<<2)
0224 #define XpmSize        (1L<<3)  /* width & height */
0225 #define XpmHotspot     (1L<<4)  /* x_hotspot & y_hotspot */
0226 #define XpmCharsPerPixel   (1L<<5)
0227 #define XpmColorSymbols    (1L<<6)
0228 #define XpmRgbFilename     (1L<<7)
0229 /* 3.2 backward compatibility code */
0230 #define XpmInfos       (1L<<8)
0231 #define XpmReturnInfos     XpmInfos
0232 /* end 3.2 bc */
0233 #define XpmReturnPixels    (1L<<9)
0234 #define XpmExtensions      (1L<<10)
0235 #define XpmReturnExtensions XpmExtensions
0236 
0237 #define XpmExactColors     (1L<<11)
0238 #define XpmCloseness       (1L<<12)
0239 #define XpmRGBCloseness    (1L<<13)
0240 #define XpmColorKey    (1L<<14)
0241 
0242 #define XpmColorTable      (1L<<15)
0243 #define XpmReturnColorTable XpmColorTable
0244 
0245 #define XpmReturnAllocPixels (1L<<16)
0246 #define XpmAllocCloseColors (1L<<17)
0247 #define XpmBitmapFormat    (1L<<18)
0248 
0249 #define XpmAllocColor      (1L<<19)
0250 #define XpmFreeColors      (1L<<20)
0251 #define XpmColorClosure    (1L<<21)
0252 
0253 
0254 /* XpmInfo value masks bits */
0255 #define XpmComments        XpmInfos
0256 #define XpmReturnComments  XpmComments
0257 
0258 /* XpmAttributes mask_pixel value when there is no mask */
0259 #ifndef FOR_MSW
0260 #define XpmUndefPixel 0x80000000
0261 #else
0262 /* int is only 16 bit for MSW */
0263 #define XpmUndefPixel 0x8000
0264 #endif
0265 
0266 /*
0267  * color keys for visual type, they must fit along with the number key of
0268  * each related element in xpmColorKeys[] defined in XpmI.h
0269  */
0270 #define XPM_MONO    2
0271 #define XPM_GREY4   3
0272 #define XPM_GRAY4   3
0273 #define XPM_GREY    4
0274 #define XPM_GRAY    4
0275 #define XPM_COLOR   5
0276 
0277 
0278 /* macros for forward declarations of functions with prototypes */
0279 #ifndef _X_EXPORT
0280 # define _X_EXPORT
0281 # define _X_HIDDEN
0282 #endif
0283 #define FUNC(f, t, p) extern _X_EXPORT t f p
0284 #define HFUNC(f, t, p) extern _X_HIDDEN t f p
0285 #define LFUNC(f, t, p) static t f p
0286 
0287 
0288 /*
0289  * functions declarations
0290  */
0291 
0292 _XFUNCPROTOBEGIN
0293 
0294 /* FOR_MSW, all ..Pixmap.. are excluded, only the ..XImage.. are used */
0295 /* Same for Amiga! */
0296 
0297 #if !defined(FOR_MSW) && !defined(AMIGA)
0298     FUNC(XpmCreatePixmapFromData, int, (Display *display,
0299                     Drawable d,
0300                     char **data,
0301                     Pixmap *pixmap_return,
0302                     Pixmap *shapemask_return,
0303                     XpmAttributes *attributes));
0304 
0305     FUNC(XpmCreateDataFromPixmap, int, (Display *display,
0306                     char ***data_return,
0307                     Pixmap pixmap,
0308                     Pixmap shapemask,
0309                     XpmAttributes *attributes));
0310 
0311     FUNC(XpmReadFileToPixmap, int, (Display *display,
0312                     Drawable d,
0313                     const char *filename,
0314                     Pixmap *pixmap_return,
0315                     Pixmap *shapemask_return,
0316                     XpmAttributes *attributes));
0317 
0318     FUNC(XpmWriteFileFromPixmap, int, (Display *display,
0319                        const char *filename,
0320                        Pixmap pixmap,
0321                        Pixmap shapemask,
0322                        XpmAttributes *attributes));
0323 #endif
0324 
0325     FUNC(XpmCreateImageFromData, int, (Display *display,
0326                        char **data,
0327                        XImage **image_return,
0328                        XImage **shapemask_return,
0329                        XpmAttributes *attributes));
0330 
0331     FUNC(XpmCreateDataFromImage, int, (Display *display,
0332                        char ***data_return,
0333                        XImage *image,
0334                        XImage *shapeimage,
0335                        XpmAttributes *attributes));
0336 
0337     FUNC(XpmReadFileToImage, int, (Display *display,
0338                    const char *filename,
0339                    XImage **image_return,
0340                    XImage **shapeimage_return,
0341                    XpmAttributes *attributes));
0342 
0343     FUNC(XpmWriteFileFromImage, int, (Display *display,
0344                       const char *filename,
0345                       XImage *image,
0346                       XImage *shapeimage,
0347                       XpmAttributes *attributes));
0348 
0349     FUNC(XpmCreateImageFromBuffer, int, (Display *display,
0350                      char *buffer,
0351                      XImage **image_return,
0352                      XImage **shapemask_return,
0353                      XpmAttributes *attributes));
0354 #if !defined(FOR_MSW) && !defined(AMIGA)
0355     FUNC(XpmCreatePixmapFromBuffer, int, (Display *display,
0356                       Drawable d,
0357                       char *buffer,
0358                       Pixmap *pixmap_return,
0359                       Pixmap *shapemask_return,
0360                       XpmAttributes *attributes));
0361 
0362     FUNC(XpmCreateBufferFromImage, int, (Display *display,
0363                      char **buffer_return,
0364                      XImage *image,
0365                      XImage *shapeimage,
0366                      XpmAttributes *attributes));
0367 
0368     FUNC(XpmCreateBufferFromPixmap, int, (Display *display,
0369                       char **buffer_return,
0370                       Pixmap pixmap,
0371                       Pixmap shapemask,
0372                       XpmAttributes *attributes));
0373 #endif
0374     FUNC(XpmReadFileToBuffer, int, (const char *filename, char **buffer_return));
0375     FUNC(XpmWriteFileFromBuffer, int, (const char *filename, char *buffer));
0376 
0377     FUNC(XpmReadFileToData, int, (const char *filename, char ***data_return));
0378     FUNC(XpmWriteFileFromData, int, (const char *filename, char **data));
0379 
0380     FUNC(XpmAttributesSize, int, (void));
0381     FUNC(XpmFreeAttributes, void, (XpmAttributes *attributes));
0382     FUNC(XpmFreeExtensions, void, (XpmExtension *extensions,
0383                    int nextensions));
0384 
0385     FUNC(XpmFreeXpmImage, void, (XpmImage *image));
0386     FUNC(XpmFreeXpmInfo, void, (XpmInfo *info));
0387     FUNC(XpmGetErrorString, char *, (int errcode));
0388     FUNC(XpmLibraryVersion, int, (void));
0389 
0390     /* XpmImage functions */
0391     FUNC(XpmReadFileToXpmImage, int, (const char *filename,
0392                       XpmImage *image,
0393                       XpmInfo *info));
0394 
0395     FUNC(XpmWriteFileFromXpmImage, int, (const char *filename,
0396                      XpmImage *image,
0397                      XpmInfo *info));
0398 #if !defined(FOR_MSW) && !defined(AMIGA)
0399     FUNC(XpmCreatePixmapFromXpmImage, int, (Display *display,
0400                         Drawable d,
0401                         XpmImage *image,
0402                         Pixmap *pixmap_return,
0403                         Pixmap *shapemask_return,
0404                         XpmAttributes *attributes));
0405 #endif
0406     FUNC(XpmCreateImageFromXpmImage, int, (Display *display,
0407                        XpmImage *image,
0408                        XImage **image_return,
0409                        XImage **shapeimage_return,
0410                        XpmAttributes *attributes));
0411 
0412     FUNC(XpmCreateXpmImageFromImage, int, (Display *display,
0413                        XImage *image,
0414                        XImage *shapeimage,
0415                        XpmImage *xpmimage,
0416                        XpmAttributes *attributes));
0417 #if !defined(FOR_MSW) && !defined(AMIGA)
0418     FUNC(XpmCreateXpmImageFromPixmap, int, (Display *display,
0419                         Pixmap pixmap,
0420                         Pixmap shapemask,
0421                         XpmImage *xpmimage,
0422                         XpmAttributes *attributes));
0423 #endif
0424     FUNC(XpmCreateDataFromXpmImage, int, (char ***data_return,
0425                       XpmImage *image,
0426                       XpmInfo *info));
0427 
0428     FUNC(XpmCreateXpmImageFromData, int, (char **data,
0429                       XpmImage *image,
0430                       XpmInfo *info));
0431 
0432     FUNC(XpmCreateXpmImageFromBuffer, int, (char *buffer,
0433                         XpmImage *image,
0434                         XpmInfo *info));
0435 
0436     FUNC(XpmCreateBufferFromXpmImage, int, (char **buffer_return,
0437                         XpmImage *image,
0438                         XpmInfo *info));
0439 
0440     FUNC(XpmGetParseError, int, (char *filename,
0441                  int *linenum_return,
0442                  int *charnum_return));
0443 
0444     FUNC(XpmFree, void, (void *ptr));
0445 
0446 _XFUNCPROTOEND
0447 
0448 /* backward compatibility */
0449 
0450 /* for version 3.0c */
0451 #define XpmPixmapColorError  XpmColorError
0452 #define XpmPixmapSuccess     XpmSuccess
0453 #define XpmPixmapOpenFailed  XpmOpenFailed
0454 #define XpmPixmapFileInvalid XpmFileInvalid
0455 #define XpmPixmapNoMemory    XpmNoMemory
0456 #define XpmPixmapColorFailed XpmColorFailed
0457 
0458 #define XpmReadPixmapFile(dpy, d, file, pix, mask, att) \
0459     XpmReadFileToPixmap(dpy, d, file, pix, mask, att)
0460 #define XpmWritePixmapFile(dpy, file, pix, mask, att) \
0461     XpmWriteFileFromPixmap(dpy, file, pix, mask, att)
0462 
0463 /* for version 3.0b */
0464 #define PixmapColorError  XpmColorError
0465 #define PixmapSuccess     XpmSuccess
0466 #define PixmapOpenFailed  XpmOpenFailed
0467 #define PixmapFileInvalid XpmFileInvalid
0468 #define PixmapNoMemory    XpmNoMemory
0469 #define PixmapColorFailed XpmColorFailed
0470 
0471 #define ColorSymbol XpmColorSymbol
0472 
0473 #define XReadPixmapFile(dpy, d, file, pix, mask, att) \
0474     XpmReadFileToPixmap(dpy, d, file, pix, mask, att)
0475 #define XWritePixmapFile(dpy, file, pix, mask, att) \
0476     XpmWriteFileFromPixmap(dpy, file, pix, mask, att)
0477 #define XCreatePixmapFromData(dpy, d, data, pix, mask, att) \
0478     XpmCreatePixmapFromData(dpy, d, data, pix, mask, att)
0479 #define XCreateDataFromPixmap(dpy, data, pix, mask, att) \
0480     XpmCreateDataFromPixmap(dpy, data, pix, mask, att)
0481 
0482 #endif /* XPM_NUMBERS */
0483 #endif