1 /*
2  * dbwind.h --
3  *
4  *	Interface definitions for the 'glue' between the window
5  *	manager and the database.
6  *
7  *     *********************************************************************
8  *     * Copyright (C) 1985, 1990 Regents of the University of California. *
9  *     * Permission to use, copy, modify, and distribute this              *
10  *     * software and its documentation for any purpose and without        *
11  *     * fee is hereby granted, provided that the above copyright          *
12  *     * notice appear in all copies.  The University of California        *
13  *     * makes no representations about the suitability of this            *
14  *     * software for any purpose.  It is provided "as is" without         *
15  *     * express or implied warranty.  Export of this software outside     *
16  *     * of the United States of America may require an export license.    *
17  *     *********************************************************************
18  *
19  *
20  * rcsid $Header: /usr/cvsroot/magic-8.0/dbwind/dbwind.h,v 1.1.1.1 2008/02/03 20:43:50 tim Exp $
21  */
22 
23 #ifndef _DBWIND_H
24 #define _DBWIND_H
25 
26 #include "database/database.h"
27 #include "windows/windows.h"
28 
29 /*--------------------------- Window Client Data ----------------------------
30  * The dbwind package keeps special client data that it uses to
31  * manage windows on the database.
32  */
33 
34 
35 typedef struct DBW1 {
36     int dbw_bitmask;		/* A single bit in a word, unique between all
37 				 * layout windows.  Any cell that is expanded
38 				 * in this window has this bit set in its
39 				 * expand mask.
40 				 */
41     int dbw_flags;		/* Various flags, see below. */
42     int dbw_watchPlane; 	/* The plane number of a plane to watch
43 				 * (show tile structure)
44 				 */
45     CellDef *dbw_watchDef;	/* The name of a celldef to watch */
46     Transform dbw_watchTrans;	/* A transform to root coordinates that
47 				 * uniquely identifies the -position- of
48 				 * the cell use being watched, in the root
49 				 * cell of the window.
50 				 */
51     Rect dbw_expandAmounts;	/* The sides of this rectangle are expanded
52 				 * out from the origin by the same amount
53 				 * that a redisplayed area should be expanded
54 				 * in order to catch all labels.  This
55 				 * reflects the size of the largest label
56 				 * displayed anywhere in the window.
57 				 */
58     TileTypeBitMask dbw_visibleLayers;
59 				/* This bit mask tells which mask layers
60 				 * should be displayed on the screen.
61 				 */
62     Plane *dbw_hlErase;		/* ERROR_P tiles on this plane record highlight
63 				 * areas that must be erased in this window,
64 				 * in screen coordinates.
65 				 */
66     Plane *dbw_hlRedraw;	/* ERROR_P tiles on this plane record highlight
67 				 * areas that must be redrawn in this window, in
68 				 * root database coordinates.
69 				 */
70     Rect dbw_gridRect;		/* Defines grid in world coordinates:  grid
71 				 * lines run along sides of rect, rect size
72 				 * determines spacing.
73 				 */
74     int dbw_labelSize;		/* What size to use for text when drawing
75 				 * labels in this window (e.g. GR_TEXT_SMALL).
76 				 * This is recomputed each time the window
77 				 * is completely redrawn.  -1 means don't
78 				 * draw labels at all.
79 				 */
80     Rect dbw_surfaceArea;	/* This field and the next two that follow
81 				 * are just copies of the corresponding
82 				 * fields from window records.  They're used
83 				 * to detect when a window has resized or
84 				 * rescaled.
85 				 */
86     Point dbw_origin;
87     int dbw_scale;
88 } DBWclientRec;
89 
90 /* Flag values for dbw_flags:
91  *
92  * DBW_GRID:		Means grid is to be displayed in window.
93  * DBW_WATCHDEMO:	Use `demo' style of watching (arrows, not addresses)
94  * DBW_ALLSAME:		Means don't use different display styles for
95  *			edit and other cells.
96  * DBW_SEELABELS:	0 means don't display labels ever.
97  * DBW_SEECELLS		0 means don't display cell names and bounding boxes
98  * DBW_SEETYPES		display tiletype instead of tile address
99  */
100 
101 #define DBW_GRID 1
102 #define DBW_WATCHDEMO 2
103 #define DBW_ALLSAME 4
104 #define DBW_SEELABELS 010
105 #define DBW_SEECELLS  020
106 #define DBW_SEETYPES  040
107 
108 /*
109  * exported variables
110  *
111  */
112 
113 extern WindClient DBWclientID;
114 extern int DBWSnapToGrid;
115 
116 extern int DBWMaxTechStyles;
117 extern int DBWMaxTileStyles;
118 extern int DBWNumStyles;
119 
120 extern int RtrPolyWidth, RtrMetalWidth, RtrContactWidth;
121 
122 /*
123  * Exported procedure headers for redisplay
124  */
125 
126 extern int DBWWatchTiles();
127 extern void DBWAreaChanged();
128 extern void DBWLabelChanged();
129 extern void DBWDrawLabel();
130 
131 /*
132  * Exported procedures and variables related to the technology file
133  */
134 
135 extern void DBWTechInitStyles();
136 extern bool DBWTechAddStyle();
137 extern char *DBWStyleType;
138 
139 /*
140  * exported button procedures and variables
141  */
142 
143 extern void (*DBWButtonCurrentProc)();
144 extern void DBWAddButtonHandler();
145 extern char *DBWChangeButtonHandler();
146 extern void DBWPrintButtonDoc();
147 extern void DBWBoxHandler();
148 
149 /* The following values are flags passed to DBWloadWindow() */
150 
151 #define DBW_LOAD_IGNORE_TECH 1	/* Force load even if tech line does not match */
152 #define DBW_LOAD_EXPAND	     2	/* Expand cell after loading	*/
153 #define DBW_LOAD_DEREFERENCE 4	/* Dereference instance file paths when loading */
154 #define DBW_LOAD_FAIL	     8	/* Do not create new cell if file is not loadable */
155 #define DBW_LOAD_QUIET	     16	/* Suppress error messages during load */
156 
157 /* The following defines are used to indicate corner positions
158  * of the box:
159  */
160 
161 #define TOOL_BL 0
162 #define TOOL_BR 1
163 #define TOOL_TR 2
164 #define TOOL_TL 3
165 #define TOOL_ILG -1
166 
167 /* The following defines are used to indicate which coordinate system
168  * the cursor box snaps to when moved with mouse clicks (values for
169  * DBWSnapToGrid).
170  */
171 
172 #define DBW_SNAP_INTERNAL	0	/* internal units (fine grid)	*/
173 #define DBW_SNAP_LAMBDA		1	/* lambda units (coarse grid)	*/
174 #define DBW_SNAP_USER		2	/* user grid units (user grid)	*/
175 #define DBW_SNAP_MICRONS	3	/* micron units			*/
176 
177 /* The following window mask can be used to select all database windows
178  * for things like the mask parameter to DBWAreaChanged.
179  */
180 
181 #define DBW_ALLWINDOWS -1
182 
183 extern MagWindow *ToolGetPoint();
184 extern MagWindow *ToolGetBoxWindow();
185 extern bool ToolGetBox();
186 extern void ToolSnapToGrid();
187 extern bool ToolGetEditBox(Rect *);
188 extern void ToolMoveBox(), ToolMoveCorner();
189 extern int ToolGetCorner();
190 extern void DBWloadWindow(), DBWxloadWindow();
191 extern void DBWSetBox();
192 extern void DBWResetBox();
193 extern void DBWUndoOldEdit();
194 extern void DBWUndoNewEdit();
195 
196 /* Exported procedures for managing highlights: */
197 
198 extern void DBWHLAddClient();
199 extern void DBWHLRemoveClient();
200 extern void DBWHLRedraw();
201 extern int DBWHLRedrawWind();
202 extern void DBWDrawBox();
203 extern void DBWDrawCrosshair();
204 
205 /* Exported procedures and variables relating to feedback: */
206 
207 extern int DBWFeedbackCount;
208 extern void DBWFeedbackClear();
209 extern void DBWFeedbackAdd();
210 extern char *DBWFeedbackNth();
211 
212 /* Exported procedures and variables relating to elements: */
213 
214 /* flag fields for all elements (8 bits maximum) */
215 #define DBW_ELEMENT_PERSISTENT	0x01
216 #define DBW_ELEMENT_TEXT_SIZE   0x0e	/* 3 bits (5 text sizes) */
217 #define DBW_ELEMENT_TEXT_POS    0xf0	/* 4 bits (9 positions) */
218 #define DBW_ELEMENT_LINE_HALFX	0x02	/* Add 1/2 to X position */
219 #define DBW_ELEMENT_LINE_HALFY	0x04	/* Add 1/2 to Y position */
220 #define DBW_ELEMENT_LINE_ARROWL	0x08	/* Add arrowhead left/bottom */
221 #define DBW_ELEMENT_LINE_ARROWR	0x10	/* Add arrowhead top/right */
222 
223 extern void DBWElementAddRect();
224 extern void DBWElementAddLine();
225 extern void DBWElementAddText();
226 extern void DBWElementDelete();
227 extern void DBWElementNames();
228 extern void DBWElementInbox();
229 extern void DBWElementClearDef();
230 extern void DBWElementParseFlags();
231 extern char *DBWPrintElements();
232 extern void DBWScaleElements();
233 extern void DBWScaleCrosshair();
234 
235 /* Random procedures used internally to this module.  None of these
236  * should ever need to be called by the outside world.
237  */
238 
239 extern void DBWCheckBoxDisplay();
240 extern void DBWUndoBox();
241 extern void DBWHLUpdate();
242 extern void DBWFeedbackShow();
243 
244 extern void dbwElementInit();
245 extern void dbwCrosshairInit();
246 
247 
248 #endif /* _DBWIND_H */
249