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