Back to index

plt-scheme  4.2.1
simx.h
Go to the documentation of this file.
00001 /*
00002  * Copyright (C) 1989-95 GROUPE BULL
00003  *
00004  * Permission is hereby granted, free of charge, to any person obtaining a copy
00005  * of this software and associated documentation files (the "Software"), to
00006  * deal in the Software without restriction, including without limitation the
00007  * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
00008  * sell copies of the Software, and to permit persons to whom the Software is
00009  * furnished to do so, subject to the following conditions:
00010  *
00011  * The above copyright notice and this permission notice shall be included in
00012  * all copies or substantial portions of the Software.
00013  *
00014  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
00015  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
00016  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
00017  * GROUPE BULL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
00018  * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
00019  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
00020  *
00021  * Except as contained in this notice, the name of GROUPE BULL shall not be
00022  * used in advertising or otherwise to promote the sale, use or other dealings
00023  * in this Software without prior written authorization from GROUPE BULL.
00024  */
00025 
00026 /*****************************************************************************\
00027 * simx.h: 0.1a                                                                *
00028 *                                                                             *
00029 * This emulates some Xlib functionality for MSW. It's not a general solution, *
00030 * it is close related to XPM-lib. It is only intended to satisfy what is need *
00031 * there. Thus allowing to read XPM files under MS windows.                    *
00032 *                                                                             *
00033 * Developed by HeDu 3/94 (hedu@cul-ipn.uni-kiel.de)                           *
00034 \*****************************************************************************/
00035 
00036 
00037 #ifndef _SIMX_H
00038 #define _SIMX_H
00039 
00040 #ifdef FOR_MSW
00041 
00042 #include "windows.h"               /* MS windows GDI types */
00043 
00044 /*
00045  * minimal portability layer between ansi and KR C
00046  */
00047 /* this comes from xpm.h, and is here again, to avoid complicated
00048     includes, since this is included from xpm.h */
00049 /* these defines get undefed at the end of this file */
00050 #if __STDC__ || defined(__cplusplus) || defined(c_plusplus)
00051  /* ANSI || C++ */
00052 #define FUNC(f, t, p) extern t f p
00053 #define LFUNC(f, t, p) static t f p
00054 #else /* k&R */
00055 #define FUNC(f, t, p) extern t f()
00056 #define LFUNC(f, t, p) static t f()
00057 #endif
00058 
00059 
00060 FUNC(boundCheckingMalloc, void *, (long s));
00061 FUNC(boundCheckingCalloc, void *, (long num, long s));
00062 FUNC(boundCheckingRealloc, void *, (void *p, long s));
00063 
00064 /* define MSW types for X window types,
00065    I don't know much about MSW, but the following defines do the job */
00066 
00067 typedef HDC Display;               /* this should be similar */
00068 typedef void *Screen;                     /* not used */
00069 typedef void *Visual;                     /* not used yet, is for GRAY, COLOR,
00070                                     * MONO */
00071 
00072 typedef void *Colormap;                   /* should be COLORPALETTE, not done
00073                                     * yet */
00074 
00075 typedef COLORREF Pixel;
00076 
00077 #define PIXEL_ALREADY_TYPEDEFED           /* to let xpm.h know about it */
00078 
00079 typedef struct {
00080     Pixel pixel;
00081     BYTE red, green, blue;
00082 }      XColor;
00083 
00084 typedef struct {
00085     HBITMAP bitmap;
00086     unsigned int width;
00087     unsigned int height;
00088     unsigned int depth;
00089 }      XImage;
00090 
00091 #if defined(__cplusplus) || defined(c_plusplus)
00092 extern "C" {
00093 #endif
00094 /* some replacements for X... functions */
00095 
00096 /* XDefaultXXX */
00097     FUNC(XDefaultVisual, Visual *, (Display *display, Screen *screen));
00098     FUNC(XDefaultScreen, Screen *, (Display *d));
00099     FUNC(XDefaultColormap, Colormap *, (Display *display, Screen *screen));
00100     FUNC(XDefaultDepth, int, (Display *d, Screen *s));
00101 
00102 /* color related */
00103     FUNC(XParseColor, int, (Display *, Colormap *, char *, XColor *));
00104     FUNC(XAllocColor, int, (Display *, Colormap *, XColor *));
00105     FUNC(XQueryColors, void, (Display *display, Colormap *colormap,
00106                            XColor *xcolors, int ncolors));
00107     FUNC(XFreeColors, int, (Display *d, Colormap cmap,
00108                          unsigned long pixels[],
00109                          int npixels, unsigned long planes));
00110 /* XImage */
00111     FUNC(XCreateImage, XImage *, (Display *, Visual *, int depth, int format,
00112                               int x, int y, int width, int height,
00113                               int pad, int foo));
00114 
00115 /* free and destroy bitmap */
00116     FUNC(XDestroyImage, void /* ? */ , (XImage *));
00117 /* free only, bitmap remains */
00118     FUNC(XImageFree, void, (XImage *));
00119 #if defined(__cplusplus) || defined(c_plusplus)
00120 } /* end of extern "C" */
00121 #endif /* cplusplus */
00122 
00123 #define ZPixmap 1                  /* not really used */
00124 
00125 #ifndef True
00126 #define True 1
00127 #define False 0
00128 #endif
00129 #ifndef Bool
00130 typedef BOOL Bool;          /* take MSW bool */
00131 #endif
00132 /* make these local here, simx.c gets the same from xpm.h */
00133 #undef LFUNC
00134 #undef FUNC
00135 
00136 #endif /* def FOR_MSW */
00137 
00138 #endif /* _SIMX_H */