home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Source Code 1993 July / THE_SOURCE_CODE_CD_ROM.iso / gnu / lucid / xpm-3.2a / xpm.h < prev    next >
Encoding:
C/C++ Source or Header  |  1992-08-16  |  7.1 KB  |  231 lines

  1. /* Copyright 1990,91 GROUPE BULL -- See license conditions in file COPYRIGHT */
  2. /*****************************************************************************\
  3. * xpm.h:                                                                      *
  4. *                                                                             *
  5. *  XPM library                                                                *
  6. *  Include file                                                               *
  7. *                                                                             *
  8. *  Developed by Arnaud Le Hors                                                *
  9. \*****************************************************************************/
  10.  
  11. #ifndef XPM_h
  12. #define XPM_h
  13.  
  14. #ifdef VMS
  15. #include "decw$include:Xlib.h"
  16. #include "decw$include:Intrinsic.h"
  17. #include "sys$library:stdio.h"
  18. #else
  19. #include <X11/Xlib.h>
  20. #include <X11/Intrinsic.h>
  21. #include <stdio.h>
  22. #endif
  23.  
  24. /* we keep the same codes as for Bitmap management */
  25. #ifndef _XUTIL_H_
  26. #ifdef VMS
  27. #include "decw$include:Xutil.h"
  28. #else
  29. #include <X11/Xutil.h>
  30. #endif
  31. #endif
  32.  
  33. /* Return ErrorStatus codes:
  34.  * null     if full success
  35.  * positive if partial success
  36.  * negative if failure
  37.  */
  38.  
  39. #define XpmColorError    1
  40. #define XpmSuccess       0
  41. #define XpmOpenFailed   -1
  42. #define XpmFileInvalid  -2
  43. #define XpmNoMemory     -3
  44. #define XpmColorFailed  -4
  45.  
  46.  
  47. typedef struct {
  48.     char *name;                /* Symbolic color name */
  49.     char *value;            /* Color value */
  50.     Pixel pixel;            /* Color pixel */
  51. }      XpmColorSymbol;
  52.  
  53. typedef struct {
  54.     char *name;                /* name of the extension */
  55.     unsigned int nlines;        /* number of lines in this extension */
  56.     char **lines;            /* pointer to the extension array of 
  57.                        strings */
  58. }      XpmExtension;
  59.  
  60. typedef struct {
  61.     unsigned long valuemask;        /* Specifies which attributes are
  62.                      * defined */
  63.  
  64.     Visual *visual;            /* Specifies the visual to use */
  65.     Colormap colormap;            /* Specifies the colormap to use */
  66.     unsigned int depth;            /* Specifies the depth */
  67.     unsigned int width;            /* Returns the width of the created
  68.                      * pixmap */
  69.     unsigned int height;        /* Returns the height of the created
  70.                      * pixmap */
  71.     unsigned int x_hotspot;        /* Returns the x hotspot's
  72.                      * coordinate */
  73.     unsigned int y_hotspot;        /* Returns the y hotspot's
  74.                      * coordinate */
  75.     unsigned int cpp;            /* Specifies the number of char per
  76.                      * pixel */
  77.     Pixel *pixels;            /* List of used color pixels */
  78.     unsigned int npixels;        /* Number of pixels */
  79.     XpmColorSymbol *colorsymbols;    /* Array of color symbols to
  80.                      * override */
  81.     unsigned int numsymbols;        /* Number of symbols */
  82.     char *rgb_fname;            /* RGB text file name */
  83.     unsigned int nextensions;        /* number of extensions */
  84.     XpmExtension *extensions;        /* pointer to array of extensions */
  85.  
  86.     /* Infos */
  87.     unsigned int ncolors;        /* Number of colors */
  88.     char ***colorTable;            /* Color table pointer */
  89.     char *hints_cmt;            /* Comment of the hints section */
  90.     char *colors_cmt;            /* Comment of the colors section */
  91.     char *pixels_cmt;            /* Comment of the pixels section */
  92.     unsigned int mask_pixel;        /* Transparent pixel's color table
  93.                      * index */
  94. }      XpmAttributes;
  95.  
  96. /* Xpm attribute value masks bits */
  97. #define XpmVisual       (1L<<0)
  98. #define XpmColormap       (1L<<1)
  99. #define XpmDepth       (1L<<2)
  100. #define XpmSize           (1L<<3)    /* width & height */
  101. #define XpmHotspot       (1L<<4)    /* x_hotspot & y_hotspot */
  102. #define XpmCharsPerPixel   (1L<<5)
  103. #define XpmColorSymbols       (1L<<6)
  104. #define XpmRgbFilename       (1L<<7)
  105. #define XpmInfos       (1L<<8)    /* all infos members */
  106. #define XpmExtensions      (1L<<10)
  107.  
  108. #define XpmReturnPixels       (1L<<9)
  109. #define XpmReturnInfos       XpmInfos
  110. #define XpmReturnExtensions XpmExtensions
  111.  
  112. /*
  113.  * minimal portability layer between ansi and KR C 
  114.  */
  115.  
  116. /* forward declaration of functions with prototypes */
  117.  
  118. #if __STDC__ || defined(__cplusplus) || defined(c_plusplus)
  119.  /* ANSI || C++ */
  120. #define FUNC(f, t, p) extern t f p
  121. #define LFUNC(f, t, p) static t f p
  122. #else                    /* K&R */
  123. #define FUNC(f, t, p) extern t f()
  124. #define LFUNC(f, t, p) static t f()
  125. #endif                    /* end of K&R */
  126.  
  127.  
  128. /*
  129.  * functions declarations
  130.  */
  131.  
  132. #ifdef __cplusplus
  133. extern "C" {
  134. #endif
  135.  
  136.     FUNC(XpmCreatePixmapFromData, int, (Display * display,
  137.                     Drawable d,
  138.                     char **data,
  139.                     Pixmap * pixmap_return,
  140.                     Pixmap * shapemask_return,
  141.                     XpmAttributes * attributes));
  142.  
  143.     FUNC(XpmCreateDataFromPixmap, int, (Display * display,
  144.                     char ***data_return,
  145.                     Pixmap pixmap,
  146.                     Pixmap shapemask,
  147.                     XpmAttributes * attributes));
  148.  
  149.     FUNC(XpmReadFileToPixmap, int, (Display * display,
  150.                     Drawable d,
  151.                     char *filename,
  152.                     Pixmap * pixmap_return,
  153.                     Pixmap * shapemask_return,
  154.                     XpmAttributes * attributes));
  155.  
  156.     FUNC(XpmWriteFileFromPixmap, int, (Display * display,
  157.                        char *filename,
  158.                        Pixmap pixmap,
  159.                        Pixmap shapemask,
  160.                        XpmAttributes * attributes));
  161.  
  162.     FUNC(XpmCreateImageFromData, int, (Display * display,
  163.                        char **data,
  164.                        XImage ** image_return,
  165.                        XImage ** shapemask_return,
  166.                        XpmAttributes * attributes));
  167.  
  168.     FUNC(XpmCreateDataFromImage, int, (Display * display,
  169.                        char ***data_return,
  170.                        XImage * image,
  171.                        XImage * shapeimage,
  172.                        XpmAttributes * attributes));
  173.  
  174.     FUNC(XpmReadFileToImage, int, (Display * display,
  175.                    char *filename,
  176.                    XImage ** image_return,
  177.                    XImage ** shapeimage_return,
  178.                    XpmAttributes * attributes));
  179.  
  180.     FUNC(XpmWriteFileFromImage, int, (Display * display,
  181.                       char *filename,
  182.                       XImage * image,
  183.                       XImage * shapeimage,
  184.                       XpmAttributes * attributes));
  185.  
  186.     FUNC(XpmAttributesSize, int, ());
  187.     FUNC(XpmFreeAttributes, int, (XpmAttributes * attributes));
  188.     FUNC(XpmFreeExtensions, int, (XpmExtension * extensions, int nextensions));
  189.  
  190. #ifdef __cplusplus
  191. }                    /* for C++ V2.0 */
  192.  
  193. #endif
  194.  
  195.  
  196. /* backward compatibility */
  197.  
  198. /* for version 3.0c */
  199. #define XpmPixmapColorError  XpmColorError
  200. #define XpmPixmapSuccess     XpmSuccess
  201. #define XpmPixmapOpenFailed  XpmOpenFailed
  202. #define XpmPixmapFileInvalid XpmFileInvalid
  203. #define XpmPixmapNoMemory    XpmNoMemory
  204. #define XpmPixmapColorFailed XpmColorFailed
  205.  
  206. #define XpmReadPixmapFile(dpy, d, file, pix, mask, att) \
  207.     XpmReadFileToPixmap(dpy, d, file, pix, mask, att)
  208. #define XpmWritePixmapFile(dpy, file, pix, mask, att) \
  209.     XpmWriteFileFromPixmap(dpy, file, pix, mask, att)
  210.  
  211. /* for version 3.0b */
  212. #define PixmapColorError  XpmColorError
  213. #define PixmapSuccess     XpmSuccess
  214. #define PixmapOpenFailed  XpmOpenFailed
  215. #define PixmapFileInvalid XpmFileInvalid
  216. #define PixmapNoMemory    XpmNoMemory
  217. #define PixmapColorFailed XpmColorFailed
  218.  
  219. #define ColorSymbol XpmColorSymbol
  220.  
  221. #define XReadPixmapFile(dpy, d, file, pix, mask, att) \
  222.     XpmReadFileToPixmap(dpy, d, file, pix, mask, att)
  223. #define XWritePixmapFile(dpy, file, pix, mask, att) \
  224.     XpmWriteFileFromPixmap(dpy, file, pix, mask, att)
  225. #define XCreatePixmapFromData(dpy, d, data, pix, mask, att) \
  226.     XpmCreatePixmapFromData(dpy, d, data, pix, mask, att)
  227. #define XCreateDataFromPixmap(dpy, data, pix, mask, att) \
  228.     XpmCreateDataFromPixmap(dpy, data, pix, mask, att)
  229.  
  230. #endif
  231.