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 * simx.h: 0.1a * 28 * * 29 * This emulates some Xlib functionality for MSW. It's not a general solution, * 30 * it is close related to XPM-lib. It is only intended to satisfy what is need * 31 * there. Thus allowing to read XPM files under MS windows. * 32 * * 33 * Developed by HeDu 3/94 (hedu@cul-ipn.uni-kiel.de) * 34 \*****************************************************************************/ 35 36 37 #ifndef _SIMX_H 38 #define _SIMX_H 39 40 #ifdef FOR_MSW 41 42 #include "windows.h" /* MS windows GDI types */ 43 #define _XFUNCPROTOBEGIN 44 #define _XFUNCPROTOEND 45 #define NO_ZPIPE 46 47 /* 48 * minimal portability layer between ansi and KR C 49 */ 50 /* this comes from xpm.h, and is here again, to avoid complicated 51 includes, since this is included from xpm.h */ 52 /* these defines get undefed at the end of this file */ 53 #if __STDC__ || defined(__cplusplus) || defined(c_plusplus) 54 /* ANSI || C++ */ 55 #define FUNC(f, t, p) extern t f p 56 #define LFUNC(f, t, p) static t f p 57 #else /* k&R */ 58 #define FUNC(f, t, p) extern t f() 59 #define LFUNC(f, t, p) static t f() 60 #endif 61 62 63 FUNC(boundCheckingMalloc, void *, (long s)); 64 FUNC(boundCheckingCalloc, void *, (long num, long s)); 65 FUNC(boundCheckingRealloc, void *, (void *p, long s)); 66 67 /* define MSW types for X window types, 68 I don't know much about MSW, but the following defines do the job */ 69 70 typedef HDC Display; /* this should be similar */ 71 typedef void *Screen; /* not used */ 72 typedef void *Visual; /* not used yet, is for GRAY, COLOR, 73 * MONO */ 74 75 typedef void *Colormap; /* should be COLORPALETTE, not done 76 * yet */ 77 78 typedef COLORREF Pixel; 79 80 #define PIXEL_ALREADY_TYPEDEFED /* to let xpm.h know about it */ 81 82 typedef struct { 83 Pixel pixel; 84 BYTE red, green, blue; 85 } XColor; 86 87 typedef struct { 88 HBITMAP bitmap; 89 unsigned int width; 90 unsigned int height; 91 unsigned int depth; 92 } XImage; 93 94 #if defined(__cplusplus) || defined(c_plusplus) 95 extern "C" { 96 #endif 97 /* some replacements for X... functions */ 98 99 /* XDefaultXXX */ 100 FUNC(XDefaultVisual, Visual *, (Display *display, Screen *screen)); 101 FUNC(XDefaultScreen, Screen *, (Display *d)); 102 FUNC(XDefaultColormap, Colormap *, (Display *display, Screen *screen)); 103 FUNC(XDefaultDepth, int, (Display *d, Screen *s)); 104 105 /* color related */ 106 FUNC(XParseColor, int, (Display *, Colormap *, char *, XColor *)); 107 FUNC(XAllocColor, int, (Display *, Colormap, XColor *)); 108 FUNC(XQueryColors, void, (Display *display, Colormap *colormap, 109 XColor *xcolors, int ncolors)); 110 FUNC(XFreeColors, int, (Display *d, Colormap cmap, 111 unsigned long pixels[], 112 int npixels, unsigned long planes)); 113 /* XImage */ 114 FUNC(XCreateImage, XImage *, (Display *, Visual *, int depth, int format, 115 int x, int y, int width, int height, 116 int pad, int foo)); 117 118 /* free and destroy bitmap */ 119 FUNC(XDestroyImage, void /* ? */ , (XImage *)); 120 /* free only, bitmap remains */ 121 FUNC(XImageFree, void, (XImage *)); 122 #if defined(__cplusplus) || defined(c_plusplus) 123 } /* end of extern "C" */ 124 #endif /* cplusplus */ 125 126 #define ZPixmap 1 /* not really used */ 127 #define XYBitmap 1 /* not really used */ 128 129 #ifndef True 130 #define True 1 131 #define False 0 132 #endif 133 #ifndef Bool 134 typedef BOOL Bool; /* take MSW bool */ 135 #endif 136 /* make these local here, simx.c gets the same from xpm.h */ 137 #undef LFUNC 138 #undef FUNC 139 140 /* Some functions and constants that have non-standard names in the 141 MS library. */ 142 #define bzero(addr,sz) memset(addr, 0, sz) 143 #define close _close 144 #define fdopen _fdopen 145 #define index strchr 146 #define open _open 147 #define O_RDONLY _O_RDONLY 148 #define rindex strrchr 149 #define strdup _strdup 150 151 152 #endif /* def FOR_MSW */ 153 154 #endif /* _SIMX_H */ 155