]> git.saurik.com Git - wxWidgets.git/blob - src/xpm/simx.h
gtk 1.2.8 compilation fix
[wxWidgets.git] / src / xpm / simx.h
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 #if !defined(__OS2__)
43 #include "windows.h" /* MS windows GDI types */
44 #else
45 #define INCL_PM
46 #define INCL_GPI
47 #include<os2.h>
48 typedef unsigned long COLORREF;
49 // RGB under OS2 is more like a PALETTEENTRY struct under Windows so we need a real RGB def
50 //#define OS2RGB(r,g,b) ((ULONG ((BYTE) (r) | ((UINT) (g) << 8)) | (((ULONG)(BYTE)(b)) << 16)))
51 #define OS2RGB(r,g,b) ((unsigned long)r<<16|(unsigned long)g<<8|(unsigned long)b)
52
53 #define GetBValue(rgb) ((BYTE)((rgb) >> 16))
54 #define GetGValue(rgb) ((BYTE)(((WORD)(rgb)) >> 8))
55 #define GetRValue(rgb) ((BYTE)(rgb))
56 typedef UINT WORD;
57 #endif
58
59
60 /*
61 * minimal portability layer between ansi and KR C
62 */
63 /* this comes from xpm.h, and is here again, to avoid complicated
64 includes, since this is included from xpm.h */
65 /* these defines get undefed at the end of this file */
66 #if __STDC__ || defined(__cplusplus) || defined(c_plusplus)
67 /* ANSI || C++ */
68 # define FUNC(f, t, p) extern t f p
69 # define LFUNC(f, t, p) static t f p
70 #else /* k&R */
71 # define FUNC(f, t, p) extern t f()
72 # define LFUNC(f, t, p) static t f()
73 #endif
74
75
76 FUNC(boundCheckingMalloc, void *, (long s));
77 FUNC(boundCheckingCalloc, void *, (long num, long s));
78 FUNC(boundCheckingRealloc, void *, (void *p, long s));
79
80 /* define MSW types for X window types,
81 I don't know much about MSW, but the following defines do the job */
82
83 typedef HDC Display; /* this should be similar */
84 typedef void *Screen; /* not used */
85 typedef void *Visual; /* not used yet, is for GRAY, COLOR,
86 * MONO */
87
88 typedef void *Colormap; /* should be COLORPALETTE, not done
89 * yet */
90
91 typedef COLORREF Pixel;
92
93 #define PIXEL_ALREADY_TYPEDEFED /* to let xpm.h know about it */
94
95 typedef struct {
96 Pixel pixel;
97 BYTE red, green, blue;
98 } XColor;
99
100 typedef struct {
101 HBITMAP bitmap;
102 unsigned int width;
103 unsigned int height;
104 unsigned int depth;
105 } XImage;
106
107 #if defined(__cplusplus) || defined(c_plusplus)
108 extern "C" {
109 #endif
110 /* some replacements for X... functions */
111
112 /* XDefaultXXX */
113 FUNC(XDefaultVisual, Visual *, (Display *display, Screen *screen));
114 FUNC(XDefaultScreen, Screen *, (Display *d));
115 FUNC(XDefaultColormap, Colormap *, (Display *display, Screen *screen));
116 FUNC(XDefaultDepth, int, (Display *d, Screen *s));
117
118 /* color related */
119 FUNC(XParseColor, int, (Display *, Colormap *, char *, XColor *));
120 FUNC(XAllocColor, int, (Display *, Colormap *, XColor *));
121 FUNC(XQueryColors, void, (Display *display, Colormap *colormap,
122 XColor *xcolors, int ncolors));
123 FUNC(XFreeColors, int, (Display *d, Colormap cmap,
124 unsigned long pixels[],
125 int npixels, unsigned long planes));
126 /* XImage */
127 FUNC(XCreateImage, XImage *, (Display *, Visual *, int depth, int format,
128 int x, int y, int width, int height,
129 int pad, int foo));
130
131 /* free and destroy bitmap */
132 FUNC(XDestroyImage, void /* ? */ , (XImage *));
133 /* free only, bitmap remains */
134 FUNC(XImageFree, void, (XImage *));
135 #if defined(__cplusplus) || defined(c_plusplus)
136 } /* end of extern "C" */
137 #endif /* cplusplus */
138
139 #define ZPixmap 1 /* not really used */
140 #define XYBitmap 1 /* not really used */
141
142 #ifndef True
143 #define True 1
144 #define False 0
145 #endif
146 #ifndef Bool
147 typedef BOOL Bool; /* take MSW bool */
148 #endif
149 /* make these local here, simx.c gets the same from xpm.h */
150 #undef LFUNC
151 #undef FUNC
152
153 #endif /* def FOR_MSW */
154
155 #endif /* _SIMX_H */