]> git.saurik.com Git - wxWidgets.git/blame - src/mac/xpm/XpmI.h
Use system default font for all platforms
[wxWidgets.git] / src / mac / xpm / XpmI.h
CommitLineData
0240e8b1
SC
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* XpmI.h: *
28* *
29* XPM library *
30* Internal Include file *
31* *
32* ** Everything defined here is subject to changes any time. ** *
33* *
34* Developed by Arnaud Le Hors *
35\*****************************************************************************/
36
37/*
38 * The code related to FOR_MSW has been added by
39 * HeDu (hedu@cul-ipn.uni-kiel.de) 4/94
40 */
41
42#ifndef XPMI_h
43#define XPMI_h
44
45#include "xpm.h"
46
47#ifdef macintosh
48 #undef index
49 #undef rindex
50 #undef bzero
51 #undef bcopy
52#endif
53
54/*
55 * lets try to solve include files
56 */
57
58#include <stdio.h>
59#include <stdlib.h>
60/* stdio.h doesn't declare popen on a Sequent DYNIX OS */
61#ifdef sequent
62extern FILE *popen();
63#endif
64
65#if defined(SYSV) || defined(SVR4) || defined(VMS) || defined(WIN32) || defined( macintosh )
66#include <string.h>
67
68#ifndef index
69#define index strchr
70#endif
71
72#ifndef rindex
73#define rindex strrchr
74#endif
75
76#else /* defined(SYSV) || defined(SVR4) || defined(VMS) */
77#include <strings.h>
78#endif
79
80
81
82#if defined(SYSV) || defined(SVR4) || defined(VMS) || defined(WIN32) || defined( macintosh )
83#ifndef bcopy
84#define bcopy(source, dest, count) memcpy(dest, source, count)
85#endif
86#ifndef bzero
87#define bzero(b, len) memset(b, 0, len)
88#endif
89#endif
90
91/* the following is defined in X11R6 but not in previous versions */
92#ifdef __alpha
93#ifndef LONG64
94#define LONG64
95#endif
96#endif
97
98#ifdef VMS
99#include <unixio.h>
100#include <file.h>
101#endif
102
103/* The following should help people wanting to use their own memory allocation
104 * functions. To avoid the overhead of a function call when the standard
105 * functions are used these are all macros, even the XpmFree function which
106 * needs to be a real function for the outside world though.
107 * So if change these be sure to change the XpmFree function in misc.c
108 * accordingly.
109 */
110#define XpmFree(ptr) free(ptr)
111
112#ifndef FOR_MSW
113#define XpmMalloc(size) malloc((size))
114#define XpmRealloc(ptr, size) realloc((ptr), (size))
115#define XpmCalloc(nelem, elsize) calloc((nelem), (elsize))
116#else
117/* checks for mallocs bigger than 64K */
118#define XpmMalloc(size) boundCheckingMalloc((long)(size))/* in simx.[ch] */
119#define XpmRealloc(ptr, size) boundCheckingRealloc((ptr),(long)(size))
120#define XpmCalloc(nelem, elsize) \
121 boundCheckingCalloc((long)(nelem),(long) (elsize))
122#endif
123
124#define XPMMAXCMTLEN BUFSIZ
125typedef struct {
126 unsigned int type;
127 union {
128 FILE *file;
129 char **data;
130 } stream;
131 char *cptr;
132 unsigned int line;
133 int CommentLength;
134 char Comment[XPMMAXCMTLEN];
135 char *Bcmt, *Ecmt, Bos, Eos;
136 int format; /* 1 if XPM1, 0 otherwise */
137#ifdef CXPMPROG
138 int lineNum;
139 int charNum;
140#endif
141} xpmData;
142
143#define XPMARRAY 0
144#define XPMFILE 1
145#define XPMPIPE 2
146#define XPMBUFFER 3
147
148#define EOL '\n'
149#define TAB '\t'
150#define SPC ' '
151
152typedef struct {
153 char *type; /* key word */
154 char *Bcmt; /* string beginning comments */
155 char *Ecmt; /* string ending comments */
156 char Bos; /* character beginning strings */
157 char Eos; /* character ending strings */
158 char *Strs; /* strings separator */
159 char *Dec; /* data declaration string */
160 char *Boa; /* string beginning assignment */
161 char *Eoa; /* string ending assignment */
162} xpmDataType;
163
164extern xpmDataType xpmDataTypes[];
165
166/*
167 * rgb values and ascii names (from rgb text file) rgb values,
168 * range of 0 -> 65535 color mnemonic of rgb value
169 */
170typedef struct {
171 int r, g, b;
172 char *name;
173} xpmRgbName;
174
175/* Maximum number of rgb mnemonics allowed in rgb text file. */
176#define MAX_RGBNAMES 1024
177
178extern char *xpmColorKeys[];
179
180#define TRANSPARENT_COLOR "None" /* this must be a string! */
181
182/* number of xpmColorKeys */
183#define NKEYS 5
184
185/* XPM internal routines */
186
187FUNC(xpmParseData, int, (xpmData *data, XpmImage *image, XpmInfo *info));
188FUNC(xpmParseDataAndCreate, int, (Display *display, xpmData *data,
189 XImage **image_return,
190 XImage **shapeimage_return,
191 XpmImage *image, XpmInfo *info,
192 XpmAttributes *attributes));
193
194FUNC(xpmFreeColorTable, void, (XpmColor *colorTable, int ncolors));
195
196FUNC(xpmInitAttributes, void, (XpmAttributes *attributes));
197
198FUNC(xpmInitXpmImage, void, (XpmImage *image));
199
200FUNC(xpmInitXpmInfo, void, (XpmInfo *info));
201
202FUNC(xpmSetInfoMask, void, (XpmInfo *info, XpmAttributes *attributes));
203FUNC(xpmSetInfo, void, (XpmInfo *info, XpmAttributes *attributes));
204FUNC(xpmSetAttributes, void, (XpmAttributes *attributes, XpmImage *image,
205 XpmInfo *info));
206
207/* structures and functions related to hastable code */
208
209typedef struct _xpmHashAtom {
210 char *name;
211 void *data;
212} *xpmHashAtom;
213
214typedef struct {
215 int size;
216 int limit;
217 int used;
218 xpmHashAtom *atomTable;
219} xpmHashTable;
220
221FUNC(xpmHashTableInit, int, (xpmHashTable *table));
222FUNC(xpmHashTableFree, void, (xpmHashTable *table));
223FUNC(xpmHashSlot, xpmHashAtom *, (xpmHashTable *table, char *s));
224FUNC(xpmHashIntern, int, (xpmHashTable *table, char *tag, void *data));
225
226#define HashAtomData(i) ((void *)i)
227#define HashColorIndex(slot) ((unsigned int)((*slot)->data))
228#define USE_HASHTABLE (cpp > 2 && ncolors > 4)
229
230/* I/O utility */
231
232FUNC(xpmNextString, int, (xpmData *mdata));
233FUNC(xpmNextUI, int, (xpmData *mdata, unsigned int *ui_return));
234FUNC(xpmGetString, int, (xpmData *mdata, char **sptr, unsigned int *l));
235
236#define xpmGetC(mdata) \
237 ((!mdata->type || mdata->type == XPMBUFFER) ? \
238 (*mdata->cptr++) : (getc(mdata->stream.file)))
239
240FUNC(xpmNextWord, unsigned int,
241 (xpmData *mdata, char *buf, unsigned int buflen));
242FUNC(xpmGetCmt, int, (xpmData *mdata, char **cmt));
243FUNC(xpmParseHeader, int, (xpmData *mdata));
244FUNC(xpmParseValues, int, (xpmData *data, unsigned int *width,
245 unsigned int *height, unsigned int *ncolors,
246 unsigned int *cpp, unsigned int *x_hotspot,
247 unsigned int *y_hotspot, unsigned int *hotspot,
248 unsigned int *extensions));
249
250FUNC(xpmParseColors, int, (xpmData *data, unsigned int ncolors,
251 unsigned int cpp, XpmColor **colorTablePtr,
252 xpmHashTable *hashtable));
253
254FUNC(xpmParseExtensions, int, (xpmData *data, XpmExtension **extensions,
255 unsigned int *nextensions));
256
257/* RGB utility */
258
259FUNC(xpmReadRgbNames, int, (char *rgb_fname, xpmRgbName *rgbn));
260FUNC(xpmGetRgbName, char *, (xpmRgbName *rgbn, int rgbn_max,
261 int red, int green, int blue));
262FUNC(xpmFreeRgbNames, void, (xpmRgbName *rgbn, int rgbn_max));
263
264FUNC(xpmGetRGBfromName,int, (char *name, int *r, int *g, int *b));
265
266#ifdef __STDC__
267#define Const const
268#else
269#define Const /**/
270#endif
271
272#ifdef NEED_STRDUP
273FUNC(xpmstrdup, char *, (char *s1));
274#else
275#undef xpmstrdup
276#define xpmstrdup strdup
277#endif
278
279#ifdef NEED_STRCASECMP
280FUNC(xpmstrcasecmp, int, (char *s1, char *s2));
281#else
282#undef xpmstrcasecmp
283#define xpmstrcasecmp strcasecmp
284#endif
285
286FUNC(xpmatoui, unsigned int,
287 (char *p, unsigned int l, unsigned int *ui_return));
288
289#endif