1 /* graphics.h -
2  *
3  *     *********************************************************************
4  *     * Copyright (C) 1985, 1990 Regents of the University of California. *
5  *     * Permission to use, copy, modify, and distribute this              *
6  *     * software and its documentation for any purpose and without        *
7  *     * fee is hereby granted, provided that the above copyright          *
8  *     * notice appear in all copies.  The University of California        *
9  *     * makes no representations about the suitability of this            *
10  *     * software for any purpose.  It is provided "as is" without         *
11  *     * express or implied warranty.  Export of this software outside     *
12  *     * of the United States of America may require an export license.    *
13  *     *********************************************************************
14  *
15  * This file contains a bunch of macros that look like
16  * normal procedure calls but really indirect through procedure
17  * pointers in order to achieve graphics display independence.
18  */
19 
20 /* rcsid "$Header: /usr/cvsroot/magic-8.0/graphics/graphics.h,v 1.3 2010/06/24 12:37:18 tim Exp $" */
21 
22 #ifndef _GRAPHICS_H
23 #define	_GRAPHICS_H
24 
25 #include "utils/magic.h"
26 #include "utils/geometry.h"
27 
28 /* data structures */
29 typedef struct {
30     int idx, mask, color, outline, fill, stipple;
31     char shortname;
32     char *longname;
33 } GR_STYLE_LINE;
34 
35 typedef struct {	/* Colormap table entry */
36     char *name;
37     unsigned char red;
38     unsigned char green;
39     unsigned char blue;
40 } colorEntry;
41 
42 /* Housekeeping and initialization routines */
43 extern bool (*GrInitPtr)();
44 extern void (*GrClosePtr)();
45 extern void (*GrTextSizePtr)();
46 
47 /*
48  * Display painting and text routines
49  *
50  *    You must call GrLock() before using these, and
51  *    call GrUnlock() afterwards.
52  */
53 extern void (*GrLockPtr)();
54 extern void (*GrUnlockPtr)();
55 extern bool GrHaveLock();
56 extern void GrClipTo();
57 extern void GrClipBox();
58 extern void GrClipLine();
59 extern bool GrPutText();
60 extern void GrFillPolygon();
61 extern void (*GrDrawGlyphPtr)();
62 extern void (*GrBitBltPtr)();
63 extern int  (*GrReadPixelPtr)();
64 extern void (*GrFlushPtr)();
65 
66 /* Tablet routines */
67 extern void (*GrEnableTabletPtr)();
68 extern void (*GrDisableTabletPtr)();
69 extern void (*GrSetCursorPtr)();
70 
71 /* graphics routines that are called in the same way for all displays */
72 extern int  GrLoadStyles();
73 extern bool GrLoadCursors();
74 extern bool GrSetDisplay();
75 extern bool GrIsDisplay();
76 extern void GrLabelSize();
77 extern void GrSetStuff();
78 extern void GrDrawFastBox();
79 extern void GrGuessDisplayType();
80 extern int  GrGetStyleFromName();
81 extern bool GrDrawGlyphNum();
82 
83 #define GrFastBox(x)	GrDrawFastBox(x, 0)
84 
85 /* external color map routines */
86 extern bool GrReadCMap(), GrSaveCMap();
87 extern bool GrGetColor(), GrPutColor();
88 extern int  GrNameToColor();
89 extern void GrPutManyColors();
90 extern void (*GrSetCMapPtr)();
91 extern void GrResetCMap();
92 
93 /* Routines for windows, called only if non-null.  See SUN160 driver for
94  * details.
95  */
96 extern bool (*GrCreateWindowPtr)();	/* Passed a window just after it is
97 					 * created.
98 					 */
99 extern void (*GrDeleteWindowPtr)();	/* Passed a window just before it
100 					 * is destroyed.
101 					 */
102 extern void (*GrDamagedPtr)();		/* Called at a conventient time after
103 					 * receiving a SIG_WINCH signal.
104 					 */
105 extern void (*GrUpdateIconPtr)(); 	/* Adjust text on icon.
106 					 */
107 extern bool (*GrEventPendingPtr)(); 	/* Check for pending graphics events.
108 					 */
109 extern void (*GrConfigureWindowPtr)();	/* Called to reconfigure size/location
110 					 * of an existing window.
111 					 */
112 extern void (*GrOverWindowPtr)();	/* Raise window to top of stack.
113 					 */
114 extern void (*GrUnderWindowPtr)();	/* Lower window to bottom of stack.
115 					 */
116 extern int (*GrWindowIdPtr)(); 		/* Get the window ID from a window name
117 					 */
118 extern char *(*GrWindowNamePtr)(); 	/* Get the window name from a MagWin ptr.
119 					 */
120 extern bool (*GrGetCursorPosPtr)(); 	/* Get the current cursor position
121 					 */
122 extern bool (*GrGetCursorRootPosPtr)();	/* Get the current cursor position
123 					 * in root (screen) coordinates
124 					 */
125 
126 /* Backing store mechanism (added 4/2/05) */
127 extern bool (*GrGetBackingStorePtr)();
128 extern bool (*GrScrollBackingStorePtr)();
129 extern void (*GrPutBackingStorePtr)();
130 extern void (*GrCreateBackingStorePtr)();
131 extern void (*GrFreeBackingStorePtr)();
132 
133 /* Routines called by the signals module just before Magic is stopped
134  * (such as via ^Z) and just after it is resumed.
135  */
136 extern void (*GrStopPtr)();
137 extern void (*GrResumePtr)();
138 #define GrStop	(*GrStopPtr)
139 #define GrResume (*GrResumePtr)
140 
141 /* Number of colors defined in the colormap */
142 extern int GrNumColors;
143 
144 /* Different graphics (OpenGL vs. X11, for instance) have different
145  * definitions of line and rectangle/polygon coordinates.  Usually
146  * this boils down to a single pixel difference on rectangle edges.
147  * GrPixelCorrect should be set to 0 for OpenGL and other real-valued
148  * coordinate systems, 1 for X11 and other pixel-based systems.
149  */
150 extern int GrPixelCorrect;
151 
152 /* The size of the screen in screen coordinates */
153 extern Rect GrScreenRect;
154 
155 /* The size of crosses (drawn for zero-size boxes), in pixels. */
156 extern Rect GrCrossRect;
157 
158 /* Multiples of the grid spacing which we draw lighter, for a fading effect */
159 extern unsigned char GrGridMultiple;
160 
161 /* Style tables */
162 extern GR_STYLE_LINE *GrStyleTable;
163 extern int **GrStippleTable;
164 extern int GrStyleNames[];
165 
166 #ifndef lint
167 
168 /* Constants for easy access */
169 
170 #define GrLock (*GrLockPtr)
171 #define GrUnlock (*GrUnlockPtr)
172 #define GrInit (*GrInitPtr)
173 #define GrClose (*GrClosePtr)
174 #define GrSetCMap (*GrSetCMapPtr)
175 #define GrTextSize (*GrTextSizePtr)
176 #define GrDrawGlyph (*GrDrawGlyphPtr)
177 #define GrBitBlt (*GrBitBltPtr)
178 #define	GrReadPixel (*GrReadPixelPtr)
179 #define GrFlush (*GrFlushPtr)
180 
181 #define GrEnableTablet (*GrEnableTabletPtr)
182 #define GrDisableTablet (*GrDisableTabletPtr)
183 #define GrGetCursorPos (*GrGetCursorPosPtr)
184 #define GrGetCursorRootPos (*GrGetCursorRootPosPtr)
185 #define GrGetButtons (*GrGetButtonsPtr)
186 #define GrSetCursor (*GrSetCursorPtr)
187 
188 #endif
189 
190 enum { DISPLAY_IDLE, DISPLAY_IN_PROGRESS, DISPLAY_BREAK_PENDING, DISPLAY_SUSPEND };
191 extern unsigned char GrDisplayStatus;
192 
193 /* constants */
194 
195 /* Rectangle filling styles.
196  * (note: this must match the array in grDStyle.c)
197  */
198 
199 #define GR_STSOLID      0
200 #define GR_STCROSS      1
201 #define GR_STOUTLINE    2
202 #define GR_STSTIPPLE    3
203 #define GR_STGRID       4
204 
205 /* 4 text sizes that are specified by the graphics driver, plus a 5th one.
206  * This last one is for systems that allow the user to specify a default font
207  * (such as a sun) -- on other systems it's size is decided by the driver.
208  *
209  * Note:
210  *    These must be in sequential, ascending order.
211  */
212 #define GR_TEXT_SMALL	0
213 #define GR_TEXT_MEDIUM	1
214 #define GR_TEXT_LARGE	2
215 #define GR_TEXT_XLARGE	3
216 #define GR_TEXT_DEFAULT	4
217 
218 /* Default cursor position -- used on startup and if we can't read the cursor */
219 #define GR_CURSOR_X	100
220 #define GR_CURSOR_Y	100
221 
222 /* Special full-screen access for window manager only */
223 #define GR_LOCK_SCREEN	(MagWindow *)(-1)
224 
225 #endif /* _GRAPHICS_H */
226