| 1 | /* |
| 2 | * tixImgXpm.h -- |
| 3 | * |
| 4 | * Generic header file for the pixmap image type. This is NOT a public |
| 5 | * header file! |
| 6 | * |
| 7 | * Copyright (c) 1996, Expert Interface Technologies |
| 8 | * |
| 9 | * See the file "license.terms" for information on usage and redistribution |
| 10 | * of this file, and for a DISCLAIMER OF ALL WARRANTIES. |
| 11 | * |
| 12 | */ |
| 13 | |
| 14 | #ifndef _TIX_IMG_XPM_H_ |
| 15 | #define _TIX_IMG_XPM_H_ |
| 16 | #define _TIXIMGXPM |
| 17 | /* |
| 18 | * Constants |
| 19 | */ |
| 20 | |
| 21 | #define XPM_MONO 1 |
| 22 | #define XPM_GRAY_4 2 |
| 23 | #define XPM_GRAY 3 |
| 24 | #define XPM_COLOR 4 |
| 25 | #define XPM_SYMBOLIC 5 |
| 26 | #define XPM_UNKNOWN 6 |
| 27 | |
| 28 | /* |
| 29 | * The following data structure represents the master for a pixmap |
| 30 | * image: |
| 31 | */ |
| 32 | |
| 33 | typedef struct PixmapMaster { |
| 34 | Tk_ImageMaster tkMaster; /* Tk's token for image master. NULL means |
| 35 | * the image is being deleted. */ |
| 36 | Tcl_Interp *interp; /* Interpreter for application that is |
| 37 | * using image. */ |
| 38 | Tcl_Command imageCmd; /* Token for image command (used to delete |
| 39 | * it when the image goes away). NULL means |
| 40 | * the image command has already been |
| 41 | * deleted. */ |
| 42 | char *fileString; /* Value of -file option (malloc'ed). |
| 43 | * valid only if the -file option is specified |
| 44 | */ |
| 45 | char *dataString; /* Value of -data option (malloc'ed). |
| 46 | * valid only if the -data option is specified |
| 47 | */ |
| 48 | Tk_Uid id; /* ID's for XPM data already compiled |
| 49 | * into the tixwish binary */ |
| 50 | int size[2]; /* width and height */ |
| 51 | int ncolors; /* number of colors */ |
| 52 | int cpp; /* characters per pixel */ |
| 53 | char ** data; /* The data that defines this pixmap |
| 54 | * image (array of strings). It is |
| 55 | * converted into an X Pixmap when this |
| 56 | * image is instanciated |
| 57 | */ |
| 58 | int isDataAlloced; /* False iff the data is got from |
| 59 | * the -id switch */ |
| 60 | /* First in list of all instances associated |
| 61 | * with this master. */ |
| 62 | struct PixmapInstance *instancePtr; |
| 63 | } PixmapMaster; |
| 64 | |
| 65 | typedef struct ColorStruct { |
| 66 | char c; /* This is used if CPP is one */ |
| 67 | char * cstring; /* This is used if CPP is bigger than one */ |
| 68 | XColor * colorPtr; |
| 69 | } ColorStruct; |
| 70 | |
| 71 | /*---------------------------------------------------------------------- |
| 72 | * PixmapInstance -- |
| 73 | * |
| 74 | * Represents all of the instances of an image that lie within a |
| 75 | * particular window: |
| 76 | * |
| 77 | * %% ToDo |
| 78 | * Currently one instance is created for each window that uses |
| 79 | * this pixmap. This is usually OK because pixmaps are usually |
| 80 | * not shared or only shared by a small number of windows. To |
| 81 | * improve resource allocation, we can create an instance for |
| 82 | * each (Display x Visual x Depth) combo. This will usually |
| 83 | * reduce the number of instances to one. |
| 84 | *---------------------------------------------------------------------- |
| 85 | */ |
| 86 | typedef struct PixmapInstance { |
| 87 | int refCount; /* Number of instances that share this |
| 88 | * data structure. */ |
| 89 | PixmapMaster *masterPtr; /* Pointer to master for image. */ |
| 90 | Tk_Window tkwin; /* Window in which the instances will be |
| 91 | * displayed. */ |
| 92 | Pixmap pixmap; /* The pixmap to display. */ |
| 93 | struct PixmapInstance *nextPtr; |
| 94 | /* Next in list of all instance structures |
| 95 | * associated with masterPtr (NULL means |
| 96 | * end of list). |
| 97 | */ |
| 98 | ColorStruct * colors; |
| 99 | ClientData clientData; /* Place holder for platform specific |
| 100 | * instance data */ |
| 101 | } PixmapInstance; |
| 102 | |
| 103 | |
| 104 | EXTERN void TixpInitPixmapInstance _ANSI_ARGS_(( |
| 105 | PixmapMaster *masterPtr, |
| 106 | PixmapInstance *instancePtr)); |
| 107 | EXTERN void TixpXpmAllocTmpBuffer _ANSI_ARGS_(( |
| 108 | PixmapMaster * masterPtr, |
| 109 | PixmapInstance * instancePtr, |
| 110 | XImage ** imagePtr, XImage ** maskPtr)); |
| 111 | EXTERN void TixpXpmFreeTmpBuffer _ANSI_ARGS_(( |
| 112 | PixmapMaster * masterPtr, |
| 113 | PixmapInstance * instancePtr, |
| 114 | XImage * image, XImage * mask)); |
| 115 | EXTERN void TixpXpmSetPixel _ANSI_ARGS_(( |
| 116 | PixmapInstance * instancePtr, XImage * image, |
| 117 | XImage * mask, int x, int y, XColor * colorPtr, |
| 118 | int * isTranspPtr)); |
| 119 | EXTERN void TixpXpmRealizePixmap _ANSI_ARGS_(( |
| 120 | PixmapMaster * masterPtr, |
| 121 | PixmapInstance * instancePtr, |
| 122 | XImage * image, XImage * mask, int isTransp)); |
| 123 | EXTERN void TixpXpmFreeInstanceData _ANSI_ARGS_(( |
| 124 | PixmapInstance *instancePtr, int delete, |
| 125 | Display *display)); |
| 126 | EXTERN void TixpXpmDisplay _ANSI_ARGS_((ClientData clientData, |
| 127 | Display *display, Drawable drawable, |
| 128 | int imageX, int imageY, int width, int height, |
| 129 | int drawableX, int drawableY)); |
| 130 | |
| 131 | #endif |