aboutsummaryrefslogtreecommitdiff
path: root/generic/Types.h
blob: 1a9b7bc5c79acc2c4a5272865d8dc31585a54cb8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
/*
 * Types.h -- Some types and macros used by the Zinc widget.
 *
 * Authors		: Patrick Lecoanet.
 * Creation date	: Mon Feb  1 12:13:24 1999
 *
 * $Id$
 */

/*
 *  Copyright (c) 1993 - 1999 CENA, Patrick Lecoanet --
 *
 * This code is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Library General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This code is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Library General Public License for more details.
 *
 * You should have received a copy of the GNU Library General Public
 * License along with this code; if not, write to the Free
 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 *
 */


#ifndef _Types_h
#define _Types_h


#ifdef _WIN32
#  define WIN32_LEAN_AND_MEAN
#  include <windows.h>
#  undef WIN32_LEAN_AND_MEAN
#  if defined(_MSC_VER)
#    define DllEntryPoint DllMain
#  endif
#endif

#ifdef GL
#  ifdef _WIN32
#    include <GL/gl.h>
#  else
#    include <GL/glx.h>
#  endif
#endif

#include "private.h"

#define NEED_REAL_STDIO

#include <tk.h>
#include <tkInt.h>
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#ifdef PTK
#  include <tkPort.h>
#  include <tkImgPhoto.h>
#  include <tkVMacro.h>
#  ifndef PTK_800
#    define Arg Tcl_Obj *
#  endif
#else
#  include <tkDecls.h>
#  include <tkIntDecls.h>
#endif
#include <stdio.h>


/* This EXTERN declaration is needed for Tcl < 8.0.3 */
#ifndef EXTERN
# ifdef __cplusplus
#  define EXTERN extern "C" TCL_STORAGE_CLASS
# else
#  define EXTERN extern TCL_STORAGE_CLASS
# endif
#endif


#ifdef __CPLUSPLUS__
extern "C" {
#endif


typedef double	ZnReal;	/* Keep it a double for GL and Tcl. */
typedef int	ZnBool;	/* Keep it an int to keep Tk happy */
typedef ZnReal	ZnPos;
typedef ZnReal	ZnDim;
typedef void	*ZnPtr;


#define ZnPixel(color)		((color)->pixel)
#define ZnMalloc(size)		((void *)ckalloc(size))
#define ZnFree(ptr)		(ckfree((char *)(ptr)))
#define ZnRealloc(ptr, size)	((void *)ckrealloc((void *)(ptr), size))
#define ZnWarning(msg)		(fprintf(stderr, "%s", (msg)))
  
#define ZnUnspecifiedImage	None
#define ZnUnspecifiedColor	NULL

#ifndef TCL_INTEGER_SPACE
#  define TCL_INTEGER_SPACE	24
#endif

#ifdef PTK_800
/*
 * Macros for Tk8.4/perl/Tk utf compatibility
 */
#define Tcl_NumUtfChars(str, len) (((len)<0)?((int)strlen(str)):(len))
#define Tcl_UtfAtIndex(str, index) (&(str)[(index)])
#define Tcl_GetString(str) (Tcl_GetStringFromObj(str, NULL))

#define Tk_GetScrollInfoObj(interp, argc, args, fract, count) \
Tk_GetScrollInfo(interp, argc, (Tcl_Obj **) args, fract, count)
#endif

/*
 * Macros for Windows compatibility
 */
#ifdef _WIN32
#  include <tkWinInt.h>

#  ifndef _MSC_VER
#    undef EXTERN
#    define EXTERN
#  endif
#  ifdef TCL_STORAGE_CLASS
#    undef TCL_STORAGE_CLASS
#  endif
#  ifdef BUILD_Tkzinc
#    define TCL_STORAGE_CLASS DLLEXPORT
#  else
#    define TCL_STORAGE_CLASS DLLIMPORT
#  endif

#  undef XFillRectangle
#  undef XFillRectangles
#  undef XFillArc
#  undef XFillPolygon
#  undef XDrawRectangle
#  undef XDrawArc
#  undef XDrawLine
#  undef XDrawLines

ZnBool ZnPointInRegion(TkRegion reg, int x, int y);
void ZnUnionRegion(TkRegion sra, TkRegion srb, 
		   TkRegion dr_return);
void ZnOffsetRegion(TkRegion reg, int dx, int dy);
TkRegion ZnPolygonRegion(XPoint *points, int n,
			 int fill_rule);
#  ifdef GL
#    define ZnGLContext HGLRC
#    define ZnGLWaitX()
#    define ZnGLWaitGL()
#    define ZN_GL_LINE_WIDTH_RANGE GL_LINE_WIDTH_RANGE
#    define ZN_GL_POINT_SIZE_RANGE GL_POINT_SIZE_RANGE
#  endif
#else /* !_WIN32 */
#  define ZnPointInRegion(reg, x, y) \
  XPointInRegion((Region) reg, x, y)
#  define ZnPolygonRegion(points, npoints, fillrule) \
  ((TkRegion) XPolygonRegion(points, npoints, fillrule))
#  define ZnUnionRegion(sra, srb, rreturn) \
  XUnionRegion((Region) sra, (Region) srb, (Region) rreturn)
#  define ZnOffsetRegion(reg, dx, dy) \
  XOffsetRegion((Region) reg, dx, dy)
#  ifdef GL
#    define ZnGLContext GLXContext
#    define ZnGLWaitX() \
  glXWaitX()
#    define ZnGLWaitGL() \
  glXWaitGL()
#    define ZN_GL_LINE_WIDTH_RANGE GL_SMOOTH_LINE_WIDTH_RANGE
#    define ZN_GL_POINT_SIZE_RANGE GL_SMOOTH_POINT_SIZE_RANGE
#  endif
#endif

#ifdef __CPLUSPLUS__
}
#endif

#endif /* _Types_h */