1 
2 /*
3  * bltWin.h --
4  *
5  * Copyright 1993-1998 Lucent Technologies, Inc.
6  *
7  * Permission to use, copy, modify, and distribute this software and
8  * its documentation for any purpose and without fee is hereby
9  * granted, provided that the above copyright notice appear in all
10  * copies and that both that the copyright notice and warranty
11  * disclaimer appear in supporting documentation, and that the names
12  * of Lucent Technologies any of their entities not be used in
13  * advertising or publicity pertaining to distribution of the software
14  * without specific, written prior permission.
15  *
16  * Lucent Technologies disclaims all warranties with regard to this
17  * software, including all implied warranties of merchantability and
18  * fitness.  In no event shall Lucent Technologies be liable for any
19  * special, indirect or consequential damages or any damages
20  * whatsoever resulting from loss of use, data or profits, whether in
21  * an action of contract, negligence or other tortuous action, arising
22  * out of or in connection with the use or performance of this
23  * software.
24  */
25 
26 #ifndef _BLT_WIN_H
27 #define _BLT_WIN_H
28 
29 #define STRICT
30 #define WIN32_LEAN_AND_MEAN
31 #include <windows.h>
32 #undef STRICT
33 #undef WIN32_LEAN_AND_MEAN
34 #include <windowsx.h>
35 
36 
37 #undef STD_NORMAL_BACKGROUND
38 #undef STD_NORMAL_FOREGROUND
39 #undef STD_SELECT_BACKGROUND
40 #undef STD_SELECT_FOREGROUND
41 #undef STD_TEXT_FOREGROUND
42 #undef STD_FONT
43 #undef STD_FONT_LARGE
44 #undef STD_FONT_SMALL
45 
46 #define STD_NORMAL_BACKGROUND	"SystemButtonFace"
47 #define STD_NORMAL_FOREGROUND	"SystemButtonText"
48 #define STD_SELECT_BACKGROUND	"SystemHighlight"
49 #define STD_SELECT_FOREGROUND	"SystemHighlightText"
50 #define STD_TEXT_FOREGROUND	"SystemWindowText"
51 #define STD_FONT		"Arial 8"
52 #define STD_FONT_LARGE		"Arial 12"
53 #define STD_FONT_SMALL		"Arial 6"
54 
55 #ifdef CHECK_UNICODE_CALLS
56 #define _UNICODE
57 #define UNICODE
58 #define __TCHAR_DEFINED
59 typedef float *_TCHAR;
60 #define _TCHAR_DEFINED
61 typedef float *TCHAR;
62 #endif /* CHECK_UNICODE_CALLS */
63 
64 /* DOS Encapsulated PostScript File Header */
65 #pragma pack(2)
66 typedef struct {
67     BYTE magic[4];		/* Magic number for a DOS EPS file
68 				 * C5,D0,D3,C6 */
69     DWORD psStart;		/* Offset of PostScript section. */
70     DWORD psLength;		/* Length of the PostScript section. */
71     DWORD wmfStart;		/* Offset of Windows Meta File section. */
72     DWORD wmfLength;		/* Length of Meta file section. */
73     DWORD tiffStart;		/* Offset of TIFF section. */
74     DWORD tiffLength;		/* Length of TIFF section. */
75     WORD checksum;		/* Checksum of header. If FFFF, ignore. */
76 } DOSEPSHEADER;
77 #pragma pack()
78 
79 /* Aldus Portable Metafile Header */
80 #pragma pack(2)
81 typedef struct {
82     DWORD key;			/* Type of metafile */
83     WORD hmf;			/* Unused. Must be NULL. */
84     SMALL_RECT bbox;		/* Bounding rectangle */
85     WORD inch;			/* Units per inch. */
86     DWORD reserved;		/* Unused. */
87     WORD checksum;		/* XOR of previous fields (10 32-bit words). */
88 } APMHEADER;
89 #pragma pack()
90 
91 extern double hypot(double x, double y);
92 extern int Blt_AsyncRead(int fd, char *buffer, unsigned int size);
93 extern int Blt_AsyncWrite(int fd, char *buffer, unsigned int size);
94 extern void Blt_CreateFileHandler(int fd, int flags, Tcl_FileProc * proc,
95     ClientData clientData);
96 extern void Blt_DeleteFileHandler(int fd);
97 extern int Blt_GetPlatformId(void);
98 extern char *Blt_LastError(void);
99 extern int Blt_GetOpenPrinter(Tcl_Interp *interp, const char *id,
100     Drawable *drawablePtr);
101 extern int Blt_PrintDialog(Tcl_Interp *interp, Drawable *drawablePtr);
102 extern int Blt_OpenPrinterDoc(Tcl_Interp *interp, const char *id);
103 extern int Blt_ClosePrinterDoc(Tcl_Interp *interp, const char *id);
104 extern void Blt_GetPrinterScale(HDC dc, double *xRatio, double *yRatio);
105 extern int Blt_StartPrintJob(Tcl_Interp *interp, Drawable drawable);
106 extern int Blt_EndPrintJob(Tcl_Interp *interp, Drawable drawable);
107 
108 #undef EXPORT
109 #define EXPORT __declspec(dllexport)
110 
111 #ifdef _MSC_VER
112 #define strncasecmp(s1,s2,n)	_strnicmp(s1,s2,n)
113 #define strcasecmp(s1,s2)	_stricmp(s1,s2)
114 #define isnan(x)		_isnan(x)
115 #endif /* _MSC_VER */
116 
117 #ifdef __BORLANDC__
118 #define isnan(x)		_isnan(x)
119 #endif
120 
121 #if defined(__BORLANDC__) || defined(_MSC_VER)
122 #ifdef FINITE
123 #undef FINITE
124 #define FINITE(x)		_finite(x)
125 #endif
126 #endif /* __BORLANDC__ || _MSC_VER */
127 
128 #ifdef __GNUC__
129 #include <wingdi.h>
130 #include <windowsx.h>
131 #undef Status
132 #include <winspool.h>
133 #define Status int
134 /*
135  * Add definitions missing from windgi.h, windowsx.h, and winspool.h
136  */
137 #include <missing.h>
138 #endif /* __GNUC__ */
139 
140 #define XCopyArea		Blt_EmulateXCopyArea
141 #define XCopyPlane		Blt_EmulateXCopyPlane
142 #define XDrawArcs		Blt_EmulateXDrawArcs
143 #define XDrawLine		Blt_EmulateXDrawLine
144 #define XDrawLines		Blt_EmulateXDrawLines
145 #define XDrawPoints		Blt_EmulateXDrawPoints
146 #define XDrawRectangle		Blt_EmulateXDrawRectangle
147 #define XDrawRectangles		Blt_EmulateXDrawRectangles
148 #define XDrawSegments		Blt_EmulateXDrawSegments
149 #define XDrawString		Blt_EmulateXDrawString
150 #define XFillArcs		Blt_EmulateXFillArcs
151 #define XFillPolygon		Blt_EmulateXFillPolygon
152 #define XFillRectangle		Blt_EmulateXFillRectangle
153 #define XFillRectangles		Blt_EmulateXFillRectangles
154 #define XFree			Blt_EmulateXFree
155 #define XGetWindowAttributes	Blt_EmulateXGetWindowAttributes
156 #define XLowerWindow		Blt_EmulateXLowerWindow
157 #define XMaxRequestSize		Blt_EmulateXMaxRequestSize
158 #define XRaiseWindow		Blt_EmulateXRaiseWindow
159 #define XReparentWindow		Blt_EmulateXReparentWindow
160 #define XSetDashes		Blt_EmulateXSetDashes
161 #define XUnmapWindow		Blt_EmulateXUnmapWindow
162 #define XWarpPointer		Blt_EmulateXWarpPointer
163 
164 EXTERN GC Blt_EmulateXCreateGC(Display *display, Drawable drawable,
165     unsigned long mask, XGCValues *valuesPtr);
166 EXTERN void Blt_EmulateXCopyArea(Display *display, Drawable src, Drawable dest,
167     GC gc, int src_x, int src_y, unsigned int width, unsigned int height,
168     int dest_x, int dest_y);
169 EXTERN void Blt_EmulateXCopyPlane(Display *display, Drawable src,
170     Drawable dest, GC gc, int src_x, int src_y, unsigned int width,
171     unsigned int height, int dest_x, int dest_y, unsigned long plane);
172 EXTERN void Blt_EmulateXDrawArcs(Display *display, Drawable drawable, GC gc,
173     XArc *arcArr, int nArcs);
174 EXTERN void Blt_EmulateXDrawLine(Display *display, Drawable drawable, GC gc,
175     int x1, int y1, int x2, int y2);
176 EXTERN void Blt_EmulateXDrawLines(Display *display, Drawable drawable, GC gc,
177     XPoint *pointArr, int nPoints, int mode);
178 EXTERN void Blt_EmulateXDrawPoints(Display *display, Drawable drawable, GC gc,
179     XPoint *pointArr, int nPoints, int mode);
180 EXTERN void Blt_EmulateXDrawRectangle(Display *display, Drawable drawable,
181     GC gc, int x, int y, unsigned int width, unsigned int height);
182 EXTERN void Blt_EmulateXDrawRectangles(Display *display, Drawable drawable,
183     GC gc, XRectangle *rectArr, int nRects);
184 EXTERN void Blt_EmulateXDrawSegments(Display *display, Drawable drawable,
185     GC gc, XSegment *segArr, int nSegments);
186 EXTERN void Blt_EmulateXDrawSegments(Display *display, Drawable drawable,
187     GC gc, XSegment *segArr, int nSegments);
188 EXTERN void Blt_EmulateXDrawString(Display *display, Drawable drawable, GC gc,
189     int x, int y, _Xconst char *string, int length);
190 EXTERN void Blt_EmulateXFillArcs(Display *display, Drawable drawable, GC gc,
191     XArc *arcArr, int nArcs);
192 EXTERN void Blt_EmulateXFillPolygon(Display *display, Drawable drawable,
193     GC gc, XPoint *points, int nPoints,  int shape, int mode);
194 EXTERN void Blt_EmulateXFillRectangle(Display *display, Drawable drawable,
195     GC gc, int x, int y, unsigned int width, unsigned int height);
196 EXTERN void Blt_EmulateXFillRectangles(Display *display, Drawable drawable,
197     GC gc, XRectangle *rectArr, int nRects);
198 EXTERN void Blt_EmulateXFree(void *ptr);
199 EXTERN int Blt_EmulateXGetWindowAttributes(Display *display, Window window,
200     XWindowAttributes * attrsPtr);
201 EXTERN void Blt_EmulateXLowerWindow(Display *display, Window window);
202 EXTERN void Blt_EmulateXMapWindow(Display *display, Window window);
203 EXTERN long Blt_EmulateXMaxRequestSize(Display *display);
204 EXTERN void Blt_EmulateXRaiseWindow(Display *display, Window window);
205 EXTERN void Blt_EmulateXReparentWindow(Display *display, Window window,
206     Window parent, int x, int y);
207 EXTERN void Blt_EmulateXSetDashes(Display *display, GC gc, int dashOffset,
208     _Xconst char *dashList, int n);
209 EXTERN void Blt_EmulateXUnmapWindow(Display *display, Window window);
210 EXTERN void Blt_EmulateXWarpPointer(Display *display, Window srcWindow,
211     Window destWindow, int srcX, int srcY, unsigned int srcWidth,
212     unsigned int srcHeight, int destX, int destY);
213 
214 EXTERN void Blt_DrawLine2D(Display *display, Drawable drawable, GC gc,
215     POINT *screenPts, int nScreenPts);
216 
217 extern unsigned char *Blt_GetBitmapData _ANSI_ARGS_((Display *display,
218 	Pixmap bitmap, int width, int height, int *pitchPtr));
219 
220 extern HFONT Blt_CreateRotatedFont _ANSI_ARGS_((Tk_Window tkwin,
221 	unsigned long font, double theta));
222 
223 extern HPALETTE Blt_GetSystemPalette _ANSI_ARGS_((void));
224 
225 extern HPEN Blt_GCToPen _ANSI_ARGS_((HDC dc, GC gc));
226 
227 #endif /*_BLT_WIN_H*/
228