1 /**************************************************************************** 2 Copyright (C) 1987-2015 by Jeffery P. Hansen 3 4 This program is free software; you can redistribute it and/or modify 5 it under the terms of the GNU General Public License as published by 6 the Free Software Foundation; either version 2 of the License, or 7 (at your option) any later version. 8 9 This program is distributed in the hope that it will be useful, 10 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 GNU General Public License for more details. 13 14 You should have received a copy of the GNU General Public License along 15 with this program; if not, write to the Free Software Foundation, Inc., 16 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 17 ****************************************************************************/ 18 /* 19 Declarations for circuit representation structures. 20 */ 21 #ifndef __tkgate_misc_h 22 #define __tkgate_misc_h 23 24 typedef struct GCellSpec_str GCellSpec; 25 typedef struct EditState_str EditState; 26 typedef struct celemnt GCElement; 27 typedef struct net GNet; 28 typedef struct wire GWire; 29 typedef struct wirelist GWireList; 30 typedef struct wirenode GWireNode; 31 typedef struct gateinfo GGateInfo; 32 typedef struct simmodule GSimModule; 33 typedef struct modlayout GModLayout; 34 typedef struct GModSymbol_str GModSymbol; 35 typedef struct GError_str GateError; 36 typedef struct GEScript_str GEScript; 37 typedef struct ErrorList_str ErrorList; 38 typedef struct TkgGatWin_str TkgGateWin; 39 typedef struct TkGateParams_str TkGateParams; 40 typedef struct EditData_str EditData; 41 typedef struct CurrentFile_str CurrentFile; 42 typedef struct Circuit_str Circuit; 43 typedef struct GPrint_str GPrint; 44 typedef struct SBreakPoint_str SBreakPoint; 45 typedef struct Script_str Script; 46 typedef struct GrabbedLabel_str GrabbedLabel; 47 typedef struct encoder_str Encoder; 48 typedef struct locale_str Locale; 49 50 /* 51 * Set of special Tcl characters 52 */ 53 #define TCL_SPECIALCHARS "\"\\[]$" 54 55 56 /* 57 * Zoom modes 58 */ 59 #define ZOOM_1 1 /* Normal zoom level */ 60 #define ZOOM_MAX 4 /* Maximum magnification */ 61 62 63 /* 64 Gate editing modes 65 */ 66 #define MODE_CUT 0 /* Cut wires */ 67 #define MODE_MOVE 1 /* Move gates, wires, connect wires */ 68 #define MODE_INVERT 2 /* Add/remove inverter on gate */ 69 #define MODE_SCROLL 3 /* x/y scrolling with hand cursor */ 70 #define MODE_NAME 5 /* Set the name of a gate or wire */ 71 #define MODE_ADDINPUT 6 /* Add an input to a block */ 72 #define MODE_ADDOUTPUT 7 /* Add an output to a block */ 73 #define MODE_REPLICATE 8 /* Replicate a gate */ 74 #define MODE_SETSIZE 9 /* Set the bit width of a wire */ 75 #define MODE_ADDTRI 10 /* Add an inout to a block */ 76 #define MODE_CHANGEDIR 11 /* Change direction of pin on a block */ 77 #define MODE_DEBUG 12 /* Print debug info on gate or wire */ 78 #define MODE_MAKESEL 13 /* Create a multi-gate selection */ 79 #define MODE_MOVESEL 14 /* Operate on a multi-gate selection */ 80 #define MODE_MOVENULL 15 /* A null mode to ignore events until a mouse release */ 81 82 #define MODE_DELETE -3 /* obsolete "delete gate" mode */ 83 84 #define NOHIT 100000 /* Not a hit */ 85 86 /* Wire directions */ 87 #define ANY 0 88 #define TRI 1 89 #define IN 2 90 #define OUT 3 91 92 /* Directions */ 93 #define ROT0 0 94 #define ROT90 1 95 #define ROT180 2 96 #define ROT270 3 97 98 #define DASH_LENGTH 6 /* Length of dash cycle (should be even) */ 99 100 101 /* 102 Replication options 103 */ 104 #define REP_NOWIRES 0x1 /* Do not replicate wires */ 105 106 /* 107 * Text justification options. 108 */ 109 #define BetweenLeftAndRight 0x1 110 #define AtRight 0x2 111 #define AtLeft 0x4 112 #define BetweenTopAndBottom 0x8 113 #define AtBaseline 0x10 114 #define AtTop 0x20 115 #define AtBottom 0x40 116 #define RJ AtBaseline|AtRight 117 #define CT AtBaseline|BetweenLeftAndRight 118 #define LJ AtBaseline|AtLeft 119 120 /* Languages for messages */ 121 #define ENGLISH 0 122 #define JAPANESE 1 123 124 /* Cursors */ 125 #define TEXTCURSOR 0 126 #define OPENCUTTERS 1 127 #define CLOSEDCUTTERS 2 128 #define IRON 3 129 #define INVERTUPCURSOR 4 130 #define DELETEUPCURSOR 5 131 #define DELETEDNCURSOR 6 132 #define PAPERMOVECURSOR 7 133 #define PENCIL 9 134 #define DOWNARROW 10 135 #define UPARROW 11 136 #define REPCURSOR 12 137 #define SIZECURSOR 13 138 #define ARROWCURSOR 14 139 #define BATCURSOR 15 140 #define BATCURSOR1 16 141 #define BATCURSOR2 17 142 #define BATCURSOR3 18 143 #define ARROW0 19 144 #define ARROW90 20 145 #define ARROW180 21 146 #define ARROW270 22 147 #define MENUCURSOR 23 148 #define TRIARROW 24 149 #define CHANGEDIRCURSOR 25 150 #define WRENCHCURSOR 26 151 #define TREKDELETEUP 27 152 #define TREKDELETEDN 28 153 #define INVERTDNCURSOR 29 154 #define ADDPORTTOP 30 155 #define ADDPORTBOTTOM 31 156 #define ADDPORTLEFT 32 157 #define ADDPORTRIGHT 33 158 #define SCROLLCURSOR 34 159 #define MAXCURSORS 35 160 161 /* 162 * Special cursors 163 */ 164 #define CANCELMOUSEOVER -1 /* Cancel any special mouseover cursors */ 165 #define HYPERLINKCURSOR -2 /* Use the hyperlink mouseover cursor */ 166 167 #define SCROLL_LIMIT 100 168 169 #define TKG_GATEWIN_HEIGHT 600 170 #define TKG_GATEWIN_WIDTH 800 171 172 /* 173 Codes for logErrorMessage 174 */ 175 #define ERL_ERROR 0,__FILE__,__LINE__ 176 #define ERL_WARN 1,__FILE__,__LINE__ 177 #define ERL_FATAL 2,__FILE__,__LINE__ 178 179 /* 180 Macros defining variable names from tcl scripts. 181 */ 182 #define FONT_PATH "font_path" 183 #define TEXT_FONT "body_font" 184 #define BOLDTEXT_FONT "boldBody_font" 185 #define SMALLTEXT_FONT "smallBody_font" 186 #define SMALLBOLDTEXT_FONT "boldSmallBody_font" 187 #define SHAPES_FONT "cursor_font" 188 189 /* Orientations */ 190 #define NORMAL 0 191 #define UP 0 192 #define RIGHT 1 193 #define DOWN 2 194 #define LEFT 3 195 196 /* Coder types */ 197 #define ENCODER 0 198 #define DECODER 1 199 #define PRIENCODER 2 200 201 /* Gate draw types */ 202 typedef enum _drawtype_t { 203 GD_NORMAL = 0, 204 #define GD_NORMAL GD_NORMAL /* Normal drawing (gate with wires) */ 205 GD_NOINWIRE, 206 #define GD_NOINWIRE GD_NOINWIRE /* Suppress input wire drawing */ 207 GD_NOWIRE, 208 #define GD_NOWIRE GD_NOWIRE /* Suppress wire drawing */ 209 GD_PADONLY 210 #define GD_PADONLY GD_PADONLY /* Draw only wire pad names (block type only) */ 211 } drawtype_t; 212 213 #define DEFAULT_PORT_NAME "*port_name*" 214 215 #define bits(var,size) unsigned int var : size 216 #define midpointp(m,v1,v2) (abs((m)-(v1)) + abs((m)-(v2)) == abs((v1)-(v2))) 217 218 /* The distance formula */ 219 #define distance(x1,y1,x2,y2) ((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2)) 220 #define wdist(w,x,y) distance((w)->nodes->x,(w)->nodes->y,x,y) 221 222 #define sqr(x) ((x)*(x)) 223 224 #define nmask(n) ((n) < 32 ? ((1 << (n)) -1) : -1) 225 226 227 /* Test a node to see if it's mobile */ 228 #define anchoredp(n) ((n)->end && (n)->end->gate) 229 #define ujanchored(n) (n->end ? (n->end->gate ? n->end->gate->gclass != JOINT : TRUE): FALSE) 230 #define boatanchored(n) (n->boatanchored) 231 /* Type cast connection description */ 232 #define connect(g,t) ((struct t *) g->connections) /* Obsolete, use c_<>() */ 233 #define dce_SetClipRectangle(x,y,w,h) wm_SetClipRectangle((x) + TkGate.org_x,(y) + TkGate.org_y,w,h) 234 235 #define vertical(n,m) (((n)->x == (m)->x) && ((n)->y != (m)->y)) 236 #define horizontal(n,m) (((n)->x != (m)->x) && ((n)->y == (m)->y)) 237 #define zerolength(n,m) (((n)->x == (m)->x) && ((n)->y == (m)->y)) 238 239 /* 240 * Print message if debugging is active. 241 */ 242 #define debugprint(m) {if (debugmode) printf(m);} 243 244 /* 245 * Target device for formatting 246 */ 247 typedef enum { 248 TD_X11, 249 TD_PRINT 250 } TargetDev_e; 251 252 #endif 253