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