1a966c04fSmrg/*
2a966c04fSmrg * Copyright (C) 1989-95 GROUPE BULL
3a966c04fSmrg *
4a966c04fSmrg * Permission is hereby granted, free of charge, to any person obtaining a copy
5a966c04fSmrg * of this software and associated documentation files (the "Software"), to
6a966c04fSmrg * deal in the Software without restriction, including without limitation the
7a966c04fSmrg * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
8a966c04fSmrg * sell copies of the Software, and to permit persons to whom the Software is
9a966c04fSmrg * furnished to do so, subject to the following conditions:
10a966c04fSmrg *
11a966c04fSmrg * The above copyright notice and this permission notice shall be included in
12a966c04fSmrg * all copies or substantial portions of the Software.
13a966c04fSmrg *
14a966c04fSmrg * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15a966c04fSmrg * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16a966c04fSmrg * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17a966c04fSmrg * GROUPE BULL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
18a966c04fSmrg * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
19a966c04fSmrg * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
20a966c04fSmrg *
21a966c04fSmrg * Except as contained in this notice, the name of GROUPE BULL shall not be
22a966c04fSmrg * used in advertising or otherwise to promote the sale, use or other dealings
23a966c04fSmrg * in this Software without prior written authorization from GROUPE BULL.
24a966c04fSmrg */
25a966c04fSmrg
26a966c04fSmrg/*****************************************************************************\
27a966c04fSmrg* simx.h: 0.1a                                                                *
28a966c04fSmrg*                                                                             *
29a966c04fSmrg* This emulates some Xlib functionality for MSW. It's not a general solution, *
30a966c04fSmrg* it is close related to XPM-lib. It is only intended to satisfy what is need *
31a966c04fSmrg* there. Thus allowing to read XPM files under MS windows.                    *
32a966c04fSmrg*                                                                             *
33a966c04fSmrg* Developed by HeDu 3/94 (hedu@cul-ipn.uni-kiel.de)                           *
34a966c04fSmrg\*****************************************************************************/
35a966c04fSmrg
36a966c04fSmrg
37a966c04fSmrg#ifndef _SIMX_H
38a966c04fSmrg#define _SIMX_H
39a966c04fSmrg
40a966c04fSmrg#ifdef FOR_MSW
41a966c04fSmrg
42a966c04fSmrg#include "windows.h"			/* MS windows GDI types */
43a966c04fSmrg#define _XFUNCPROTOBEGIN
44a966c04fSmrg#define _XFUNCPROTOEND
45a966c04fSmrg#define NO_ZPIPE
46a966c04fSmrg
47a966c04fSmrg/*
48a966c04fSmrg * minimal portability layer between ansi and KR C
49a966c04fSmrg */
50a966c04fSmrg/* this comes from xpm.h, and is here again, to avoid complicated
51a966c04fSmrg    includes, since this is included from xpm.h */
52a966c04fSmrg/* these defines get undefed at the end of this file */
53a966c04fSmrg#if __STDC__ || defined(__cplusplus) || defined(c_plusplus)
54a966c04fSmrg /* ANSI || C++ */
55a966c04fSmrg#define FUNC(f, t, p) extern t f p
56a966c04fSmrg#define LFUNC(f, t, p) static t f p
57a966c04fSmrg#else /* k&R */
58a966c04fSmrg#define FUNC(f, t, p) extern t f()
59a966c04fSmrg#define LFUNC(f, t, p) static t f()
60a966c04fSmrg#endif
61a966c04fSmrg
62a966c04fSmrg
63a966c04fSmrgFUNC(boundCheckingMalloc, void *, (long s));
64a966c04fSmrgFUNC(boundCheckingCalloc, void *, (long num, long s));
65a966c04fSmrgFUNC(boundCheckingRealloc, void *, (void *p, long s));
66a966c04fSmrg
67a966c04fSmrg/* define MSW types for X window types,
68a966c04fSmrg   I don't know much about MSW, but the following defines do the job */
69a966c04fSmrg
70a966c04fSmrgtypedef HDC Display;			/* this should be similar */
71a966c04fSmrgtypedef void *Screen;			/* not used */
72a966c04fSmrgtypedef void *Visual;			/* not used yet, is for GRAY, COLOR,
73a966c04fSmrg					 * MONO */
74a966c04fSmrg
75a966c04fSmrgtypedef void *Colormap;			/* should be COLORPALETTE, not done
76a966c04fSmrg					 * yet */
77a966c04fSmrg
78a966c04fSmrgtypedef COLORREF Pixel;
79a966c04fSmrg
80a966c04fSmrg#define PIXEL_ALREADY_TYPEDEFED		/* to let xpm.h know about it */
81a966c04fSmrg
82a966c04fSmrgtypedef struct {
83a966c04fSmrg    Pixel pixel;
84a966c04fSmrg    BYTE red, green, blue;
85a966c04fSmrg}      XColor;
86a966c04fSmrg
87a966c04fSmrgtypedef struct {
88a966c04fSmrg    HBITMAP bitmap;
89a966c04fSmrg    unsigned int width;
90a966c04fSmrg    unsigned int height;
91a966c04fSmrg    unsigned int depth;
92a966c04fSmrg}      XImage;
93a966c04fSmrg
94a966c04fSmrg#if defined(__cplusplus) || defined(c_plusplus)
95a966c04fSmrgextern "C" {
96a966c04fSmrg#endif
97a966c04fSmrg/* some replacements for X... functions */
98a966c04fSmrg
99a966c04fSmrg/* XDefaultXXX */
100a966c04fSmrg    FUNC(XDefaultVisual, Visual *, (Display *display, Screen *screen));
101a966c04fSmrg    FUNC(XDefaultScreen, Screen *, (Display *d));
102a966c04fSmrg    FUNC(XDefaultColormap, Colormap *, (Display *display, Screen *screen));
103a966c04fSmrg    FUNC(XDefaultDepth, int, (Display *d, Screen *s));
104a966c04fSmrg
105a966c04fSmrg/* color related */
106a966c04fSmrg    FUNC(XParseColor, int, (Display *, Colormap *, char *, XColor *));
107a966c04fSmrg    FUNC(XAllocColor, int, (Display *, Colormap, XColor *));
108a966c04fSmrg    FUNC(XQueryColors, void, (Display *display, Colormap *colormap,
109a966c04fSmrg			      XColor *xcolors, int ncolors));
110a966c04fSmrg    FUNC(XFreeColors, int, (Display *d, Colormap cmap,
111a966c04fSmrg			    unsigned long pixels[],
112a966c04fSmrg			    int npixels, unsigned long planes));
113a966c04fSmrg/* XImage */
114a966c04fSmrg    FUNC(XCreateImage, XImage *, (Display *, Visual *, int depth, int format,
115a966c04fSmrg				  int x, int y, int width, int height,
116a966c04fSmrg				  int pad, int foo));
117a966c04fSmrg
118a966c04fSmrg/* free and destroy bitmap */
119a966c04fSmrg    FUNC(XDestroyImage, void /* ? */ , (XImage *));
120a966c04fSmrg/* free only, bitmap remains */
121a966c04fSmrg    FUNC(XImageFree, void, (XImage *));
122a966c04fSmrg#if defined(__cplusplus) || defined(c_plusplus)
123a966c04fSmrg} /* end of extern "C" */
124a966c04fSmrg#endif /* cplusplus */
125a966c04fSmrg
126a966c04fSmrg#define ZPixmap 1			/* not really used */
127a966c04fSmrg#define XYBitmap 1			/* not really used */
128a966c04fSmrg
129a966c04fSmrg#ifndef True
130a966c04fSmrg#define True 1
131a966c04fSmrg#define False 0
132a966c04fSmrg#endif
133a966c04fSmrg#ifndef Bool
134a966c04fSmrgtypedef BOOL Bool;		/* take MSW bool */
135a966c04fSmrg#endif
136a966c04fSmrg/* make these local here, simx.c gets the same from xpm.h */
137a966c04fSmrg#undef LFUNC
138a966c04fSmrg#undef FUNC
139a966c04fSmrg
140a966c04fSmrg/* Some functions and constants that have non-standard names in the
141a966c04fSmrg   MS library.  */
142a966c04fSmrg#define bzero(addr,sz) memset(addr, 0, sz)
143a966c04fSmrg#define close _close
144a966c04fSmrg#define fdopen _fdopen
145a966c04fSmrg#define index strchr
146a966c04fSmrg#define open _open
147a966c04fSmrg#define O_RDONLY _O_RDONLY
148a966c04fSmrg#define rindex strrchr
149a966c04fSmrg#define strdup _strdup
150a966c04fSmrg
151a966c04fSmrg
152a966c04fSmrg#endif /* def FOR_MSW */
153a966c04fSmrg
154a966c04fSmrg#endif /* _SIMX_H */
155