home *** CD-ROM | disk | FTP | other *** search
/ PC Online 1997 May / PCO_5_97.ISO / FilesBBS / OS2 / XPM.ARJ / XPM / XPM.ZIP / XFree86 / include / X11 / xpm.h
Encoding:
C/C++ Source or Header  |  1996-03-19  |  14.7 KB  |  446 lines

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