1 /* 2 * Motif 3 * 4 * Copyright (c) 1987-2012, The Open Group. All rights reserved. 5 * 6 * These libraries and programs are free software; you can 7 * redistribute them and/or modify them under the terms of the GNU 8 * Lesser General Public License as published by the Free Software 9 * Foundation; either version 2 of the License, or (at your option) 10 * any later version. 11 * 12 * These libraries and programs are distributed in the hope that 13 * they will be useful, but WITHOUT ANY WARRANTY; without even the 14 * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 15 * PURPOSE. See the GNU Lesser General Public License for more 16 * details. 17 * 18 * You should have received a copy of the GNU Lesser General Public 19 * License along with these librararies and programs; if not, write 20 * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth 21 * Floor, Boston, MA 02110-1301 USA 22 */ 23 24 #ifndef _XpmP_h 25 #define _XpmP_h 26 27 /* Xpm external symbols are prefixed with Xme */ 28 29 #define XpmCreatePixmapFromData XmeXpmCreatePixmapFromData 30 #define XpmCreateDataFromPixmap XmeXpmCreateDataFromPixmap 31 #define XpmReadFileToPixmap XmeXpmReadFileToPixmap 32 #define XpmWriteFileFromPixmap XmeXpmWriteFileFromPixmap 33 #define XpmCreateImageFromData XmeXpmCreateImageFromData 34 #define XpmCreateDataFromImage XmeXpmCreateDataFromImage 35 #define XpmReadFileToImage XmeXpmReadFileToImage 36 #define XpmWriteFileFromImage XmeXpmWriteFileFromImage 37 #define XpmCreateImageFromBuffer XmeXpmCreateImageFromBuffer 38 #define XpmCreatePixmapFromBuffer XmeXpmCreatePixmapFromBuffer 39 #define XpmCreateBufferFromImage XmeXpmCreateBufferFromImage 40 #define XpmCreateBufferFromPixmap XmeXpmCreateBufferFromPixmap 41 #define XpmReadFileToBuffer XmeXpmReadFileToBuffer 42 #define XpmWriteFileFromBuffer XmeXpmWriteFileFromBuffer 43 #define XpmReadFileToData XmeXpmReadFileToData 44 #define XpmWriteFileFromData XmeXpmWriteFileFromData 45 #define XpmAttributesSize XmeXpmAttributesSize 46 #define XpmFreeAttributes XmeXpmFreeAttributes 47 #define XpmFreeExtensions XmeXpmFreeExtensions 48 #define XpmFreeXpmImage XmeXpmFreeXpmImage 49 #define XpmFreeXpmInfo XmeXpmFreeXpmInfo 50 #define XpmGetErrorString XmeXpmGetErrorString 51 #define XpmLibraryVersion XmeXpmLibraryVersion 52 #define XpmReadFileToXpmImage XmeXpmReadFileToXpmImage 53 #define XpmWriteFileFromXpmImage XmeXpmWriteFileFromXpmImage 54 #define XpmCreatePixmapFromXpmImage XmeXpmCreatePixmapFromXpmImage 55 #define XpmCreateImageFromXpmImage XmeXpmCreateImageFromXpmImage 56 #define XpmCreateXpmImageFromImage XmeXpmCreateXpmImageFromImage 57 #define XpmCreateXpmImageFromPixmap XmeXpmCreateXpmImageFromPixmap 58 #define XpmCreateDataFromXpmImage XmeXpmCreateDataFromXpmImage 59 #define XpmCreateXpmImageFromData XmeXpmCreateXpmImageFromData 60 #define XpmCreateXpmImageFromBuffer XmeXpmCreateXpmImageFromBuffer 61 #define XpmCreateBufferFromXpmImage XmeXpmCreateBufferFromXpmImage 62 #define XpmFree XmeXpmFree 63 64 /* The following is the original xpm.h header file */ 65 66 /* 67 * Copyright (C) 1989-95 GROUPE BULL 68 * 69 * Permission is hereby granted, free of charge, to any person obtaining a copy 70 * of this software and associated documentation files (the "Software"), to 71 * deal in the Software without restriction, including without limitation the 72 * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 73 * sell copies of the Software, and to permit persons to whom the Software is 74 * furnished to do so, subject to the following conditions: 75 * 76 * The above copyright notice and this permission notice shall be included in 77 * all copies or substantial portions of the Software. 78 * 79 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 80 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 81 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 82 * GROUPE BULL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN 83 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 84 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 85 * 86 * Except as contained in this notice, the name of GROUPE BULL shall not be 87 * used in advertising or otherwise to promote the sale, use or other dealings 88 * in this Software without prior written authorization from GROUPE BULL. 89 */ 90 91 /*****************************************************************************\ 92 * xpm.h: * 93 * * 94 * XPM library * 95 * Include file * 96 * * 97 * Developed by Arnaud Le Hors * 98 \*****************************************************************************/ 99 100 /* 101 * The code related to FOR_MSW has been added by 102 * HeDu (hedu@cul-ipn.uni-kiel.de) 4/94 103 */ 104 105 #ifndef XPM_h 106 #define XPM_h 107 108 /* 109 * first some identification numbers: 110 * the version and revision numbers are determined with the following rule: 111 * SO Major number = LIB minor version number. 112 * SO Minor number = LIB sub-minor version number. 113 * e.g: Xpm version 3.2f 114 * we forget the 3 which is the format number, 2 gives 2, and f gives 6. 115 * thus we have XpmVersion = 2 and XpmRevision = 6 116 * which gives SOXPMLIBREV = 2.6 117 * 118 * Then the XpmIncludeVersion number is built from these numbers. 119 */ 120 #define XpmFormat 3 121 #define XpmVersion 4 122 #define XpmRevision 9 123 #define XpmIncludeVersion ((XpmFormat * 100 + XpmVersion) * 100 + XpmRevision) 124 125 #ifndef XPM_NUMBERS 126 127 #ifdef FOR_MSW 128 # define SYSV /* uses memcpy string.h etc. */ 129 # include <malloc.h> 130 # include "simx.h" /* defines some X stuff using MSW types */ 131 #define NEED_STRCASECMP /* at least for MSVC++ */ 132 #else /* FOR_MSW */ 133 # include <X11/Xlib.h> 134 # include <X11/Xutil.h> 135 #endif /* FOR_MSW */ 136 137 /* let's define Pixel if it is not done yet */ 138 #if ! defined(_XtIntrinsic_h) && ! defined(PIXEL_ALREADY_TYPEDEFED) 139 typedef unsigned long Pixel; /* Index into colormap */ 140 # define PIXEL_ALREADY_TYPEDEFED 141 #endif 142 143 /* make sure we know whether function prototypes are needed or not */ 144 #ifndef NeedFunctionPrototypes 145 # if defined(__STDC__) || defined(__cplusplus) || defined(c_plusplus) 146 # define NeedFunctionPrototypes 1 147 # else 148 # define NeedFunctionPrototypes 0 149 # endif 150 #endif 151 152 153 /* Return ErrorStatus codes: 154 * null if full success 155 * positive if partial success 156 * negative if failure 157 */ 158 159 #define XpmColorError 1 160 #define XpmSuccess 0 161 #define XpmOpenFailed -1 162 #define XpmFileInvalid -2 163 #define XpmNoMemory -3 164 #define XpmColorFailed -4 165 166 typedef struct { 167 char *name; /* Symbolic color name */ 168 char *value; /* Color value */ 169 Pixel pixel; /* Color pixel */ 170 } XpmColorSymbol; 171 172 typedef struct { 173 char *name; /* name of the extension */ 174 unsigned int nlines; /* number of lines in this extension */ 175 char **lines; /* pointer to the extension array of strings */ 176 } XpmExtension; 177 178 typedef struct { 179 char *string; /* characters string */ 180 char *symbolic; /* symbolic name */ 181 char *m_color; /* monochrom default */ 182 char *g4_color; /* 4 level grayscale default */ 183 char *g_color; /* other level grayscale default */ 184 char *c_color; /* color default */ 185 } XpmColor; 186 187 typedef struct { 188 unsigned int width; /* image width */ 189 unsigned int height; /* image height */ 190 unsigned int cpp; /* number of characters per pixel */ 191 unsigned int ncolors; /* number of colors */ 192 XpmColor *colorTable; /* list of related colors */ 193 unsigned int *data; /* image data */ 194 } XpmImage; 195 196 typedef struct { 197 unsigned long valuemask; /* Specifies which attributes are defined */ 198 char *hints_cmt; /* Comment of the hints section */ 199 char *colors_cmt; /* Comment of the colors section */ 200 char *pixels_cmt; /* Comment of the pixels section */ 201 unsigned int x_hotspot; /* Returns the x hotspot's coordinate */ 202 unsigned int y_hotspot; /* Returns the y hotspot's coordinate */ 203 unsigned int nextensions; /* number of extensions */ 204 XpmExtension *extensions; /* pointer to array of extensions */ 205 } XpmInfo; 206 207 typedef int (*XpmAllocColorFunc)( 208 #if NeedFunctionPrototypes 209 Display* /* display */, 210 Colormap /* colormap */, 211 char* /* colorname */, 212 XColor* /* xcolor */, 213 void* /* closure */ 214 #endif 215 ); 216 217 typedef int (*XpmFreeColorsFunc)( 218 #if NeedFunctionPrototypes 219 Display* /* display */, 220 Colormap /* colormap */, 221 Pixel* /* pixels */, 222 int /* npixels */, 223 void* /* closure */ 224 #endif 225 ); 226 227 typedef struct { 228 unsigned long valuemask; /* Specifies which attributes are 229 defined */ 230 231 Visual *visual; /* Specifies the visual to use */ 232 Colormap colormap; /* Specifies the colormap to use */ 233 unsigned int depth; /* Specifies the depth */ 234 unsigned int width; /* Returns the width of the created 235 pixmap */ 236 unsigned int height; /* Returns the height of the created 237 pixmap */ 238 unsigned int x_hotspot; /* Returns the x hotspot's 239 coordinate */ 240 unsigned int y_hotspot; /* Returns the y hotspot's 241 coordinate */ 242 unsigned int cpp; /* Specifies the number of char per 243 pixel */ 244 Pixel *pixels; /* List of used color pixels */ 245 unsigned int npixels; /* Number of used pixels */ 246 XpmColorSymbol *colorsymbols; /* List of color symbols to override */ 247 unsigned int numsymbols; /* Number of symbols */ 248 char *rgb_fname; /* RGB text file name */ 249 unsigned int nextensions; /* Number of extensions */ 250 XpmExtension *extensions; /* List of extensions */ 251 252 unsigned int ncolors; /* Number of colors */ 253 XpmColor *colorTable; /* List of colors */ 254 /* 3.2 backward compatibility code */ 255 char *hints_cmt; /* Comment of the hints section */ 256 char *colors_cmt; /* Comment of the colors section */ 257 char *pixels_cmt; /* Comment of the pixels section */ 258 /* end 3.2 bc */ 259 unsigned int mask_pixel; /* Color table index of transparent 260 color */ 261 262 /* Color Allocation Directives */ 263 Bool exactColors; /* Only use exact colors for visual */ 264 unsigned int closeness; /* Allowable RGB deviation */ 265 unsigned int red_closeness; /* Allowable red deviation */ 266 unsigned int green_closeness; /* Allowable green deviation */ 267 unsigned int blue_closeness; /* Allowable blue deviation */ 268 int color_key; /* Use colors from this color set */ 269 270 Pixel *alloc_pixels; /* Returns the list of alloc'ed color 271 pixels */ 272 Bool nalloc_pixels; /* Returns the number of alloc'ed 273 color pixels */ 274 275 Bool alloc_close_colors; /* Specify whether close colors should 276 be allocated using XAllocColor 277 or not */ 278 int bitmap_format; /* Specify the format of 1bit depth 279 images: ZPixmap or XYBitmap */ 280 281 /* Color functions */ 282 XpmAllocColorFunc alloc_color; /* Application color allocator */ 283 XpmFreeColorsFunc free_colors; /* Application color de-allocator */ 284 void *color_closure; /* Application private data to pass to 285 alloc_color and free_colors */ 286 287 } XpmAttributes; 288 289 /* XpmAttributes value masks bits */ 290 #define XpmVisual (1L<<0) 291 #define XpmColormap (1L<<1) 292 #define XpmDepth (1L<<2) 293 #define XpmSize (1L<<3) /* width & height */ 294 #define XpmHotspot (1L<<4) /* x_hotspot & y_hotspot */ 295 #define XpmCharsPerPixel (1L<<5) 296 #define XpmColorSymbols (1L<<6) 297 #define XpmRgbFilename (1L<<7) 298 /* 3.2 backward compatibility code */ 299 #define XpmInfos (1L<<8) 300 #define XpmReturnInfos XpmInfos 301 /* end 3.2 bc */ 302 #define XpmReturnPixels (1L<<9) 303 #define XpmExtensions (1L<<10) 304 #define XpmReturnExtensions XpmExtensions 305 306 #define XpmExactColors (1L<<11) 307 #define XpmCloseness (1L<<12) 308 #define XpmRGBCloseness (1L<<13) 309 #define XpmColorKey (1L<<14) 310 311 #define XpmColorTable (1L<<15) 312 #define XpmReturnColorTable XpmColorTable 313 314 #define XpmReturnAllocPixels (1L<<16) 315 #define XpmAllocCloseColors (1L<<17) 316 #define XpmBitmapFormat (1L<<18) 317 318 #define XpmAllocColor (1L<<19) 319 #define XpmFreeColors (1L<<20) 320 #define XpmColorClosure (1L<<21) 321 322 323 /* XpmInfo value masks bits */ 324 #define XpmComments XpmInfos 325 #define XpmReturnComments XpmComments 326 327 /* XpmAttributes mask_pixel value when there is no mask */ 328 #ifndef FOR_MSW 329 #define XpmUndefPixel 0x80000000 330 #else 331 /* int is only 16 bit for MSW */ 332 #define XpmUndefPixel 0x8000 333 #endif 334 335 /* 336 * color keys for visual type, they must fit along with the number key of 337 * each related element in xpmColorKeys[] defined in XpmI.h 338 */ 339 #define XPM_MONO 2 340 #define XPM_GREY4 3 341 #define XPM_GRAY4 3 342 #define XPM_GREY 4 343 #define XPM_GRAY 4 344 #define XPM_COLOR 5 345 346 347 /* macros for forward declarations of functions with prototypes */ 348 #if NeedFunctionPrototypes 349 #define FUNC(f, t, p) extern t f p 350 #define LFUNC(f, t, p) static t f p 351 #else 352 #define FUNC(f, t, p) extern t f() 353 #define LFUNC(f, t, p) static t f() 354 #endif 355 356 357 /* 358 * functions declarations 359 */ 360 361 #ifdef __cplusplus 362 extern "C" { 363 #endif 364 365 /* FOR_MSW, all ..Pixmap.. are excluded, only the ..XImage.. are used */ 366 367 #ifndef FOR_MSW 368 FUNC(XpmCreatePixmapFromData, int, (Display *display, 369 Drawable d, 370 char **data, 371 Pixmap *pixmap_return, 372 Pixmap *shapemask_return, 373 XpmAttributes *attributes)); 374 375 FUNC(XpmCreateDataFromPixmap, int, (Display *display, 376 char ***data_return, 377 Pixmap pixmap, 378 Pixmap shapemask, 379 XpmAttributes *attributes)); 380 381 FUNC(XpmReadFileToPixmap, int, (Display *display, 382 Drawable d, 383 char *filename, 384 Pixmap *pixmap_return, 385 Pixmap *shapemask_return, 386 XpmAttributes *attributes)); 387 388 FUNC(XpmWriteFileFromPixmap, int, (Display *display, 389 char *filename, 390 Pixmap pixmap, 391 Pixmap shapemask, 392 XpmAttributes *attributes)); 393 #endif /* ndef FOR_MSW */ 394 395 FUNC(XpmCreateImageFromData, int, (Display *display, 396 char **data, 397 XImage **image_return, 398 XImage **shapemask_return, 399 XpmAttributes *attributes)); 400 401 FUNC(XpmCreateDataFromImage, int, (Display *display, 402 char ***data_return, 403 XImage *image, 404 XImage *shapeimage, 405 XpmAttributes *attributes)); 406 407 FUNC(XpmReadFileToImage, int, (Display *display, 408 char *filename, 409 XImage **image_return, 410 XImage **shapeimage_return, 411 XpmAttributes *attributes)); 412 413 FUNC(XpmWriteFileFromImage, int, (Display *display, 414 char *filename, 415 XImage *image, 416 XImage *shapeimage, 417 XpmAttributes *attributes)); 418 419 FUNC(XpmCreateImageFromBuffer, int, (Display *display, 420 char *buffer, 421 XImage **image_return, 422 XImage **shapemask_return, 423 XpmAttributes *attributes)); 424 #ifndef FOR_MSW 425 FUNC(XpmCreatePixmapFromBuffer, int, (Display *display, 426 Drawable d, 427 char *buffer, 428 Pixmap *pixmap_return, 429 Pixmap *shapemask_return, 430 XpmAttributes *attributes)); 431 432 FUNC(XpmCreateBufferFromImage, int, (Display *display, 433 char **buffer_return, 434 XImage *image, 435 XImage *shapeimage, 436 XpmAttributes *attributes)); 437 438 FUNC(XpmCreateBufferFromPixmap, int, (Display *display, 439 char **buffer_return, 440 Pixmap pixmap, 441 Pixmap shapemask, 442 XpmAttributes *attributes)); 443 #endif /* ndef FOR_MSW */ 444 FUNC(XpmReadFileToBuffer, int, (char *filename, char **buffer_return)); 445 FUNC(XpmWriteFileFromBuffer, int, (char *filename, char *buffer)); 446 447 FUNC(XpmReadFileToData, int, (char *filename, char ***data_return)); 448 FUNC(XpmWriteFileFromData, int, (char *filename, char **data)); 449 450 FUNC(XpmAttributesSize, int, ()); 451 FUNC(XpmFreeAttributes, void, (XpmAttributes *attributes)); 452 FUNC(XpmFreeExtensions, void, (XpmExtension *extensions, 453 int nextensions)); 454 455 FUNC(XpmFreeXpmImage, void, (XpmImage *image)); 456 FUNC(XpmFreeXpmInfo, void, (XpmInfo *info)); 457 FUNC(XpmGetErrorString, char *, (int errcode)); 458 FUNC(XpmLibraryVersion, int, ()); 459 460 /* XpmImage functions */ 461 FUNC(XpmReadFileToXpmImage, int, (char *filename, 462 XpmImage *image, 463 XpmInfo *info)); 464 465 FUNC(XpmWriteFileFromXpmImage, int, (char *filename, 466 XpmImage *image, 467 XpmInfo *info)); 468 #ifndef FOR_MSW 469 FUNC(XpmCreatePixmapFromXpmImage, int, (Display *display, 470 Drawable d, 471 XpmImage *image, 472 Pixmap *pixmap_return, 473 Pixmap *shapemask_return, 474 XpmAttributes *attributes)); 475 #endif 476 FUNC(XpmCreateImageFromXpmImage, int, (Display *display, 477 XpmImage *image, 478 XImage **image_return, 479 XImage **shapeimage_return, 480 XpmAttributes *attributes)); 481 482 FUNC(XpmCreateXpmImageFromImage, int, (Display *display, 483 XImage *image, 484 XImage *shapeimage, 485 XpmImage *xpmimage, 486 XpmAttributes *attributes)); 487 #ifndef FOR_MSW 488 FUNC(XpmCreateXpmImageFromPixmap, int, (Display *display, 489 Pixmap pixmap, 490 Pixmap shapemask, 491 XpmImage *xpmimage, 492 XpmAttributes *attributes)); 493 #endif 494 FUNC(XpmCreateDataFromXpmImage, int, (char ***data_return, 495 XpmImage *image, 496 XpmInfo *info)); 497 498 FUNC(XpmCreateXpmImageFromData, int, (char **data, 499 XpmImage *image, 500 XpmInfo *info)); 501 502 FUNC(XpmCreateXpmImageFromBuffer, int, (char *buffer, 503 XpmImage *image, 504 XpmInfo *info)); 505 506 FUNC(XpmCreateBufferFromXpmImage, int, (char **buffer_return, 507 XpmImage *image, 508 XpmInfo *info)); 509 510 FUNC(XpmFree, void, (void *ptr)); 511 512 #ifdef __cplusplus 513 } /* for C++ V2.0 */ 514 #endif 515 516 517 /* backward compatibility */ 518 519 /* for version 3.0c */ 520 #define XpmPixmapColorError XpmColorError 521 #define XpmPixmapSuccess XpmSuccess 522 #define XpmPixmapOpenFailed XpmOpenFailed 523 #define XpmPixmapFileInvalid XpmFileInvalid 524 #define XpmPixmapNoMemory XpmNoMemory 525 #define XpmPixmapColorFailed XpmColorFailed 526 527 #define XpmReadPixmapFile(dpy, d, file, pix, mask, att) \ 528 XpmReadFileToPixmap(dpy, d, file, pix, mask, att) 529 #define XpmWritePixmapFile(dpy, file, pix, mask, att) \ 530 XpmWriteFileFromPixmap(dpy, file, pix, mask, att) 531 532 /* for version 3.0b */ 533 #define PixmapColorError XpmColorError 534 #define PixmapSuccess XpmSuccess 535 #define PixmapOpenFailed XpmOpenFailed 536 #define PixmapFileInvalid XpmFileInvalid 537 #define PixmapNoMemory XpmNoMemory 538 #define PixmapColorFailed XpmColorFailed 539 540 #define ColorSymbol XpmColorSymbol 541 542 #define XReadPixmapFile(dpy, d, file, pix, mask, att) \ 543 XpmReadFileToPixmap(dpy, d, file, pix, mask, att) 544 #define XWritePixmapFile(dpy, file, pix, mask, att) \ 545 XpmWriteFileFromPixmap(dpy, file, pix, mask, att) 546 #define XCreatePixmapFromData(dpy, d, data, pix, mask, att) \ 547 XpmCreatePixmapFromData(dpy, d, data, pix, mask, att) 548 #define XCreateDataFromPixmap(dpy, data, pix, mask, att) \ 549 XpmCreateDataFromPixmap(dpy, data, pix, mask, att) 550 551 #endif /* XPM_NUMBERS */ 552 #endif 553 554 #endif /* _XpmP_h */ 555