home *** CD-ROM | disk | FTP | other *** search
/ ftp.cs.arizona.edu / ftp.cs.arizona.edu.tar / ftp.cs.arizona.edu / icon / historic / v941.tgz / icon.v941src.tar / icon.v941src / src / xpm / xpm.h < prev    next >
C/C++ Source or Header  |  2000-07-29  |  8KB  |  238 lines

  1. /* Copyright 1990-92 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 <stdio.h>
  20. #include <X11/Xlib.h>
  21. #include <X11/Intrinsic.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.     /* Color Allocation Directives */
  95.     unsigned int exactColors;        /* Only use exact colors for visual */
  96.     unsigned int closeness;        /* Allowable RGB deviation */
  97.  
  98. }      XpmAttributes;
  99.  
  100. /* Xpm attribute value masks bits */
  101. #define XpmVisual       (1L<<0)
  102. #define XpmColormap       (1L<<1)
  103. #define XpmDepth       (1L<<2)
  104. #define XpmSize           (1L<<3)    /* width & height */
  105. #define XpmHotspot       (1L<<4)    /* x_hotspot & y_hotspot */
  106. #define XpmCharsPerPixel   (1L<<5)
  107. #define XpmColorSymbols       (1L<<6)
  108. #define XpmRgbFilename       (1L<<7)
  109. #define XpmInfos       (1L<<8)    /* all infos members */
  110. #define XpmExtensions      (1L<<10)
  111.  
  112. #define XpmReturnPixels       (1L<<9)
  113. #define XpmReturnInfos       XpmInfos
  114. #define XpmReturnExtensions XpmExtensions
  115.  
  116. #define XpmExactColors     (1L<<11)
  117. #define XpmCloseness       (1L<<12)
  118.  
  119. /*
  120.  * minimal portability layer between ansi and KR C 
  121.  */
  122.  
  123. /* forward declaration of functions with prototypes */
  124.  
  125. #if __STDC__ || defined(__cplusplus) || defined(c_plusplus)
  126.  /* ANSI || C++ */
  127. #define FUNC(f, t, p) extern t f p
  128. #define LFUNC(f, t, p) static t f p
  129. #else                    /* K&R */
  130. #define FUNC(f, t, p) extern t f()
  131. #define LFUNC(f, t, p) static t f()
  132. #endif                    /* end of K&R */
  133.  
  134.  
  135. /*
  136.  * functions declarations
  137.  */
  138.  
  139. #ifdef __cplusplus
  140. extern "C" {
  141. #endif
  142.  
  143.     FUNC(XpmCreatePixmapFromData, int, (Display * display,
  144.                     Drawable d,
  145.                     char **data,
  146.                     Pixmap * pixmap_return,
  147.                     Pixmap * shapemask_return,
  148.                     XpmAttributes * attributes));
  149.  
  150.     FUNC(XpmCreateDataFromPixmap, int, (Display * display,
  151.                     char ***data_return,
  152.                     Pixmap pixmap,
  153.                     Pixmap shapemask,
  154.                     XpmAttributes * attributes));
  155.  
  156.     FUNC(XpmReadFileToPixmap, int, (Display * display,
  157.                     Drawable d,
  158.                     char *filename,
  159.                     Pixmap * pixmap_return,
  160.                     Pixmap * shapemask_return,
  161.                     XpmAttributes * attributes));
  162.  
  163.     FUNC(XpmWriteFileFromPixmap, int, (Display * display,
  164.                        char *filename,
  165.                        Pixmap pixmap,
  166.                        Pixmap shapemask,
  167.                        XpmAttributes * attributes));
  168.  
  169.     FUNC(XpmCreateImageFromData, int, (Display * display,
  170.                        char **data,
  171.                        XImage ** image_return,
  172.                        XImage ** shapemask_return,
  173.                        XpmAttributes * attributes));
  174.  
  175.     FUNC(XpmCreateDataFromImage, int, (Display * display,
  176.                        char ***data_return,
  177.                        XImage * image,
  178.                        XImage * shapeimage,
  179.                        XpmAttributes * attributes));
  180.  
  181.     FUNC(XpmReadFileToImage, int, (Display * display,
  182.                    char *filename,
  183.                    XImage ** image_return,
  184.                    XImage ** shapeimage_return,
  185.                    XpmAttributes * attributes));
  186.  
  187.     FUNC(XpmWriteFileFromImage, int, (Display * display,
  188.                       char *filename,
  189.                       XImage * image,
  190.                       XImage * shapeimage,
  191.                       XpmAttributes * attributes));
  192.  
  193.     FUNC(XpmAttributesSize, int, ());
  194.     FUNC(XpmFreeAttributes, int, (XpmAttributes * attributes));
  195.     FUNC(XpmFreeExtensions, int, (XpmExtension * extensions, int nextensions));
  196.  
  197. #ifdef __cplusplus
  198. }                    /* for C++ V2.0 */
  199.  
  200. #endif
  201.  
  202.  
  203. /* backward compatibility */
  204.  
  205. /* for version 3.0c */
  206. #define XpmPixmapColorError  XpmColorError
  207. #define XpmPixmapSuccess     XpmSuccess
  208. #define XpmPixmapOpenFailed  XpmOpenFailed
  209. #define XpmPixmapFileInvalid XpmFileInvalid
  210. #define XpmPixmapNoMemory    XpmNoMemory
  211. #define XpmPixmapColorFailed XpmColorFailed
  212.  
  213. #define XpmReadPixmapFile(dpy, d, file, pix, mask, att) \
  214.     XpmReadFileToPixmap(dpy, d, file, pix, mask, att)
  215. #define XpmWritePixmapFile(dpy, file, pix, mask, att) \
  216.     XpmWriteFileFromPixmap(dpy, file, pix, mask, att)
  217.  
  218. /* for version 3.0b */
  219. #define PixmapColorError  XpmColorError
  220. #define PixmapSuccess     XpmSuccess
  221. #define PixmapOpenFailed  XpmOpenFailed
  222. #define PixmapFileInvalid XpmFileInvalid
  223. #define PixmapNoMemory    XpmNoMemory
  224. #define PixmapColorFailed XpmColorFailed
  225.  
  226. #define ColorSymbol XpmColorSymbol
  227.  
  228. #define XReadPixmapFile(dpy, d, file, pix, mask, att) \
  229.     XpmReadFileToPixmap(dpy, d, file, pix, mask, att)
  230. #define XWritePixmapFile(dpy, file, pix, mask, att) \
  231.     XpmWriteFileFromPixmap(dpy, file, pix, mask, att)
  232. #define XCreatePixmapFromData(dpy, d, data, pix, mask, att) \
  233.     XpmCreatePixmapFromData(dpy, d, data, pix, mask, att)
  234. #define XCreateDataFromPixmap(dpy, data, pix, mask, att) \
  235.     XpmCreateDataFromPixmap(dpy, data, pix, mask, att)
  236.  
  237. #endif
  238.