1 #-------------------------------------------------------------------------
2 # Start of xcircuit GUI configuration file.
3 # This file is sourced by "xcircuit.tcl" (".wishrc")
4 #-------------------------------------------------------------------------
6 # This script sets up all the xcircuit windows and callback functions.
7 # The callback routines are in the shared object file xcwrap.so
10 #-------------------------------
11 # Main xcircuit drawing window
12 #-------------------------------
14 proc xcircuit
::new_window { name
} {
16 global XCIRCUIT_VERSION XCIRCUIT_REVISION XCOps XCWinOps tcl_platform
19 wm title
$name XCircuit
21 wm protocol
$name WM_DELETE_WINDOW
\
22 "xcircuit::closewindow ${name}.mainframe.mainarea.drawing"
24 # All the internal frames
28 frame ${name
}.mainframe
30 grid propagate
${name
} false
31 grid ${name
}.menubar
-sticky news
-row 0 -column 0
32 grid ${name
}.mainframe
-sticky news
-row 1 -columnspan 2
33 grid ${name
}.infobar
-sticky news
-row 2 -columnspan 2
35 grid rowconfigure
${name
} 0 -weight 0
36 grid rowconfigure
${name
} 1 -weight 1
37 grid rowconfigure
${name
} 2 -weight 0
39 grid columnconfigure
${name
} 0 -weight 0
40 grid columnconfigure
${name
} 1 -weight 1
42 frame ${name
}.mainframe.mainarea
43 frame ${name
}.mainframe.toolbar
45 pack ${name
}.mainframe.toolbar
-side right
-fill y
46 pack ${name
}.mainframe.mainarea
-expand true
-fill both
48 set drawing
${name
}.mainframe.mainarea.drawing
49 simple
$drawing -bg white
-commandproc "focus $drawing ; set XCOps(focus) $name"
51 if [catch {set XCOps
(scale)}] {
52 set XCOps
(scale) [expr {int
([font measure TkDefaultFont M
] / 10)}]
54 set sbsize
[expr {2 + 13 * $XCOps(scale)}]
55 simple
${name
}.mainframe.mainarea.sbleft
-width $sbsize
56 simple
${name
}.mainframe.mainarea.sbbottom
-height $sbsize
57 simple
${name
}.mainframe.mainarea.corner
-width $sbsize -height $sbsize
59 # The drawing area and its scrollbars
61 grid ${name
}.mainframe.mainarea.sbleft
-row 0 -column 0 -sticky ns
62 grid ${name
}.mainframe.mainarea.sbbottom
-row 1 -column 1 -sticky ew
63 grid $drawing -row 0 -column 1 -sticky news
64 grid ${name
}.mainframe.mainarea.corner
-row 1 -column 0 -sticky news
66 grid rowconfigure
${name
}.mainframe.mainarea
0 -weight 1
67 grid columnconfigure
${name
}.mainframe.mainarea
1 -weight 1
69 # The top menu and message bar
71 menubutton ${name
}.menubar.filebutton
-text File
\
72 -menu ${name
}.menubar.filebutton.filemenu
73 menubutton ${name
}.menubar.editbutton
-text Edit
\
74 -menu ${name
}.menubar.editbutton.editmenu
75 menubutton ${name
}.menubar.textbutton
-text Text
\
76 -menu ${name
}.menubar.textbutton.textmenu
77 menubutton ${name
}.menubar.optionsbutton
-text Options
\
78 -menu ${name
}.menubar.optionsbutton.optionsmenu
79 menubutton ${name
}.menubar.windowbutton
-text Window
\
80 -menu ${name
}.menubar.windowbutton.windowmenu
81 menubutton ${name
}.menubar.netlistbutton
-text Netlist
\
82 -menu ${name
}.menubar.netlistbutton.netlistmenu
84 grid ${name
}.menubar.filebutton
${name
}.menubar.editbutton
\
85 ${name
}.menubar.textbutton
${name
}.menubar.optionsbutton
\
86 ${name
}.menubar.windowbutton
${name
}.menubar.netlistbutton
\
87 -ipadx 10 -sticky news
91 label ${name
}.
message -text \
92 "Welcome to Xcircuit v${XCIRCUIT_VERSION} rev ${XCIRCUIT_REVISION}" \
93 -justify left
-anchor w
95 grid ${name
}.
message -row 0 -column 1 -sticky news
-ipadx 10
97 button ${name
}.infobar.symb
-text "Symbol" -bg gray30
-fg white
98 button ${name
}.infobar.schem
-text "Schematic" -bg red
-fg white
99 button ${name
}.infobar.mode
-text "Wire Mode" -bg skyblue2
-fg gray20
100 label ${name
}.infobar.message1
-text "Editing: Page 1"
101 label ${name
}.infobar.message2
-text "Grid 1/6 in : Snap 1/12 in" \
102 -justify left
-anchor w
103 pack ${name
}.infobar.symb
${name
}.infobar.schem
${name
}.infobar.message1
\
104 ${name
}.infobar.mode
-side left
-ipadx 6 -fill y
105 pack ${name
}.infobar.message2
-ipadx 6 -expand true
-fill both
107 #-------------------------------------------------
108 # Mouse hint window (if mousehints are enabled)
109 #-------------------------------------------------
111 if {$XCOps(mousehints
) == 0} {
112 bind ${name
}.infobar.mode
<Button-1
> {xcircuit
::enable_mousehints}
113 } elseif
{$XCOps(mousehints
) == 1} {
114 xcircuit
::mousehint_create ${name
}
117 #-------------------------------------------------
118 # Create the menus, toolbar and associated tools
119 #-------------------------------------------------
121 xcircuit
::makemenus $name
122 xcircuit
::createtoolbar $name
123 xcircuit
::arrangetoolbar $name
124 xcircuit
::allcolorbuttons $name
125 xcircuit
::allfontbuttons $name
127 #-----------------------------------------------------------------
128 # Add key and button bindings for XCircuit commands (standard actions)
129 # These can be overridden by binding to specific keys and/or buttons.
130 #-----------------------------------------------------------------
132 bind $drawing <ButtonPress
> {standardaction
%b down
%s
}
133 bind $drawing <ButtonRelease
> {standardaction
%b up
%s
}
134 bind $drawing <KeyPress
> {standardaction
%k down
%s
}
135 bind $drawing <KeyRelease
> {standardaction
%k up
%s
}
137 # Here are some extra key functions that come with the TCL wrapper
139 bind $drawing <Key-Next
> {catch {page
[expr {[page
] + 1}]}}
140 bind $drawing <Key-Prior
> {catch {page
[expr {[page
] - 1}]}}
141 bind $drawing <Control-Key-p
> {xcircuit
::prompteditparams}
143 xcircuit
::keybind <Key-bracketleft
> {if {[select get
] == {}} \
144 {select here
; element
lower; deselect
} else {element
lower}; \
146 xcircuit
::keybind <Key-bracketright
> {if {[select get
] == {}} \
147 {select here
; element
raise; deselect
} else {element
raise}; \
150 # Bind numbers 1-9 and 0 so that they call the Tcl "page" command,
151 # and so can take advantage of the tag callback to "pageupdate".
153 xcircuit
::keybind <Key-1
> {page
1} $drawing
154 xcircuit
::keybind <Key-2
> {page
2} $drawing
155 xcircuit
::keybind <Key-3
> {page
3} $drawing
156 xcircuit
::keybind <Key-4
> {page
4} $drawing
157 xcircuit
::keybind <Key-5
> {page
5} $drawing
158 xcircuit
::keybind <Key-6
> {page
6} $drawing
159 xcircuit
::keybind <Key-7
> {page
7} $drawing
160 xcircuit
::keybind <Key-8
> {page
8} $drawing
161 xcircuit
::keybind <Key-9
> {page
9} $drawing
162 xcircuit
::keybind <Key-0
> {page
10} $drawing
164 # These are supposed to disable the scroll wheel on the scrollbars. . .
166 if {$tcl_platform(platform
) == "windows"} {
167 bind $name <FocusIn
> \
168 "catch {config focus ${drawing} ; focus ${drawing}; \
169 set XCOps(focus) ${name} ; xcircuit::updatedialog}"
171 bind ${name
}.mainframe.mainarea.sbleft
<MouseWheel
> {}
172 bind ${name
}.mainframe.mainarea.sbbottom
<MouseWheel
> {}
175 bind $drawing <Enter
> {focus %W
}
176 bind $name <FocusIn
> "catch {config focus $drawing ; \
177 set XCOps(focus) ${name} ; xcircuit::updatedialog}"
179 bind ${name
}.mainframe.mainarea.sbleft
<Button-4
> {}
180 bind ${name
}.mainframe.mainarea.sbleft
<Button-5
> {}
181 bind ${name
}.mainframe.mainarea.sbbottom
<Button-4
> {}
182 bind ${name
}.mainframe.mainarea.sbbottom
<Button-5
> {}
185 # Window-specific variable defaults (variables associated with toggle
186 # and radio buttons, etc.). Note that we really should set these
187 # defaults for the first window only, and subsequent windows should
188 # inherit values from the first window.
190 set XCWinOps
(${name
},button1
) None
191 set XCWinOps
(${name
},colorval
) inherit
192 set XCWinOps
(${name
},jhoriz
) left
193 set XCWinOps
(${name
},jvert
) bottom
194 set XCWinOps
(${name
},justif
) left
195 set XCWinOps
(${name
},linestyle
) solid
196 set XCWinOps
(${name
},fillamount
) 0
197 set XCWinOps
(${name
},opaque
) false
198 set XCWinOps
(${name
},polyedittype
) manhattan
199 set XCWinOps
(${name
},pathedittype
) tangents
200 set XCWinOps
(${name
},showgrid
) true
201 set XCWinOps
(${name
},showsnap
) true
202 set XCWinOps
(${name
},showaxes
) true
203 set XCWinOps
(${name
},showbbox
) false
204 set XCWinOps
(${name
},fontfamily
) Helvetica
205 set XCWinOps
(${name
},fontstyle
) normal
206 set XCWinOps
(${name
},fontencoding
) ISOLatin1
207 set XCWinOps
(${name
},fontlining
) normal
208 set XCWinOps
(${name
},fontscript
) normal
209 set XCWinOps
(${name
},gridstyle
) "internal units"
210 set XCWinOps
(${name
},flipinvariant
) true
211 set XCWinOps
(${name
},pinvisible
) false
212 set XCWinOps
(${name
},netlistable
) true
213 set XCWinOps
(${name
},showclipmasks
) show
214 set XCWinOps
(${name
},latexmode
) false
215 set XCWinOps
(${name
},colorscheme
) normal
216 set XCWinOps
(${name
},editinplace
) true
217 set XCWinOps
(${name
},pinpositions
) invisible
218 set XCWinOps
(${name
},pinattach
) false
219 set XCWinOps
(${name
},namespaces
) false
220 set XCWinOps
(${name
},centerobject
) true
221 set XCWinOps
(${name
},manhattandraw
) false
222 set XCWinOps
(${name
},polyclosed
) closed
223 set XCWinOps
(${name
},scaleinvariant
) invariant
224 set XCWinOps
(${name
},endcaps
) round
225 set XCWinOps
(${name
},bboxtype
) false
226 set XCWinOps
(${name
},clipmask
) false
227 set XCWinOps
(${name
},substringparam
) false
228 set XCWinOps
(${name
},numericparam
) false
229 set XCWinOps
(${name
},expressparam
) false
230 set XCWinOps
(${name
},xposparam
) false
231 set XCWinOps
(${name
},yposparam
) false
232 set XCWinOps
(${name
},styleparam
) false
233 set XCWinOps
(${name
},anchorparam
) false
234 set XCWinOps
(${name
},startparam
) false
235 set XCWinOps
(${name
},endparam
) false
236 set XCWinOps
(${name
},radiusparam
) false
237 set XCWinOps
(${name
},minorparam
) false
238 set XCWinOps
(${name
},rotationparam
) false
239 set XCWinOps
(${name
},scaleparam
) false
240 set XCWinOps
(${name
},linewidthparam
) false
241 set XCWinOps
(${name
},colorparam
) false
242 set XCWinOps
(${name
},sel_lab
) true
243 set XCWinOps
(${name
},sel_inst
) true
244 set XCWinOps
(${name
},sel_poly
) true
245 set XCWinOps
(${name
},sel_arc
) true
246 set XCWinOps
(${name
},sel_spline
) true
247 set XCWinOps
(${name
},sel_graphic
) true
248 set XCWinOps
(${name
},sel_path
) true
249 set XCWinOps
(${name
},labeltype
) Text
250 set XCWinOps
(${name
},labelimage
) img_t
251 set XCWinOps
(${name
},rotateamount
) 15
253 #-----------------------------------------------------------------
254 # The "catch" statement here allows "i" and "I" to have other bindings for
255 # normal mode (e.g., "I" for "make info label") when nothing is selected.
256 #-----------------------------------------------------------------
258 xcircuit
::keybind i
{if {[catch {xcircuit
::autoincr}]} \
259 {standardaction
%k down
%s
}} $drawing
260 xcircuit
::keybind I
{if {[catch {xcircuit
::autoincr -1}]} \
261 {standardaction
%k down
%s
}} $drawing
263 #-----------------------------------------------------------------
264 # Function bindings for the mouse scroll wheel.
265 # Note that Windows uses MouseWheel and direction passed as %D,
266 # while Linux uses Button-4 and Button-5.
267 #-----------------------------------------------------------------
269 if {$tcl_platform(platform
) == "windows"} {
270 xcircuit
::keybind <MouseWheel
> {if { %D
/120 >= 1} \
271 {pan up
0.1 ; refresh
} else {pan down
0.1 ; refresh
}} $drawing
272 xcircuit
::keybind <Shift-MouseWheel
> {if { %D
/120 >= 1} \
273 {pan left
0.1 ; refresh
} else {pan right
0.1 ; refresh
}} $drawing
274 xcircuit
::keybind <Control-MouseWheel
> {if { %D
/120 >= 1} \
275 {zoom in
; refresh
} else {zoom out
; refresh
}} $drawing
277 xcircuit
::keybind <Button-4
> { pan up
0.05 ; refresh
} $drawing
278 xcircuit
::keybind <Button-5
> { pan down
0.05 ; refresh
} $drawing
279 xcircuit
::keybind <Shift-Button-4
> { pan left
0.05 ; refresh
} $drawing
280 xcircuit
::keybind <Shift-Button-5
> { pan right
0.05 ; refresh
} $drawing
281 xcircuit
::keybind <Control-Button-4
> { zoom in
; refresh
} $drawing
282 xcircuit
::keybind <Control-Button-5
> { zoom out
; refresh
} $drawing
285 #-----------------------------------------------------------------
286 # Evaluate registered callback procedures
287 #-----------------------------------------------------------------
289 catch {eval $XCOps(callback
)}
290 catch {eval $XCWinOps(${name
}, callback
)}
293 #----------------------------------------------------------------------
295 #----------------------------------------------------------------------
297 proc xcircuit
::closewindow {name
} {
300 set winlist
[config windownames
]
301 if {[llength $winlist] > 1} {
302 if {[lsearch $winlist $name] != -1} {
304 set newwin
[lindex [config windownames
] 0]
305 destroy [winfo top
$name]
307 set XCOps
(focus) [winfo top
$newwin]
314 #----------------------------------------------------------------------
315 # Create a new window, and set it to the same page as the current one.
316 #----------------------------------------------------------------------
318 proc xcircuit
::forkwindow {} {
319 set suffix
[llength [config windownames
]]
320 set newname .xcircuit
${suffix
}
321 xcircuit
::new_window $newname
325 #----------------------------------------------------------------------
326 # Find the geometry position that centers a window on the cursor
328 #----------------------------------------------------------------------
330 proc xcircuit
::centerwin {wname
} {
331 set xmax
[expr {[winfo screenwidth
$wname] - 10}]
332 set ymax
[expr {[winfo screenheight
$wname] - 35}] ;# allow for titlebar height
333 set x
[winfo pointerx
$wname]
334 set y
[winfo pointery
$wname]
335 tkwait visibility
$wname
336 set w
[winfo width
$wname]
337 set h
[winfo height
$wname]
338 set x
[expr $x - $w / 2]
339 set y
[expr $y - $h / 2]
340 if {$x < 10} {set x
10}
341 if {$y < 10} {set y
10}
342 if {[expr {$x + $w}] > $xmax} {set x
[expr {$xmax - $w}]}
343 if {[expr {$y + $h}] > $ymax} {set y
[expr {$ymax - $h}]}
344 if {$x > 0} {set x
"+$x"}
345 if {$y > 0} {set y
"+$y"}
346 wm geometry
$wname $x$y
349 #----------------------------------------------------------------------
350 # Message handling. Assumes that windows are named
351 # 1) "pagename" where the page name is printed
352 # 2) "coordinates" where the coordinates are printed
353 # 3) "status" the general-purpose status and message line.
354 #----------------------------------------------------------------------
356 proc xcircuit
::print {wname
string} {
358 set window
$XCOps(focus)
360 switch -glob ${wname
} {
362 ${window
}.infobar.message1 configure
-text ${string}
365 ${window
}.
message configure
-text ${string}
369 ${window
}.infobar.message2 configure
-text ${string}
374 proc xcircuit
::getinitstate {wname
} {
375 if [winfo exists
$wname] {
376 set wstate
[wm state
$wname]
383 #----------------------------------------------------------------------
384 # Support procedures for tag callbacks
385 #----------------------------------------------------------------------
387 proc xcircuit
::popupdialog {{w .dialog
}} {
388 set wstate
[xcircuit
::getinitstate ${w
}]
389 xcircuit
::removelists ${w
}
391 if {"$wstate" != "normal"} {centerwin
${w
}}
393 focus ${w
}.textent.txt
396 proc xcircuit
::popupfilelist {{w .filelist
}} {
397 set wstate
[xcircuit
::getinitstate ${w
}]
398 xcircuit
::removelists ${w
}
402 focus ${w
}.textent.txt
405 #----------------------------------------------------------------------
406 # A refined "page size" that keeps a lid on the numerical precision
408 #----------------------------------------------------------------------
410 proc xcircuit
::getpagesize {} {
411 set slist
[xcircuit
::page size
]
412 set coordstyle
[lindex $slist 3]
413 if {$coordstyle == "cm"} {
414 # Round centimeter coords to the nearest 0.1
415 set xcm
[lindex $slist 0]
416 set xcm
[expr {round
($xcm * 10.0) / 10.0}]
417 set slist
[lreplace $slist 0 0 $xcm]
418 set ycm
[lindex $slist 2]
419 set ycm
[expr {round
($ycm * 10.0) / 10.0}]
420 set slist
[lreplace $slist 2 2 $ycm]
421 } elseif
{$coordstyle == "in"} {
422 # Round inch coords to the nearest 1/8
423 set xin
[lindex $slist 0]
424 set xin
[expr {round
($xin * 8.0) / 8.0}]
425 set slist
[lreplace $slist 0 0 $xin]
426 set yin
[lindex $slist 2]
427 set yin
[expr {round
($yin * 8.0) / 8.0}]
428 set slist
[lreplace $slist 2 2 $yin]
433 #----------------------------------------------------------------------
434 # This procedure configures the sheet size according to the page
435 # dimensions (if they match, within reason)
436 #----------------------------------------------------------------------
438 proc xcircuit
::setsheetsize {} {
441 set slist
[xcircuit
::getpagesize]
442 set coordstyle
[lindex $slist 3]
443 if {$coordstyle == "cm"} {
444 set xcm
[lindex $slist 0]
445 set ycm
[lindex $slist 2]
447 if {$xcm == 21.0 && $ycm == 29.7} {
448 set XCOps
(sheetsize
) a4
449 .output.textent.txtf.sizb configure
-text "A4"
450 } elseif
{$xcm == 29.7 && $ycm == 42.0} {
451 set XCOps
(sheetsize
) a3
452 .output.textent.txtf.sizb configure
-text "A3"
453 } elseif
{$xcm == 14.8 && $ycm == 18.4} {
454 set XCOps
(sheetsize
) a5
455 .output.textent.txtf.sizb configure
-text "A5"
456 } elseif
{$xcm == 25.7 && $ycm == 36.4} {
457 set XCOps
(sheetsize
) b4
458 .output.textent.txtf.sizb configure
-text "B4"
459 } elseif
{$xcm == 18.2 && $ycm == 25.7} {
460 set XCOps
(sheetsize
) b5
461 .output.textent.txtf.sizb configure
-text "B5"
463 set XCOps
(sheetsize
) special
464 .output.textent.txtf.sizb configure
-text "Special"
466 } elseif
{$coordstyle == "in"} {
467 set xin
[lindex $slist 0]
468 set yin
[lindex $slist 2]
470 if {$xin == 8.5 && $yin == 11.0} {
471 set XCOps
(sheetsize
) letter
472 .output.textent.txtf.sizb configure
-text Letter
473 } elseif
{$xin == 8.5 && $yin == 14.0} {
474 set XCOps
(sheetsize
) legal
475 .output.textent.txtf.sizb configure
-text Legal
476 } elseif
{$xin == 5.5 && $yin == 8.5} {
477 set XCOps
(sheetsize
) statement
478 .output.textent.txtf.sizb configure
-text Statement
479 } elseif
{$xin == 11.0 && $yin == 17.0} {
480 set XCOps
(sheetsize
) tabloid
481 .output.textent.txtf.sizb configure
-text Tabloid
482 } elseif
{$xin == 17.0 && $yin == 11.0} {
483 set XCOps
(sheetsize
) ledger
484 .output.textent.txtf.sizb configure
-text Ledger
485 } elseif
{$xin == 8.5 && $yin == 13.0} {
486 set XCOps
(sheetsize
) folio
487 .output.textent.txtf.sizb configure
-text Folio
488 } elseif
{$xin == 10.0 && $yin == 14.0} {
489 set XCOps
(sheetsize
) tenfourteen
490 .output.textent.txtf.sizb configure
-text 10x14
491 } elseif
{$xin == 7.5 && $yin == 10.0} {
492 set XCOps
(sheetsize
) executive
493 .output.textent.txtf.sizb configure
-text Executive
494 } elseif
{$xin == 17.0 && $yin == 22.0} {
495 set XCOps
(sheetsize
) ansic
496 .output.textent.txtf.sizb configure
-text "ANSI C"
497 } elseif
{$xin == 22.0 && $yin == 34.0} {
498 set XCOps
(sheetsize
) ansid
499 .output.textent.txtf.sizb configure
-text "ANSI D"
500 } elseif
{$xin == 34.0 && $yin == 44.0} {
501 set XCOps
(sheetsize
) ansie
502 .output.textent.txtf.sizb configure
-text "ANSI E"
504 set XCOps
(sheetsize
) special
505 .output.textent.txtf.sizb configure
-text "Special"
510 #----------------------------------------------------------------------
511 # This procedure configures the output properties window according to
512 # the page mode (full or encapsulated)
513 #----------------------------------------------------------------------
515 proc xcircuit
::setpstype {mode
} {
518 {eps
} { .output.textent.butp configure
-text "Embedded (EPS)"
519 grid remove .output.textent.but7
520 grid remove .output.textent.butf
521 grid remove .output.textent.txtf
523 {full
} {.output.textent.butp configure
-text "Full Page"
524 grid .output.textent.but7
-row 6 -column 3 -pady 5 -ipadx 10
525 grid .output.textent.butf
-row 5 -column 2 -padx 10
526 grid .output.textent.txtf
-row 6 -column 2 -sticky ew
-padx 10
529 set XCOps
(pstype
) $mode
530 xcircuit
::page encapsulation
$mode
533 #----------------------------------------------------------------------
535 proc xcircuit
::dolinks {} {
537 set ilinks
[xcircuit
::page links independent
]
539 set XCOps
(imultiple
) 1
541 set XCOps
(imultiple
) 0
543 if {$ilinks == 1} { set plural
""} else { set plural
"s"}
544 .output.title.imulti configure
-text "$ilinks schematic$plural"
546 if {$XCOps(dmultiple
) == 1} {
547 set dlinks
[xcircuit
::page links dependent
]
551 if {$dlinks == 1} { set plural
""} else { set plural
"s"}
552 .output.title.dmulti configure
-text "$dlinks subcircuit$plural"
555 #----------------------------------------------------------------------
557 proc xcircuit
::setlinksmenu {} {
558 set m .output.textent.butl.linksmenu
560 $m add radio
-label "None" -variable XCOps
(links
) -command \
561 {.output.textent.butl configure
-text None
; \
562 xcircuit
::page filename {}}
563 if {![catch {set plist
[xcircuit
::page list]}]} {
566 set pfile
[xcircuit
::page $p filename]
567 if {"$pfile" != ""} {
568 lappend fnames
$pfile
571 foreach f
[lsort -uniq $fnames] {
572 $m add radio
-label $f -variable XCOps
(links
) \
573 -command ".output.textent.butl configure -text $f ; \
574 xcircuit::page filename $f"
577 .output.textent.butl configure
-text "(change)"
580 #----------------------------------------------------------------------
582 proc xcircuit
::pageupdate { {subcommand
"none"} } {
584 if {[info level
] <= 1} {
585 switch -- $subcommand {
587 .output.bbar.okay configure
-text "Done"
588 .output.bbar.okay configure
-command {wm withdraw .output
}
591 xcircuit
::newpagebutton [xcircuit
::page label]
594 .output.title.field configure
-text \
595 "PostScript output properties (Page [xcircuit::page])"
596 set fname
[xcircuit
::page filename]
597 .output.textent.but1 configure
-text Apply
598 .output.textent.but2 configure
-text Apply
599 .output.textent.but3 configure
-text Apply
600 .output.textent.but4 configure
-text Apply
601 .output.textent.but5 configure
-text Apply
602 .output.textent.but7 configure
-text Apply
603 .output.textent.txt1 delete
0 end
604 .output.textent.txt1 insert
0 $fname
605 .output.textent.txt2 delete
0 end
606 .output.textent.txt2 insert
0 [xcircuit
::page label]
607 .output.textent.txt3 delete
0 end
608 set stext
[format "%g" [xcircuit
::page scale]]
609 .output.textent.txt3 insert
0 $stext
610 .output.textent.txt4 delete
0 end
611 set wtext
[format "%g" [xcircuit
::page width
]]
612 .output.textent.txt4 insert
0 $wtext
613 .output.textent.txt4 insert end
" "
614 .output.textent.txt4 insert end
[xcircuit
::coordstyle get
]
615 .output.textent.txt5 delete
0 end
616 set htext
[format "%g" [xcircuit
::page height
]]
617 .output.textent.txt5 insert
0 $htext
618 .output.textent.txt5 insert end
" "
619 .output.textent.txt5 insert end
[xcircuit
::coordstyle get
]
620 .output.textent.txtf.txtp delete
0 end
621 .output.textent.txtf.txtp insert
0 [xcircuit
::getpagesize]
622 xcircuit
::setpstype [xcircuit
::page encapsulation
]
623 set XCOps
(orient
) [xcircuit
::page orientation
]
624 if {$XCOps(orient
) == 0} {
625 .output.textent.buto configure
-text Portrait
627 .output.textent.buto configure
-text Landscape
630 xcircuit
::setlinksmenu
631 xcircuit
::setsheetsize
633 set XCOps
(autofit
) [xcircuit
::page fit
]
634 if {[string match
*.
* $fname] == 0} {append fname .ps
}
635 if {[glob -nocomplain ${fname
}] == {}} {
636 .output.bbar.okay configure
-text "Write File"
638 .output.bbar.okay configure
-text "Overwrite File"
640 .output.bbar.okay configure
-command \
641 {.output.textent.but1 invoke
; \
642 .output.textent.but2 invoke
; \
643 if {$XCOps(autofit
)} {xcircuit
::page fit true
}; \
644 if {$XCOps(dmultiple
) == 1} {xcircuit
::page save
} else { \
645 xcircuit
::page saveonly
}; wm withdraw .output
}
651 #----------------------------------------------------------------------
652 # Update the GUI based on the schematic class of the current page
653 # This is called internally from the xcircuit code and the function
654 # must be defined, even if it is a null proc.
655 #----------------------------------------------------------------------
657 proc xcircuit
::setsymschem {} {
659 set window
$XCOps(focus)
661 if {[info level
] <= 1} {
662 set schemtype
[xcircuit
::schematic type
]
663 set symschem
[xcircuit
::schematic get
]
664 set m
${window
}.menubar.netlistbutton.netlistmenu
665 switch -- $schemtype {
669 ${window
}.infobar.schem configure
-background red
-foreground white
670 if {$symschem == {}} {
671 ${window
}.infobar.symb configure
-background gray70
\
673 $m entryconfigure
6 -label "Make Matching Symbol" \
674 -command {xcircuit
::promptmakesymbol [page
label]}
675 $m entryconfigure
7 -label "Associate With Symbol" \
676 -command {xcircuit
::symbol associate
}
678 ${window
}.infobar.symb configure
-background white
-foreground black
679 $m entryconfigure
6 -label "Go To Symbol" \
680 -command {xcircuit
::symbol go
}
681 $m entryconfigure
7 -label "Disassociate Symbol" \
682 -command {xcircuit
::symbol disassociate
}
688 ${window
}.infobar.symb configure
-foreground white
689 if {$symschem == {}} {
690 ${window
}.infobar.schem configure
-background gray70
-foreground \
692 $m entryconfigure
6 -label "Make Matching Schematic" \
693 -command {xcircuit
::schematic make
}
694 $m entryconfigure
7 -label "Associate With Schematic" \
695 -command {xcircuit
::schematic associate
}
697 ${window
}.infobar.schem configure
-background white
-foreground black
698 $m entryconfigure
6 -label "Go To Schematic" \
699 -command {xcircuit
::schematic go
}
700 $m entryconfigure
7 -label "Disassociate Schematic" \
701 -command {xcircuit
::schematic disassociate
}
705 switch -- $schemtype {
707 ${window
}.infobar.symb configure
-background red
710 ${window
}.infobar.symb configure
-background green4
;# bboxcolor
713 ${window
}.infobar.symb configure
-background blue2
719 #----------------------------------------------------------------------
720 # Set the coordinate style to inches from cm and vice versa.
721 # This routine avoids switching from fractional to decimal inches
722 # and vice versa if we are already in one of the two inches modes.
724 # with no argument, or argument "get", returns the "short" name
725 # ("cm" or "in") of the style.
726 #----------------------------------------------------------------------
728 proc xcircuit
::coordstyle { { mode get
} } {
729 global XCOps XCWinOps
730 set curstyle
[xcircuit
::config coordstyle
]
733 switch -- $curstyle {
735 xcircuit
::config coordstyle
"decimal inches"
742 switch -- $curstyle {
746 xcircuit
::config coordstyle
"centimeters"
752 switch -- $curstyle {
764 #----------------------------------------------------------------------
766 proc xcircuit
::raiseconsole {} {
768 set window
$XCOps(focus)
771 xcircuit
::consoleontop
772 set cidx
[${window
}.menubar.filebutton.filemenu index
*Console
]
773 ${window
}.menubar.filebutton.filemenu entryconfigure
\
774 $cidx -label "No Console" -command {xcircuit
::lowerconsole}
777 #----------------------------------------------------------------------
779 proc xcircuit
::lowerconsole {} {
781 set window
$XCOps(focus)
783 xcircuit
::consoledown
784 set cidx
[${window
}.menubar.filebutton.filemenu index
*Console
]
785 ${window
}.menubar.filebutton.filemenu entryconfigure
\
786 $cidx -label "Tcl Console" -command {xcircuit
::raiseconsole}
789 #----------------------------------------------------------------------
790 # Command tags---these let the command-line entry functions update the
791 # Tk windows, so that the Tk window structure doesn't need to be hard-
792 # coded into the source.
793 #----------------------------------------------------------------------
795 xcircuit
::tag page
{xcircuit
::pageupdate %1 ; xcircuit
::updateparams}
796 xcircuit
::tag promptsavepage
{xcircuit
::pageupdate ;
797 set wstate
[xcircuit
::getinitstate .output
] ; wm deiconify .output
;
798 if {"$wstate" != "normal"} {xcircuit
::centerwin .output
} ; raise .output
}
799 xcircuit
::tag loadfont
{xcircuit
::newfontbutton %r
}
800 xcircuit
::tag color
{ if {"%1" == "set"} {
801 set XCWinOps
($XCOps(focus),colorval
) %2; set iname img_co
;
802 if {"%2" != "inherit"} {append iname l
%2} ;
803 $XCOps(focus).mainframe.toolbar.bco configure
-image $iname} }
804 xcircuit
::tag border
{if {%# == 2} {
806 dashed
{ set XCWinOps
($XCOps(focus),linestyle
) dashed
}
807 dotted
{ set XCWinOps
($XCOps(focus),linestyle
) dotted
}
808 unbordered
{ set XCWinOps
($XCOps(focus),linestyle
) unbordered
}
809 solid
{ set XCWinOps
($XCOps(focus),linestyle
) solid
}
810 square
{ set XCWinOps
($XCOps(focus),endcaps
) square
}
811 round
{ set XCWinOps
($XCOps(focus),endcaps
) round
}
812 closed
{ set XCWinOps
($XCOps(focus),polyclosed
) closed
}
813 unclosed
{ set XCWinOps
($XCOps(focus),polyclosed
) unclosed
}
814 }} elseif
{%# == 3} {
816 bbox
{ set XCWinOps
($XCOps(focus),bboxtype
) %2}
817 clipmask
{ set XCWinOps
($XCOps(focus),clipmask
) %2}
819 xcircuit
::tag fill
{ foreach i
%N
{ switch -- "$i" {
820 opaque
{ set XCWinOps
($XCOps(focus),opaque
) true
}
821 transparent
{ set XCWinOps
($XCOps(focus),opaque
) false
} 0 - unfilled
822 {set XCWinOps
($XCOps(focus),fillamount
) 0;
823 $XCOps(focus).mainframe.toolbar.bfi configure
-image img_fi
}
824 solid
{set XCWinOps
($XCOps(focus),fillamount
) 100;
825 $XCOps(focus).mainframe.toolbar.bfi configure
-image img_stip100
}
826 default {set XCWinOps
($XCOps(focus),fillamount
) $i;
827 $XCOps(focus).mainframe.toolbar.bfi configure
-image img_stip
$i} } } }
829 xcircuit
::tag select
{if {%N
> 1} {xcircuit
::updateparams; xcircuit
::updatedialog}}
830 xcircuit
::tag unselect
{xcircuit
::updateparams; xcircuit
::updatedialog}
831 xcircuit
::tag schematic
{xcircuit
::setsymschem}
832 xcircuit
::tag symbol
{xcircuit
::setsymschem}
834 xcircuit
::tag parameter
{ if {"%1" == "make"} {set cond true
} else {set cond false
}
838 delete
{xcircuit
::updateparams}
840 replace
{switch -- "%2" {
841 "x position" {set XCWinOps
($XCOps(focus),xposparam
) $cond}
842 "y position" {set XCWinOps
($XCOps(focus),yposparam
) $cond}
843 style
{set XCWinOps
($XCOps(focus),styleparam
) $cond}
844 "start angle" {set XCWinOps
($XCOps(focus),startparam
) $cond}
845 "end angle" {set XCWinOps
($XCOps(focus),endparam
) $cond}
846 anchoring
{set XCWinOps
($XCOps(focus),anchorparam
) $cond}
847 radius
{set XCWinOps
($XCOps(focus),radiusparam
) $cond}
848 "minor axis" {set XCWinOps
($XCOps(focus),minorparam
) $cond}
849 rotation
{set XCWinOps
($XCOps(focus),rotationparam
) $cond}
850 scale {set XCWinOps
($XCOps(focus),scaleparam
) $cond}
851 linewidth
{set XCWinOps
($XCOps(focus),linewidthparam
) $cond}
852 color
{set XCWinOps
($XCOps(focus),colorparam
) $cond}
853 default {xcircuit
::updateparams}
855 default {if {%# == 4} {xcircuit::updateparams}}
858 xcircuit
::tag config
{if {%# == 3} {
860 colorscheme
{set XCWinOps
($XCOps(focus),colorscheme
) [config colorscheme
];
862 bbox
{set XCWinOps
($XCOps(focus),showbbox
) [config bbox
]}
863 editinplace
{set XCWinOps
($XCOps(focus),editinplace
) [config editinplace
]}
864 pinpositions
{set XCWinOps
($XCOps(focus),pinpositions
) [config pinpositions
]}
865 pinattach
{set XCWinOps
($XCOps(focus),pinattach
) [config pinattach
]}
866 technologies
{set XCWinOps
($XCOps(focus),namespaces
) [config technologies
]}
867 hold
{set XCOps
(hold
) [config hold
]}
868 grid {catch {set XCWinOps
($XCOps(focus),showgrid
) [config
grid]}}
869 snap
{catch {set XCWinOps
($XCOps(focus),showsnap
) [config snap
]}}
870 axes
{set XCWinOps
($XCOps(focus),showaxes
) [config axes
]}
871 centering
{set XCWinOps
($XCOps(focus),centerobject
) [config centering
]}
872 manhattan
{set XCWinOps
($XCOps(focus),manhattandraw
) [config manhattan
]}
873 coordstyle
{set XCWinOps
($XCOps(focus),gridstyle
) [config coordstyle
]}
874 boxedit
{set XCWinOps
($XCOps(focus),polyedittype
) [config boxedit
]}
875 pathedit
{set XCWinOps
($XCOps(focus),pathedittype
) [config pathedit
]}
876 technologies
{set XCWinOps
($XCOps(focus),showtech
) [config technologies
]}
877 }} elseif
{(%# == 4) && ("%1" == "filter")} {
878 set XCWinOps
($XCOps(focus),sel_
%2) [config filter
%2]
881 xcircuit
::tag label {if {%# == 3} {
884 set XCWinOps
($XCOps(focus),fontencoding
) %2
885 xcircuit
::newencodingbutton %2
887 family
{if {"%2" != "-all"} {set XCWinOps
($XCOps(focus),fontfamily
) %2}}
888 style
{set XCWinOps
($XCOps(focus),fontstyle
) %2}
893 middle
{set XCWinOps
($XCOps(focus),jvert
) %2}
894 default {set XCWinOps
($XCOps(focus),jhoriz
) %2}
897 justify
{set XCWinOps
($XCOps(focus),justif
) %2}
898 flipinvariant
{set XCWinOps
($XCOps(focus),flipinvariant
) %2}
899 visible
{set XCWinOps
($XCOps(focus),pinvisible
) %2}
900 latex
{set XCWinOps
($XCOps(focus),latexmode
) %2}
901 }} elseif
{(%# == 4) && ("%1" == "anchor")} {
905 middle
{set XCWinOps
($XCOps(focus),jvert
) %2 ;
906 set XCWinOps
($XCOps(focus),jhoriz
) %3}
907 default {set XCWinOps
($XCOps(focus),jhoriz
) %2 ;
908 set XCWinOps
($XCOps(focus),jvert
) %3}
912 #------------------------------
913 # Create the file-list window
914 #------------------------------
916 # First, set the variables associated with toggle and radio buttons
919 toplevel .filelist
-bg beige
920 wm title .filelist
"File List Window"
922 wm protocol .filelist WM_DELETE_WINDOW
{wm withdraw .filelist
}
923 wm withdraw .filelist
925 frame .filelist.listwin
926 frame .filelist.textent
-bg beige
927 frame .filelist.bbar
-bg beige
929 pack .filelist.listwin
-side top
-padx 20 -pady 7 -expand true
-fill both
930 pack .filelist.textent
-side top
-padx 20 -pady 7 -fill x
931 pack .filelist.bbar
-side bottom
-padx 20 -pady 7 -fill x
933 simple .filelist.listwin.win
-bg white
934 simple .filelist.listwin.sb
-width 13 -bg beige
936 grid .filelist.listwin.win
-row 0 -column 0 -sticky news
-padx 1 -pady 1
937 grid .filelist.listwin.sb
-row 0 -column 1 -sticky ns
-padx 1 -pady 1
939 grid columnconfigure .filelist.listwin
0 -weight 1 -minsize 100
940 grid rowconfigure .filelist.listwin
0 -weight 1 -minsize 100
942 frame .filelist.textent.title
-bg beige
943 pack .filelist.textent.title
-side top
-fill x
945 label .filelist.textent.title.field
-text "Select file to load:" -bg beige
946 label .filelist.textent.title.chklabel
-text "Filter" -bg beige
947 checkbutton .filelist.textent.title.filter
-bg beige
-variable XCOps
(filter
) \
948 -command {event generate .filelist.listwin.win
<ButtonPress
> -button 3 ; \
949 event generate .filelist.listwin.win
<ButtonRelease
> -button 3}
951 entry .filelist.textent.txt
-bg white
-relief sunken
-width 50
953 pack .filelist.textent.title.filter
-side right
954 pack .filelist.textent.title.chklabel
-side right
955 pack .filelist.textent.title.field
-side left
956 pack .filelist.textent.txt
-side bottom
-fill x
-expand true
958 button .filelist.bbar.okay
-text Okay
-bg beige
959 button .filelist.bbar.cancel
-text Cancel
-bg beige
-command {wm withdraw .filelist
}
961 pack .filelist.bbar.okay
-side left
-ipadx 10
962 pack .filelist.bbar.cancel
-side right
-ipadx 10
964 # Allow <return> to update or accept entry
965 bind .filelist.textent.txt
<Return
> \
966 {event generate .filelist.listwin.win
<ButtonPress
> -button 2 ; \
967 event generate .filelist.listwin.win
<ButtonRelease
> -button 2}
969 #--------------------------------------
970 # Create the output generating window
971 #--------------------------------------
973 # First, set the variables associated with toggle and radio buttons
975 set XCOps
(imultiple
) 0
976 set XCOps
(dmultiple
) 0 ;# don't save subcircuits with different filenames
977 if {[catch {set XCOps
(technology
)}]} {set XCOps
(technology
) "(user)"}
978 if {[catch {set XCOps
(library
)}]} {set XCOps
(library
) "User Library"}
980 toplevel .output
-bg beige
981 wm title .output
"PostScript Output Properties"
983 wm protocol .output WM_DELETE_WINDOW
{wm withdraw .output
}
986 frame .output.title
-bg beige
987 frame .output.textent
-bg beige
988 frame .output.bbar
-bg beige
990 pack .output.title
-side top
-padx 20 -pady 7 -fill x
991 pack .output.textent
-side top
-padx 20 -pady 7 -fill x
992 pack .output.bbar
-side bottom
-padx 20 -pady 7 -fill x
994 label .output.title.field
-text "PostScript output properties (Page 1):" -bg tan
995 checkbutton .output.title.imulti
-text "1 schematic" -bg beige
\
996 -variable XCOps
(imultiple
) \
997 -command {xcircuit
::dolinks ; \
998 if {$XCOps(imultiple
) == 1} {.output.textent.txt1
\
999 delete
0 end
; .output.textent.but1 configure
-text Apply
; xcircuit
::page \
1000 filename {}; focus .output.textent.txt1
; xcircuit
::dolinks }}
1001 checkbutton .output.title.dmulti
-text "0 subcircuits" -bg beige
\
1002 -variable XCOps
(dmultiple
) \
1003 -command {xcircuit
::dolinks ; .output.textent.but1 configure
-text Apply
; \
1004 if {$XCOps(dmultiple
) == 1} {xcircuit
::page filename {}; \
1005 .output.textent.txt1 delete
0 end
; focus .output.textent.txt1
}; \
1008 pack .output.title.dmulti
-side right
-padx 5
1009 pack .output.title.imulti
-side right
-padx 5
1011 pack .output.title.field
-side left
1013 label .output.textent.lab1
-text "Filename:" -bg beige
1014 label .output.textent.lab2
-text "Page label:" -bg beige
1015 label .output.textent.lab3
-text "Scale:" -bg beige
1016 label .output.textent.lab4
-text "Width:" -bg beige
1017 label .output.textent.lab5
-text "Height:" -bg beige
1018 label .output.textent.lab6
-text "Orientation:" -bg beige
1019 label .output.textent.lab7
-text "Mode:" -bg beige
1020 label .output.textent.lab8
-text "Link to:" -bg beige
1022 entry .output.textent.txt1
-bg white
-relief sunken
-width 20
1023 entry .output.textent.txt2
-bg white
-relief sunken
-width 20
1024 entry .output.textent.txt3
-bg white
-relief sunken
-width 20
1025 entry .output.textent.txt4
-bg white
-relief sunken
-width 20
1026 entry .output.textent.txt5
-bg white
-relief sunken
-width 20
1028 menubutton .output.textent.buto
-text Portrait
-bg beige
\
1029 -menu .output.textent.buto.orientmenu
1030 menubutton .output.textent.butp
-text "Embedded (EPS)" -bg beige
\
1031 -menu .output.textent.butp.psmenu
1032 menubutton .output.textent.butl
-text "(change)" -bg beige
\
1033 -menu .output.textent.butl.linksmenu
1035 checkbutton .output.textent.butf
-text "Auto-fit" -bg beige
\
1036 -variable XCOps
(autofit
) -onvalue true
-offvalue false
\
1037 -command {xcircuit
::page fit
$XCOps(autofit
)}
1038 frame .output.textent.txtf
-bg beige
1039 menubutton .output.textent.txtf.sizb
-text "Sizes" -bg beige
\
1040 -menu .output.textent.txtf.sizb.sizemenu
1041 entry .output.textent.txtf.txtp
-bg white
-relief sunken
-width 14
1043 pack .output.textent.txtf.txtp
-side left
-fill y
1044 pack .output.textent.txtf.sizb
-side left
1046 button .output.textent.but1
-text Apply
-bg beige
\
1047 -command {xcircuit
::page filename [.output.textent.txt1 get
]
1048 if {[llength [xcircuit
::page label]] > 1} {
1049 xcircuit
::page label [file root
[.output.textent.txt1 get
]]};\
1050 .output.textent.but1 configure
-text Okay
}
1051 button .output.textent.but2
-text Apply
-bg beige
\
1052 -command {xcircuit
::page label [.output.textent.txt2 get
];\
1053 .output.textent.but2 configure
-text Okay
}
1054 button .output.textent.but3
-text Apply
-bg beige
\
1055 -command {xcircuit
::page scale [.output.textent.txt3 get
];\
1056 .output.textent.but3 configure
-text Okay
}
1057 button .output.textent.but4
-text Apply
-bg beige
\
1058 -command {xcircuit
::page width
[.output.textent.txt4 get
];\
1059 .output.textent.but4 configure
-text Okay
}
1060 button .output.textent.but5
-text Apply
-bg beige
\
1061 -command {xcircuit
::page height
[.output.textent.txt5 get
];\
1062 .output.textent.but5 configure
-text Okay
}
1063 button .output.textent.but7
-text Apply
-bg beige
\
1064 -command {xcircuit
::page size
[.output.textent.txtf.txtp get
];\
1065 .output.textent.but7 configure
-text Okay
}
1067 bind .output.textent.txt1
<Return
> {.output.textent.but1 invoke
}
1068 bind .output.textent.txt2
<Return
> {.output.textent.but2 invoke
}
1069 bind .output.textent.txt3
<Return
> {.output.textent.but3 invoke
}
1070 bind .output.textent.txt4
<Return
> {.output.textent.but4 invoke
}
1071 bind .output.textent.txt5
<Return
> {.output.textent.but5 invoke
}
1073 grid .output.textent.lab1
-row 0 -column 0 -sticky w
1074 grid .output.textent.lab2
-row 1 -column 0 -sticky w
1075 grid .output.textent.lab3
-row 2 -column 0 -sticky w
1076 grid .output.textent.lab4
-row 3 -column 0 -sticky w
1077 grid .output.textent.lab5
-row 4 -column 0 -sticky w
1078 grid .output.textent.lab6
-row 5 -column 0 -sticky w
1079 grid .output.textent.lab7
-row 6 -column 0 -sticky w
1080 grid .output.textent.lab8
-row 7 -column 0 -sticky w
1082 grid .output.textent.txt1
-row 0 -column 1 -columnspan 2 -sticky ew
-padx 10
1083 grid .output.textent.txt2
-row 1 -column 1 -columnspan 2 -sticky ew
-padx 10
1084 grid .output.textent.txt3
-row 2 -column 1 -columnspan 2 -sticky ew
-padx 10
1085 grid .output.textent.txt4
-row 3 -column 1 -columnspan 2 -sticky ew
-padx 10
1086 grid .output.textent.txt5
-row 4 -column 1 -columnspan 2 -sticky ew
-padx 10
1087 grid .output.textent.buto
-row 5 -column 1 -sticky w
-padx 10
1088 grid .output.textent.butp
-row 6 -column 1 -sticky w
-padx 10
1089 grid .output.textent.butl
-row 7 -column 1 -sticky w
-padx 10
1091 grid .output.textent.but1
-row 0 -column 3 -pady 5 -ipadx 10
1092 grid .output.textent.but2
-row 1 -column 3 -pady 5 -ipadx 10
1093 grid .output.textent.but3
-row 2 -column 3 -pady 5 -ipadx 10
1094 grid .output.textent.but4
-row 3 -column 3 -pady 5 -ipadx 10
1095 grid .output.textent.but5
-row 4 -column 3 -pady 5 -ipadx 10
1097 grid columnconfigure .output.textent
2 -weight 1
1099 button .output.bbar.okay
-text Okay
-bg beige
-command {xcircuit
::page save
; \
1100 wm withdraw .output
}
1101 button .output.bbar.cancel
-text Cancel
-bg beige
-command {wm withdraw .output
}
1103 # Setup simple choice menus for page type and orientation
1104 # First, set the variables associated with the radio buttons. . .
1106 set XCOps
(pstype
) eps
1108 set m
[menu .output.textent.buto.orientmenu
-tearoff 0]
1109 $m add radio
-label "Portrait" -variable XCOps
(orient
) -value 0 -command \
1110 {.output.textent.buto configure
-text Portrait
; \
1111 xcircuit
::page orientation
0}
1112 $m add radio
-label "Landscape" -variable XCOps
(orient
) -value 90 -command \
1113 {.output.textent.buto configure
-text Landscape
; \
1114 xcircuit
::page orientation
90}
1116 set m
[menu .output.textent.butp.psmenu
-tearoff 0]
1117 $m add radio
-label "Embedded (EPS)" -variable XCOps
(pstype
) -value eps
-command \
1118 {xcircuit
::setpstype eps
}
1119 $m add radio
-label "Full Page" -variable XCOps
(pstype
) -value full
-command \
1120 {xcircuit
::setpstype full
}
1122 menu .output.textent.butl.linksmenu
-tearoff 0
1123 xcircuit
::setlinksmenu
1125 pack .output.bbar.okay
-side left
-ipadx 10
1126 pack .output.bbar.cancel
-side right
-ipadx 10
1128 set m
[menu .output.textent.txtf.sizb.sizemenu
-tearoff 0]
1129 $m add radio
-label "Letter (ANSI A)" -variable XCOps
(sheetsize
) \
1130 -value letter
-command \
1131 { xcircuit
::coordstyle inches
; xcircuit
::page size
"8.5 x 11.0 in"}
1132 $m add radio
-label "Legal" -variable XCOps
(sheetsize
) -value legal
-command \
1133 { xcircuit
::coordstyle inches
; xcircuit
::page size
"8.5 x 14.0 in"}
1134 $m add radio
-label "Statement" -variable XCOps
(sheetsize
) -value statement
\
1136 { xcircuit
::coordstyle inches
; xcircuit
::page size
"5.5 x 8.5 in"}
1137 $m add radio
-label "Tabloid (ANSI B)" -variable XCOps
(sheetsize
) \
1138 -value tabloid
-command \
1139 { xcircuit
::coordstyle inches
; xcircuit
::page size
"11.0 x 17.0 in"}
1140 $m add radio
-label "Ledger" -variable XCOps
(sheetsize
) -value ledger
-command \
1141 { xcircuit
::coordstyle inches
; xcircuit
::page size
"17.0 x 11.0 in"}
1142 $m add radio
-label "Folio" -variable XCOps
(sheetsize
) -value folio
-command \
1143 { xcircuit
::coordstyle inches
; xcircuit
::page size
"8.5 x 13.0 in"}
1144 $m add radio
-label "Quarto" -variable XCOps
(sheetsize
) -value quarto
-command \
1145 { xcircuit
::coordstyle inches
; xcircuit
::page size
"8.472 x 10.833 in"}
1146 $m add radio
-label "10x14" -variable XCOps
(sheetsize
) -value tenfourteen
-command \
1147 { xcircuit
::coordstyle inches
; xcircuit
::page size
"10.0 x 14.0 in"}
1148 $m add radio
-label "Executive" -variable XCOps
(sheetsize
) -value executive
-command \
1149 { xcircuit
::coordstyle inches
; xcircuit
::page size
"7.5 x 10.0 in"}
1150 $m add radio
-label "ANSI C" -variable XCOps
(sheetsize
) -value ansic
-command \
1151 { xcircuit
::coordstyle inches
; xcircuit
::page size
"17.0 x 22.0 in"}
1152 $m add radio
-label "ANSI D" -variable XCOps
(sheetsize
) -value ansid
-command \
1153 { xcircuit
::coordstyle inches
; xcircuit
::page size
"22.0 x 34.0 in"}
1154 $m add radio
-label "ANSI E" -variable XCOps
(sheetsize
) -value ansie
-command \
1155 { xcircuit
::coordstyle inches
; xcircuit
::page size
"34.0 x 44.0 in"}
1156 $m add radio
-label "A3" -variable XCOps
(sheetsize
) -value a3
-command \
1157 { xcircuit
::coordstyle centimeters
; xcircuit
::page size
"29.7 x 42.0 cm"}
1158 $m add radio
-label "A4" -variable XCOps
(sheetsize
) -value a4
-command \
1159 { xcircuit
::coordstyle centimeters
; xcircuit
::page size
"21.0 x 29.7 cm"}
1160 $m add radio
-label "A5" -variable XCOps
(sheetsize
) -value a5
-command \
1161 { xcircuit
::coordstyle centimeters
; xcircuit
::page size
"14.82 x 18.43 cm"}
1162 $m add radio
-label "B4" -variable XCOps
(sheetsize
) -value b4
-command \
1163 { xcircuit
::coordstyle centimeters
; xcircuit
::page size
"25.7 x 36.4 cm"}
1164 $m add radio
-label "B5" -variable XCOps
(sheetsize
) -value b5
-command \
1165 { xcircuit
::coordstyle centimeters
; xcircuit
::page size
"18.2 x 25.7 cm"}
1166 $m add radio
-label "Special" -variable XCOps
(sheetsize
) -value special
}
1168 #-----------------------------------------------------------------
1169 # Clear the selection listbox. Create it if it does not exist.
1170 #-----------------------------------------------------------------
1172 proc xcircuit
::make_parameter_listbox {} {
1173 if {[catch {wm state .parameter
}]} {
1174 toplevel .parameter
-bg beige
1175 wm group .parameter .
1176 wm withdraw .parameter
1178 label .parameter.title
-text "Parameters" -bg beige
1179 label .parameter.keytitle
-text "Key" -bg beige
1180 label .parameter.valtitle
-text "Value" -bg beige
1182 listbox .parameter.keylist
-bg white
1183 listbox .parameter.vallist
-bg white
1184 listbox .parameter.parvals
-bg white
1186 # Code to get the listboxes to scroll in synchrony
1187 bind .parameter.keylist
<Button-4
> {xcircuit
::paramscroll -1}
1188 bind .parameter.keylist
<Button-5
> {xcircuit
::paramscroll 1}
1189 bind .parameter.vallist
<Button-4
> {xcircuit
::paramscroll -1}
1190 bind .parameter.vallist
<Button-5
> {xcircuit
::paramscroll 1}
1191 bind .parameter.parvals
<Button-4
> {xcircuit
::paramscroll -1}
1192 bind .parameter.parvals
<Button-5
> {xcircuit
::paramscroll 1}
1193 # Also bind to the mouse wheel (Windows-specific, generally)
1194 bind .parameter.keylist
<MouseWheel
> {xcircuit
::paramscroll %D
}
1195 bind .parameter.vallist
<MouseWheel
> {xcircuit
::paramscroll %D
}
1196 bind .parameter.parvals
<MouseWheel
> {xcircuit
::paramscroll %D
}
1198 button .parameter.dismiss
-text "Dismiss" -bg beige
\
1199 -command {wm withdraw .parameter
}
1201 menubutton .parameter.delete
-text "Delete..." -bg beige
\
1202 -menu .parameter.delete.deleteparam
1203 menu .parameter.delete.deleteparam
-tearoff 0
1205 menubutton .parameter.create
-text "New..." -bg beige
\
1206 -menu .parameter.create.newparam
1207 menu .parameter.create.newparam
-tearoff 0
1208 .parameter.create.newparam add command
-label "Substring" -command \
1209 "xcircuit::promptmakeparam substring"
1210 .parameter.create.newparam add command
-label "Numeric" -command \
1211 "xcircuit::promptmakeparam numeric"
1212 .parameter.create.newparam add command
-label "Expression" -command \
1213 "xcircuit::promptmakeparam expression"
1215 labelframe .parameter.valedit
-text "Edit value" -bg beige
1216 entry .parameter.valedit.
entry -textvariable new_paramval
-bg white
1217 button .parameter.valedit.apply
-text "Apply" -bg beige
1219 pack .parameter.valedit.
entry -side left
-fill x
-expand true
-padx 2
1220 pack .parameter.valedit.apply
-side top
1222 grid .parameter.title
-row 0 -column 0 -columnspan 2 -sticky news
1223 grid .parameter.keytitle
-row 1 -column 0 -sticky news
1224 grid .parameter.keylist
-row 2 -column 0 -sticky news
1225 grid .parameter.valtitle
-row 1 -column 1 -sticky news
1226 grid .parameter.vallist
-row 2 -column 1 -sticky news
1227 grid .parameter.parvals
-row 2 -column 1 -sticky news
1229 grid .parameter.valedit
-row 3 -column 0 -columnspan 2 -padx 2 \
1232 grid .parameter.create
-row 4 -column 1 -sticky ns
1233 grid .parameter.delete
-row 4 -column 0 -sticky ns
1234 grid .parameter.dismiss
-row 5 -column 0 -columnspan 2 -sticky ns
1236 grid rowconfigure .parameter
2 -weight 1
1237 grid columnconfigure .parameter
0 -weight 1
1238 grid columnconfigure .parameter
1 -weight 2
1240 raise .parameter.vallist
1242 bind .parameter
<Escape
> {wm withdraw .parameter
}
1243 bind .parameter.valedit.
entry <Return
> {.parameter.valedit.apply invoke
}
1247 #-----------------------------------------------------------------
1248 # Scroll all listboxes in the .parameter window at the same
1249 # time, in reponse to any one of them receiving a scroll event.
1250 #-----------------------------------------------------------------
1252 proc xcircuit
::paramscroll {value
} {
1254 set idx
[.parameter.keylist nearest
0]
1256 if {$tcl_platform(platform
) == "windows"} {
1257 set idx
[expr {$idx + $value / 120}]
1259 set idx
[expr {$idx + $value}]
1262 .parameter.keylist yview
$idx
1263 .parameter.vallist yview
$idx
1264 .parameter.parvals yview
$idx
1266 # Important! This prohibits the default binding actions.
1270 # Update the dialog box, if it has been left visible
1271 # (Corrected 2/4/12: Don't delete contents except in these specific cases!)
1273 proc xcircuit
::updatedialog {{w dialog
}} {
1275 if {[xcircuit
::getinitstate .
${w
}] == "normal"} {
1276 switch -- $XCOps(${w
}) {
1278 set btext
[format "%g" [lindex [xcircuit
::border get
] 0]]
1279 .
${w
}.textent.txt delete
0 end
1280 .
${w
}.textent.txt insert
0 $btext
1283 set cscale
[xcircuit
::label scale]
1284 .
${w
}.textent.txt delete
0 end
1285 .
${w
}.textent.txt insert
0 $cscale
1288 set selects
[xcircuit
::select]
1290 set cscale
[xcircuit
::element scale]
1291 .
${w
}.textent.txt delete
0 end
1292 .
${w
}.textent.txt insert
0 $cscale
1299 proc xcircuit
::makedialogline {dframe textline
{w dialog
}} {
1300 if {[catch {frame .
${w
}.
${dframe
} -bg beige
}]} {
1301 .
${w
}.
${dframe
}.title.field configure
-text ${textline
}
1303 pack .
${w
}.
${dframe
} -side top
-padx 20 -pady 7 -fill x
1305 frame .
${w
}.
${dframe
}.title
-bg beige
1306 entry .
${w
}.
${dframe
}.txt
-bg white
-relief sunken
-width 50
1308 pack .
${w
}.
${dframe
}.title
-side top
-fill x
1309 pack .
${w
}.
${dframe
}.txt
-side bottom
-fill x
-expand true
1311 label .
${w
}.
${dframe
}.title.field
-text ${textline
} -bg beige
1312 pack .
${w
}.
${dframe
}.title.field
-side left
1316 proc xcircuit
::removedialogline {dframe
{w dialog
}} {
1318 pack forget .
${w
}.
${dframe
}
1319 destroy .
${w
}.
${dframe
}
1323 #--------------------------------------------
1324 # Create a simple popup prompt window
1325 # With "Apply", "Okay", and "Cancel" buttons
1326 #--------------------------------------------
1328 proc make_simple_dialog
{name
} {
1330 toplevel ${window
} -bg beige
1331 wm title
${window
} "Dialog Box"
1332 wm group
${window
} .
1333 wm protocol
${window
} WM_DELETE_WINDOW
[subst {wm withdraw
${window
}}]
1334 wm withdraw
${window
}
1335 set XCOps
(${name
}) 0
1337 xcircuit
::makedialogline textent
"Select file to load:" ${name
}
1339 frame ${window
}.bbar
-bg beige
1340 pack ${window
}.bbar
-side bottom
-padx 20 -pady 7 -fill x
1342 button ${window
}.bbar.okay
-text Okay
-bg beige
\
1343 -command [subst {${window
}.bbar.apply invoke
;\
1344 wm withdraw
${window
}}]
1345 button ${window
}.bbar.apply
-text Apply
-bg beige
1346 button ${window
}.bbar.cancel
-text Cancel
-bg beige
-command \
1347 [subst {wm withdraw
${window
}}]
1349 bind ${window
}.textent.txt
<Return
> [subst {${window
}.bbar.apply invoke
}]
1351 pack ${window
}.bbar.okay
-side left
-ipadx 10
1352 pack ${window
}.bbar.apply
-side left
-ipadx 10
1353 pack ${window
}.bbar.cancel
-side right
-ipadx 10
1356 #--------------------------------------
1357 # Create a query prompt window with
1358 # "Okay" and "Cancel" buttons, and a
1359 # "Select:" title message
1360 #--------------------------------------
1362 proc make_query_dialog
{name
} {
1364 toplevel ${window
} -bg beige
1365 wm title
${window
} "Query Dialog Box"
1366 wm group
${window
} .
1367 wm protocol
${window
} WM_DELETE_WINDOW
[subst {wm withdraw
${window
}}]
1368 wm withdraw
${window
}
1370 frame ${window
}.title
-bg beige
1371 frame ${window
}.bbar
-bg beige
1373 pack ${window
}.title
-side top
-padx 20 -pady 7 -fill x
1374 pack ${window
}.bbar
-side bottom
-padx 20 -pady 7 -fill x
1376 label ${window
}.title.field
-text "Select:" -bg beige
1377 pack ${window
}.title.field
-side left
1379 button ${window
}.bbar.okay
-text Okay
-bg beige
1380 button ${window
}.bbar.cancel
-text Cancel
-bg beige
-command \
1381 [subst {wm withdraw
${window
}}]
1383 pack ${window
}.bbar.okay
-side left
-ipadx 10
1384 pack ${window
}.bbar.cancel
-side right
-ipadx 10
1387 make_query_dialog query
1388 make_simple_dialog dialog
1389 make_simple_dialog savetech
1390 make_simple_dialog makesymbol
1392 #--------------------------------------------------------
1393 # Generate all of the menu cascades
1394 # Most commands reference XCircuit internal routines
1395 #--------------------------------------------------------
1397 # Supporting procedures
1399 proc xcircuit
::printstring {stringlist
} {
1401 foreach i
$stringlist {
1402 switch -- [lindex $i 0] {
1403 Text
{append p
[lindex $i 1]}
1405 Quarter
{append p
" "}
1411 proc xcircuit
::printanchor {anchor
} {
1412 switch [expr {$anchor & 3}] {
1417 switch [expr {$anchor & 12}] {
1418 0 {append p
" bottom"}
1419 4 {append p
" middle"}
1420 12 {append p
" top"}
1425 proc xcircuit
::labelmakeparam {} {
1427 if {[xcircuit
::select] > 0} { ;# this should be true. . .
1428 set XCOps
(dialog
) paramname
1429 xcircuit
::removedialogline textent2 dialog
;# default is the selected text
1430 .dialog.bbar.apply configure
-command \
1431 [subst {xcircuit
::parameter make substring
\[.dialog.textent.txt get
\];\
1432 xcircuit
::updateparams substring
}]
1433 .dialog.textent.title.field configure
-text "Parameter name:"
1434 .dialog.textent.txt delete
0 end
1435 xcircuit
::popupdialog
1439 proc xcircuit
::promptmakeparam {{mode substring
}} {
1442 set XCOps
(dialog
) paramdefault
1443 if {$mode == "label"} {set mode substring
}
1444 xcircuit
::makedialogline textent2
"Default value:" dialog
1445 .dialog.bbar.apply configure
-command \
1446 [subst {xcircuit
::parameter make
$mode \
1447 \[.dialog.textent.txt get
\] \[.dialog.textent2.txt get
\] -forward; \
1448 xcircuit
::removedialogline textent2 dialog
; \
1449 xcircuit
::updateparams $mode}]
1450 .dialog.textent.title.field configure
-text \
1452 .dialog.textent.txt delete
0 end
1453 xcircuit
::popupdialog
1456 #----------------------------------------------------------------------
1457 # This procedure generates a new index number for list selection
1458 # inside a parameter, using "regsub" and "subst" to replace the
1459 # old index with the new one. This procedure depends on the
1460 # existance of the listbox widget ".paramlist.plist".
1461 #----------------------------------------------------------------------
1463 proc xcircuit
::renewparam {key y args
} {
1464 set newidx
[.parameter.parvals nearest
$y]
1465 set current
[join [xcircuit
::parameter get
$key ${args
} -verbatim]]
1466 regsub {(.
*lindex +{.
*} +)([0-9]+)(.
*)} $current {\1$newidx\3} tmpkey
1467 set newkey
[subst -nocommands -nobackslashes "$tmpkey"]
1468 xcircuit
::parameter set $key $newkey $args
1471 #----------------------------------------------------------------------
1472 # Prompt for a new value of a parameter. Do some sophisticated checking
1473 # for parameters that declare a list of possible options, and handle
1474 # that situation separately.
1475 #----------------------------------------------------------------------
1477 proc xcircuit
::changeparamvalue {key current args
} {
1479 .parameter.valedit.
entry delete
0 end
1480 if {[xcircuit
::parameter type
$key -forward] == "expression"} {
1482 # Use regexp processing to find if there is some part of the expression
1483 # that chooses a single fixed value from a list. If so, generate a
1484 # listbox to present the choices in the list.
1486 set loccurnt
[join [xcircuit
::parameter get
$key ${args
} -verbatim]]
1487 if {[regexp {.
*lindex +{(.
*)} +[0-9]+.
*} $loccurnt qall sellist
] > 0} {
1488 .parameter.parvals delete
0 end
1489 raise .parameter.parvals
1491 foreach item
$sellist {
1492 .parameter.parvals insert end
$item
1495 #Abort the parameter value selection
1496 bind .parameter.parvals
<ButtonRelease-3
> {raise .parameter.vallist
}
1498 bind .parameter.parvals
<ButtonRelease-1
> [subst {xcircuit
::renewparam \
1500 .parameter.keylist configure
-state normal
;\
1501 xcircuit
::updateparams ;\
1502 raise .parameter.vallist
}]
1504 .parameter.valedit.
entry delete
0 end
1505 .parameter.valedit.
entry insert
0 $loccurnt
1508 # If the parameter is an expression but not a choice-list type, then
1509 # we had better print the verbatim entry, or people will just get
1510 # confused when the value becomes "invalid result:..."
1511 .parameter.valedit.
entry insert
0 $loccurnt
1514 .parameter.valedit.
entry insert
0 $current
1516 focus .parameter.valedit.
entry
1517 .parameter.valedit.apply configure
\
1518 -command [subst {xcircuit
::parameter set \
1519 $key \[.parameter.valedit.
entry get
\] \
1520 ${args
}; xcircuit
::updateparams}]
1523 #----------------------------------------------------------------------
1525 proc xcircuit
::updateparams { {mode
{substring numeric expression
}} } {
1527 if {[catch {wm state .parameter
}]} {return}
1529 # Avoid infinite recursion if a parameter invokes updateparams
1530 # (e.g., any "page" command in a parameter will do this!)
1532 if {$mode != "force"} {
1533 if {[info level
] > 1} {return}
1535 set mode
{substring numeric expression
}
1538 while {[.parameter.keylist size
] > 0} {.parameter.keylist delete
0}
1539 while {[.parameter.vallist size
] > 0} {.parameter.vallist delete
0}
1541 .parameter.delete.deleteparam delete
0 last
1543 if {$mode == "none"} {
1544 set dlist
[xcircuit
::parameter get
-forward]
1548 set dlist
[concat $dlist [parameter get
$i -forward]]
1552 # Ensure that the parvals list is not present
1553 if {[select
] == 0} { lower .parameter.parvals
}
1555 # All selections will be lost, so make sure that the value field is clear
1556 .parameter.valedit.
entry delete
0 end
1557 .parameter.valedit.apply configure
-command {}
1559 bind .parameter.vallist
<ButtonRelease-1
> {
1560 set kidx
[.parameter.keylist nearest
%y
]; \
1561 xcircuit
::changeparamvalue \
1562 [.parameter.keylist get
$kidx] [.parameter.vallist get
$kidx] \
1565 ;#The insertion of parameters should only be applicable in "text" mode
1566 bind .parameter.keylist
<ButtonRelease-1
> {
1567 set kidx
[.parameter.keylist nearest
%y
]; \
1568 if {[string last
"text" [xcircuit
::eventmode]] >= 0} {
1569 label insert parameter
[.parameter.keylist get
$kidx]
1573 if {[catch {set oname
[xcircuit
::object name
]}]} {
1574 .parameter.title configure
-text "Parameters"
1576 .parameter.title configure
-text "Parameters of $oname"
1579 set p_name
[lindex $i 0]
1580 set p_val
[lindex $i 1]
1581 .parameter.delete.deleteparam add command
-label $p_name -command \
1582 "xcircuit::parameter delete $p_name -forward"
1583 .parameter.keylist insert end
$p_name
1584 switch -- [xcircuit
::parameter type
$p_name -forward] {
1586 .parameter.vallist insert end
[xcircuit
::printstring $p_val]
1589 .parameter.vallist insert end
[xcircuit
::printanchor $p_val]
1592 .parameter.vallist insert end
$p_val
1598 #----------------------------------------------------------------------
1600 proc xcircuit
::prompteditparams {} {
1601 set wstate
[xcircuit
::getinitstate .parameter
]
1602 xcircuit
::make_parameter_listbox
1603 xcircuit
::updateparams force
1604 if {"$wstate" != "normal"} {
1605 wm deiconify .parameter
1606 xcircuit
::centerwin .parameter
1611 #----------------------------------------------------------------------
1613 proc xcircuit
::promptmakesymbol {{name
""}} {
1616 set XCOps
(dialog
) makeobject
1617 .makesymbol.bbar.apply configure
-command \
1618 {if {[string first
"Page " [page
label]] >= 0} { \
1619 page
label [.makesymbol.textent.txt get
]}; \
1620 xcircuit
::symbol make
[.makesymbol.textent.txt get
] $XCOps(library
)}
1621 xcircuit
::removedialogline textent2 makesymbol
1622 .makesymbol.textent.title.field configure
-text "Name for new object:"
1623 .makesymbol.textent.txt delete
0 end
1624 .makesymbol.textent.txt insert
0 $name
1625 xcircuit
::popupdialog .makesymbol
1626 xcircuit
::addliblist .makesymbol Place in
: "
1629 #----------------------------------------------------------------------
1631 proc xcircuit::prompttargettech {{name ""}} {
1634 set XCOps(dialog) targettech
1635 .savetech.bbar.apply configure -command { \
1636 set selects [xcircuit::select]; \
1637 if {$selects > 0} { \
1638 if {[catch {set techname [.savetech.textent2.txt get]}]} {\
1639 set techname $XCOps(technology)}; \
1640 technology objects $techname [.savetech.textent.txt get]}\
1642 xcircuit::removedialogline textent2 savetech
1643 .savetech.textent.title.field configure -text "Objects to move
:"
1644 .savetech.textent.txt delete 0 end
1645 .savetech.textent.txt insert 0 $name
1646 xcircuit::popupdialog
1647 xcircuit::addtechlist .savetech "Target technology
: "
1649 # Add an additional selection to the tech menu for adding a new
1650 # technology namespace. This is relevant only to "prompttargettech
".
1652 .savetech.techself.techselect.menu add \
1653 command -label "Add New Tech
" -command \
1654 "xcircuit
::makedialogline textent2
{New tech name
:}" savetech
1657 #----------------------------------------------------------------------
1659 proc xcircuit::promptelementsize {} {
1661 if {![catch {set cscale [xcircuit::element scale]}]} {
1662 set XCOps(dialog) elementscale
1663 .dialog.bbar.apply configure -command \
1664 {xcircuit::element scale [.dialog.textent.txt get]}
1665 .dialog.textent.title.field configure -text "Element
scale:"
1666 .dialog.textent.txt delete 0 end
1667 .dialog.textent.txt insert 0 $cscale
1668 xcircuit::popupdialog
1672 #----------------------------------------------------------------------
1674 proc xcircuit::promptborderwidth {} {
1676 .dialog.textent.txt delete 0 end
1677 set XCOps(dialog) linewidth
1678 set elist [xcircuit::select get]
1679 if {[llength $elist] == 0} {
1680 .dialog.bbar.apply configure -command \
1681 [subst {config focus [config focus] ;\
1682 xcircuit::border set \[.dialog.textent.txt get\]}]
1683 .dialog.textent.title.field configure -text "Default linewidth
scale:"
1684 set btext [format "%g
" [xcircuit::border get]]
1685 .dialog.textent.txt insert 0 $btext
1687 .dialog.bbar.apply configure -command \
1688 [subst {config focus [config focus] ;\
1689 xcircuit::border set \[.dialog.textent.txt get \]}]
1690 .dialog.textent.title.field configure -text "Element linewidth
:"
1691 set btext [format "%g
" [lindex [xcircuit::border get] 0]]
1692 .dialog.textent.txt insert 0 $btext
1694 xcircuit::popupdialog
1697 #----------------------------------------------------------------------
1699 proc xcircuit::promptlinewidth {} {
1701 set XCOps(dialog) linescale
1702 .dialog.bbar.apply configure -command \
1703 [subst {config focus [config focus] ;\
1704 xcircuit::config linewidth \[.dialog.textent.txt get \]}]
1705 .dialog.textent.title.field configure -text "Page linewidth scaling
:"
1706 .dialog.textent.txt delete 0 end
1707 set ltext [format "%g
" [xcircuit::config linewidth]]
1708 .dialog.textent.txt insert 0 $ltext
1709 xcircuit::popupdialog
1712 #----------------------------------------------------------------------
1714 proc xcircuit::promptdrawingscale {} {
1716 set XCOps(dialog) drawingscale
1717 .dialog.bbar.apply configure -command \
1718 {xcircuit::config drawingscale [.dialog.textent.txt get]}
1719 .dialog.textent.title.field configure -text "Drawing
scale:"
1720 .dialog.textent.txt delete 0 end
1721 .dialog.textent.txt insert 0 [xcircuit::config drawingscale]
1722 xcircuit::popupdialog
1725 #----------------------------------------------------------------------
1727 proc xcircuit::promptgridspace {} {
1728 .dialog.bbar.apply configure -command \
1729 {xcircuit::config grid spacing [.dialog.textent.txt get]}
1730 .dialog.textent.title.field configure -text "Grid spacing
:"
1731 .dialog.textent.txt delete 0 end
1732 .dialog.textent.txt insert 0 [xcircuit::config grid space]
1733 xcircuit::popupdialog
1736 #----------------------------------------------------------------------
1738 proc xcircuit::promptsnapspace {} {
1740 set XCOps(dialog) snapspace
1741 .dialog.bbar.apply configure -command \
1742 {xcircuit::config snap spacing [.dialog.textent.txt get]}
1743 .dialog.textent.title.field configure -text "Snap spacing
:"
1744 .dialog.textent.txt delete 0 end
1745 .dialog.textent.txt insert 0 [xcircuit::config snap space]
1746 xcircuit::popupdialog
1749 #----------------------------------------------------------------------
1751 proc xcircuit::promptmakeobject {} {
1753 if {[xcircuit::select] > 0} {
1754 set XCOps(dialog) makeobject
1755 .dialog.bbar.apply configure -command \
1756 {if {[select get] != {}} {\
1757 if {[.dialog.textent.txt get] == ""} {\
1758 .dialog.textent.title.field configure -text "Please enter a name
" }\
1759 elseif {[catch {xcircuit::object handle [.dialog.textent.txt get]}]} {\
1760 xcircuit::object make [.dialog.textent.txt get] $XCOps(library)}\
1761 else {.dialog.textent.title.field configure -text \
1762 "Name already used. Choose another name
" ; .dialog.textent.txt \
1764 .dialog.textent.title.field configure -text "Name
for new object
"
1765 .dialog.textent.txt delete 0 end
1766 if {$XCOps(technology) != "(user
)"} {
1767 .dialog.textent.txt insert 0 "${XCOps
(technology
)}::"
1769 xcircuit::popupdialog
1770 xcircuit::addtechlist .dialog "Technology
: " {(user)} prefix
1771 xcircuit::addliblist .dialog "Place in
: "
1776 #----------------------------------------------------------------------
1778 proc xcircuit::promptreplaceobject {} {
1780 if {[xcircuit::select] > 0} {
1781 set XCOps(dialog) replaceobject
1782 .dialog.bbar.apply configure -command \
1783 {xcircuit::element selected object [.dialog.textent.txt get]}
1784 .dialog.textent.title.field configure -text "Name of replacement object
"
1785 .dialog.textent.txt delete 0 end
1786 xcircuit::popupdialog
1790 #----------------------------------------------------------------------
1792 proc xcircuit::promptloadlibrary {} {
1795 .filelist.bbar.okay configure -command \
1796 {xcircuit::library [.filelist.libself.libselect cget -text] load \
1797 [.filelist.textent.txt get]; wm withdraw .filelist}
1798 .filelist.listwin.win configure -data "lps
"
1799 .filelist.textent.title.field configure -text "Select technology
file to
load:"
1800 .filelist.textent.txt delete 0 end
1801 xcircuit::popupfilelist
1802 xcircuit::addliblist .filelist "Load to which library page
: "
1805 #----------------------------------------------------------------------
1807 proc xcircuit::promptsavetech {} {
1810 set XCOps(dialog) techname
1811 .savetech.bbar.apply configure -command \
1812 {xcircuit::technology save [.savetech.techself.techselect cget -text] \
1813 [.savetech.textent.txt get]}
1814 .savetech.textent.title.field configure -text "Filename to save technology as
:"
1815 .savetech.textent.txt delete 0 end
1816 xcircuit::popupdialog .savetech
1817 xcircuit::addtechlist .savetech "Save which technology
: " {(user)} true
1819 catch {set fname [technology filename $XCOps(technology)]}
1820 if {$fname == "(no associated
file)"} {
1821 set fname $XCOps(technology).lps
1823 .savetech.textent.txt insert 0 $fname
1826 #----------------------------------------------------------------------
1828 proc xcircuit::promptaddlibrary {} {
1830 set XCOps(dialog) libname
1831 .dialog.bbar.apply configure -command \
1832 {xcircuit::library make [.dialog.textent.txt get]}
1833 .dialog.textent.title.field configure -text "Name of new library page
:"
1834 .dialog.textent.txt delete 0 end
1835 xcircuit::popupdialog
1838 #----------------------------------------------------------------------
1840 proc xcircuit::promptloadfile {} {
1841 .filelist.bbar.okay configure -command \
1842 {xcircuit::page load [.filelist.textent.txt get] -replace \
1843 [.filelist.techself.techselect cget -text] \
1844 -target $XCOps(library); wm withdraw .filelist}
1845 .filelist.listwin.win configure -data "ps eps
"
1846 .filelist.textent.title.field configure -text "Select
file to
load:"
1847 .filelist.textent.txt delete 0 end
1848 xcircuit::popupfilelist
1849 xcircuit::addtechlist .filelist "Replace from
: " {(user) all none}
1850 xcircuit::addliblist .filelist "Target library
: "
1853 #----------------------------------------------------------------------
1855 proc xcircuit::promptimportspice {} {
1856 .filelist.bbar.okay configure -command \
1857 {xcircuit::page import spice \
1858 [.filelist.textent.txt get]; wm withdraw .filelist}
1859 .filelist.listwin.win configure -data "spice spc spi ckt sp cir
"
1860 .filelist.textent.title.field configure -text "Select SPICE
file to import
:"
1861 .filelist.textent.txt delete 0 end
1862 xcircuit::popupfilelist
1865 #----------------------------------------------------------------------
1867 proc xcircuit::promptimportfile {} {
1868 .filelist.bbar.okay configure -command \
1869 {xcircuit::page import xcircuit \
1870 [.filelist.textent.txt get]; wm withdraw .filelist}
1871 .filelist.listwin.win configure -data "ps eps
"
1872 .filelist.textent.title.field configure -text "Select
file to import
:"
1873 xcircuit::popupfilelist
1876 #----------------------------------------------------------------------
1878 proc xcircuit::promptimportbackground {} {
1879 .filelist.bbar.okay configure -command \
1880 {xcircuit::page import background \
1881 [.filelist.textent.txt get]; wm withdraw .filelist}
1882 .filelist.listwin.win configure -data "ps eps
"
1883 .filelist.textent.title.field configure -text "Select
file to use as background
:"
1884 .filelist.textent.txt delete 0 end
1885 xcircuit::popupfilelist
1888 #----------------------------------------------------------------------
1889 # Convert a graphic image using ImageMagick "convert
" (if available)
1890 #----------------------------------------------------------------------
1892 proc xcircuit::convertgraphic {filename} {
1893 set fileext [file extension $filename]
1894 set fileroot [file rootname $filename]
1896 switch -- $fileext {
1901 exec convert $filename ${fileroot}.ppm
1908 exec convert -density 300x300 $filename ${fileroot}.ppm
1911 xcircuit::graphic make ${fileroot}.ppm {0 0} 1;
1912 if {$temp == true} {
1913 file delete ${fileroot}.ppm
1917 #----------------------------------------------------------------------
1919 proc xcircuit::promptimportgraphic {} {
1920 if {![catch {exec convert -version}]} {
1921 .filelist.bbar.okay configure -command \
1922 {xcircuit::convertgraphic [.filelist.textent.txt get];
1923 refresh; wm withdraw .filelist}
1924 .filelist.listwin.win configure -data "pnm ppm gif jpg png
"
1926 .filelist.bbar.okay configure -command \
1927 {xcircuit::graphic make [.filelist.textent.txt get] {0 0} 1;
1928 refresh; wm withdraw .filelist}
1929 .filelist.listwin.win configure -data "pnm ppm
"
1931 .filelist.textent.title.field configure -text "Select graphic
image file:"
1932 .filelist.textent.txt delete 0 end
1933 xcircuit::popupfilelist
1936 #----------------------------------------------------------------------
1938 proc xcircuit::promptexecscript {} {
1939 .filelist.bbar.okay configure -command \
1940 {source [.filelist.textent.txt get]; wm withdraw .filelist}
1941 .filelist.listwin.win configure -data "tcl xcircuitrc
"
1942 .filelist.textent.title.field configure -text "Select script to execute
:"
1943 xcircuit::popupfilelist
1946 #----------------------------------------------------------------------
1948 proc xcircuit::prompttextsize {} {
1950 set XCOps(dialog) textscale
1951 .dialog.bbar.apply configure -command \
1952 {xcircuit::label scale [.dialog.textent.txt get]}
1953 .dialog.textent.title.field configure -text "Text
scale:"
1954 .dialog.textent.txt delete 0 end
1955 set stext [format "%g
" [xcircuit::label scale]]
1956 .dialog.textent.txt insert 0 $stext
1957 xcircuit::popupdialog
1960 #----------------------------------------------------------------------
1961 # add a library list widget to a dialog box
1962 #----------------------------------------------------------------------
1964 proc xcircuit::addliblist {w {prompt "Target
: "}} {
1968 label ${w}.libself.title -text $prompt -bg beige
1970 set liblist [library directory list]
1972 menubutton ${w}.libself.libselect -menu ${w}.libself.libselect.menu -relief groove
1973 menu ${w}.libself.libselect.menu -tearoff 0
1974 foreach j $liblist {
1975 ${w}.libself.libselect.menu add \
1976 radio -label "$j" -variable XCOps(library) -value \
1977 "$j" -command "${w
}.libself.libselect configure
-text {$j}"
1979 ${w}.libself.libselect configure -text $XCOps(library)
1981 pack ${w}.libself.title -side left
1982 pack ${w}.libself.libselect -side left
1983 pack ${w}.libself -side top -anchor w -padx 20
1986 #----------------------------------------------------------------------
1987 # Add a technology list widget to a dialog box
1989 # If "update" is "true
", then a selection of a technology in the list
1990 # will update the text entry window contents with the corresponding
1991 # filename. If "update" is "prefix
", then a selection of a technology
1992 # in the list will update the text entry window contents with the
1993 # technology namespace prefix corresponding to the selected technology.
1994 # If "update" is "false
", then selecting the technology will set the
1995 # global variable XCOps(technology) but will not alter the window
1997 #----------------------------------------------------------------------
1999 proc xcircuit::addtechlist {w {prompt "Technology
: "} {endlist {}} {update {false}}} {
2003 label ${w}.techself.title -text $prompt -bg beige
2005 set techlist [technology list]
2006 foreach j $endlist { lappend techlist $j }
2008 menubutton ${w}.techself.techselect -menu ${w}.techself.techselect.menu -relief groove
2009 menu ${w}.techself.techselect.menu -tearoff 0
2010 foreach j $techlist {
2011 if {$update == true} {
2013 catch {set fname [technology filename "$j"]}
2015 ${w}.techself.techselect.menu add \
2016 radio -label "$j" -variable XCOps(technology) -value \
2017 "$j" -command "${w
}.techself.techselect configure
-text {$j} ; \
2018 ${w
}.textent.txt delete
0 end
; ${w
}.textent.txt insert
0 {$fname}"
2019 } elseif {$update == "prefix
"} {
2020 if {$j != {} && $j != "(user
)"} {
2025 ${w}.techself.techselect.menu add \
2026 radio -label "$j" -variable XCOps(technology) -value \
2027 "$j" -command [subst {${w}.techself.techselect configure -text {$j} ; \
2028 set pfixend \[string last :: \[${w}.textent.txt get\]\] ; \
2029 if {\$pfixend < 0} {set pfixend 0} else {incr pfixend 2} ; \
2030 ${w}.textent.txt delete 0 \$pfixend ; \
2031 ${w}.textent.txt insert 0 {$tpfix}}]
2033 ${w}.techself.techselect.menu add \
2034 radio -label "$j" -variable XCOps(technology) -value \
2035 "$j" -command "${w
}.techself.techselect configure
-text {$j}"
2038 ${w}.techself.techselect configure -text $XCOps(technology)
2040 pack ${w}.techself.title -side left
2041 pack ${w}.techself.techselect -side left
2042 pack ${w}.techself -side right -anchor w -padx 20
2045 #----------------------------------------------------------------------
2047 proc xcircuit::removelists {w} {
2051 pack forget ${w}.libself
2052 destroy ${w}.libself
2055 pack forget ${w}.techself
2056 destroy ${w}.techself
2060 #----------------------------------------------------------------------
2061 # newcolorbutton is called internally to xcircuit---don't mess with it!
2062 #----------------------------------------------------------------------
2064 proc xcircuit::newcolorbutton {r g b idx} {
2065 global XCWinOps XCIRCUIT_LIB_DIR
2067 set colorrgb [format "#%04X%04X%04X" $r $g $b]
2068 image create
bitmap img_col
$idx -foreground $colorrgb -file \
2069 ${XCIRCUIT_LIB_DIR
}/pixmaps
/solid.xbm
2071 foreach window
[config windownames
] {
2072 set frame [winfo top
$window]
2073 ${frame}.menubar.optionsbutton.optionsmenu.elementsmenu.colormenu
\
2074 add radio
-image img_col
$idx -activebackground $colorrgb \
2075 -variable XCWinOps
(${frame},colorval
) -value $idx -command \
2076 "xcircuit::color set $idx"
2080 #----------------------------------------------------------------------
2081 # Regenerate the list of color buttons for a new window
2082 #----------------------------------------------------------------------
2084 proc xcircuit
::allcolorbuttons {window
} {
2087 set colorlist
[color get
-all]
2088 set frame [winfo top
$window]
2089 set idx
18 ;# NUMBER_OF_COLORS in colordefs.h
2090 foreach colorrgb
$colorlist {
2091 ${frame}.menubar.optionsbutton.optionsmenu.elementsmenu.colormenu
\
2092 add radio
-image img_col
$idx -activebackground $colorrgb \
2093 -variable XCWinOps
(${frame},colorval
) -value $idx -command \
2094 "xcircuit::color set $idx"
2099 #----------------------------------------------------------------------
2101 proc xcircuit
::picknewcolor {} {
2102 if {[catch {set colorrgb
[tk_chooseColor]}]} {
2103 set colorrgb
[tkColorDialog
]
2105 xcircuit
::color add
$colorrgb
2108 #----------------------------------------------------------------------
2110 proc xcircuit
::newencodingbutton {encodingname
} {
2113 foreach window
[config windownames
] {
2114 set frame [winfo top
$window]
2115 if {[catch {${frame}.menubar.textbutton.textmenu.encodingmenu
\
2116 index
$encodingname} result
]} {
2117 ${frame}.menubar.textbutton.textmenu.encodingmenu add radio
-label \
2118 $encodingname -command "xcircuit::label encoding $encodingname" \
2119 -variable XCWinOps
(${frame},fontencoding
) -value $encodingname
2124 #----------------------------------------------------------------------
2126 proc xcircuit
::newfontbutton {familyname
} {
2129 foreach window
[config windownames
] {
2130 set frame [winfo top
$window]
2131 if {[catch {${frame}.menubar.textbutton.textmenu.fontmenu
\
2132 index
$familyname} result
]} {
2133 ${frame}.menubar.textbutton.textmenu.fontmenu add radio
-label \
2134 $familyname -command "xcircuit::label family $familyname" \
2135 -variable XCWinOps
(${frame},fontfamily
) -value $familyname
2140 #----------------------------------------------------------------------
2141 # Regenerate the list of known font families for a new window
2142 #----------------------------------------------------------------------
2144 proc xcircuit
::allfontbuttons {window
} {
2147 set familylist
[label family
-all]
2148 set frame [winfo top
$window]
2149 while {$familylist != {}} {
2150 set familyname
[lindex $familylist 0]
2151 ${frame}.menubar.textbutton.textmenu.fontmenu add radio
-label \
2152 $familyname -command "xcircuit::label family $familyname" \
2153 -variable XCWinOps
(${frame},fontfamily
) -value $familyname
2154 # Remove all such entries (this works like "lsort -unique" but doesn't
2155 # scramble the list entries).
2156 set familylist
[lsearch -all -inline -not $familylist $familyname]
2160 #----------------------------------------------------------------------
2162 proc xcircuit
::newlibrarybutton {libname
} {
2163 if {[catch {.librarymenu index
$libname} result
]} {
2164 set libidx
[.librarymenu index end
]
2165 if {$libidx <= 1} {set libidx
[expr $libidx + 1]}
2166 .librarymenu insert
$libidx command
-label $libname -command \
2167 "xcircuit::library \"$libname\" goto"
2171 #----------------------------------------------------------------------
2173 proc xcircuit
::newpagebutton {pagename
{pageno
0}} {
2174 if {[catch {.pagemenu index
$pagename} result
]} {
2175 set target
$pagename
2176 if {$pageno > 0} { set target
$pageno }
2177 .pagemenu add command
-label $pagename -command \
2178 "xcircuit::page \"$target\" goto"
2182 #----------------------------------------------------------------------
2184 proc xcircuit
::renamelib {libno libname
} {
2185 set target
[expr $libno + 1]
2186 .librarymenu entryconfigure
$target -label $libname -command \
2187 "xcircuit::library \"$libname\" goto"
2190 #----------------------------------------------------------------------
2192 proc xcircuit
::renamepage {pageno pagename
} {
2193 set target
[expr $pageno + 1]
2194 .pagemenu entryconfigure
$target -label $pagename -command \
2195 "xcircuit::page \"$pagename\" goto"
2198 #----------------------------------------------------------------------
2200 proc xcircuit
::promptnewfont {} {
2202 set XCOps
(dialog
) fontname
2203 .dialog.bbar.apply configure
-command \
2204 {xcircuit
::loadfont [.dialog.textent.txt get
]}
2205 .dialog.textent.title.field configure
-text "Font name:"
2206 .dialog.textent.txt delete
0 end
2207 xcircuit
::popupdialog
2210 #----------------------------------------------------------------------
2212 proc xcircuit
::promptkern {} {
2214 set XCOps
(dialog
) kernamount
2215 .dialog.bbar.apply configure
-command \
2216 {xcircuit
::label insert kern
[.dialog.textent.txt get
]}
2217 .dialog.textent.title.field configure
-text "Kern amount:"
2218 .dialog.textent.txt delete
0 end
2219 xcircuit
::popupdialog
2222 #----------------------------------------------------------------------
2224 proc xcircuit
::promptmargin {} {
2226 set XCOps
(dialog
) marginamount
2227 .dialog.bbar.apply configure
-command \
2228 {xcircuit
::label insert margin
[.dialog.textent.txt get
]}
2229 .dialog.textent.title.field configure
-text "Margin amount:"
2230 .dialog.textent.txt delete
0 end
2231 xcircuit
::popupdialog
2234 #----------------------------------------------------------------------
2236 proc xcircuit
::maketoolimages {} {
2237 global XCOps XCIRCUIT_LIB_DIR
2238 set XCOps
(tools
) [list pn w b a s t mv cp e d2 cw ccw fx fy r pu2 po2 mk pz
\
2239 uj co bd fi pm pa li yp pl z4 z5 i
]
2241 puts stdout
"XCOps(scale) set to $XCOps(scale)"
2242 set gsize
[expr {int
($XCOps(scale) * 20)}]
2243 set gscale
[expr {int
($XCOps(scale))}]
2245 for {set i
0} {$i < [llength $XCOps(tools
)]} {incr i
1} {
2246 set bname
[lindex $XCOps(tools
) $i]
2247 image create
photo stdimage
-file ${XCIRCUIT_LIB_DIR
}/pixmaps
/${bname
}.gif
2248 image create
photo img_
${bname
} -width $gsize -height $gsize
2249 img_
${bname
} copy stdimage
-zoom $gscale
2253 #----------------------------------------------------------------------
2255 proc xcircuit
::modebutton {widget
} {
2256 global XCOps XCWinOps
2257 set window
$XCOps(focus)
2259 for {set i
0} {$i < [llength $XCOps(tools
)]} {incr i
1} {
2260 set bname
[lindex $XCOps(tools
) $i]
2261 ${window
}.mainframe.toolbar.b
${bname
} configure
-relief raised
\
2262 -highlightbackground gray90
-background gray90
2264 $widget configure
-relief solid
-highlightbackground green3
-background green3
2265 if {$XCWinOps(${window
},button1
) == "Rotate"} {
2266 ${window
}.infobar.mode configure
-text "$XCWinOps(${window},button1) \
2267 $XCWinOps(${window},rotateamount) Mode"
2269 ${window
}.infobar.mode configure
-text "$XCWinOps(${window},button1) Mode"
2273 #----------------------------------------------------------------------
2275 proc xcircuit
::button1action {button cursor action
{value
{}}} {
2276 global XCOps XCWinOps
2278 set window
$XCOps(focus).mainframe.mainarea.drawing
2279 catch {bindkey
$window Button1
$XCWinOps($XCOps(focus),button1
) forget
}
2282 bindkey
$window Button1
$action
2284 bindkey
$window Button1
$action $value
2286 set XCWinOps
($XCOps(focus),button1
) $action
2287 xcircuit
::modebutton $button
2288 catch {cursor
$cursor}
2289 catch {xcircuit
::automousehint $window}
2292 #----------------------------------------------------------------------
2294 proc xcircuit
::createtoolbar {window
} {
2295 global XCOps XCWinOps XCIRCUIT_LIB_DIR
2297 set tooltips
[list "pan window" "draw wire" "draw box" \
2298 "draw arc" "draw spline" "enter text" \
2299 "move element" "copy element" "edit element" "delete element" \
2300 "rotate 15 degrees clockwise" "rotate 15 degrees counterclockwise" \
2301 "flip horizontal" "flip vertical" "rescale" "push (edit object)" \
2302 "pop (return from object edit)" "make an object from selection" \
2303 "join elements into polygon or path" "separate path into elements" \
2304 "set color" "set border and line properties" "set fill properties" \
2305 "parameterize properties" "parameter selection" \
2306 "go to next library" "go to library directory" \
2307 "go to page directory" "zoom in" "zoom out" "pop up help window"]
2308 set toolactions
[list \
2309 {xcircuit
::button1action %W hand Pan
6} \
2310 {xcircuit
::button1action %W cross Wire
} \
2311 {xcircuit
::button1action %W cross Box
} \
2312 {xcircuit
::button1action %W circle Arc
} \
2313 {if {[select
]} {spline make
} else { \
2314 xcircuit
::button1action %W arrow Spline
}} \
2315 {xcircuit
::button1action %W
text $XCWinOps($XCOps(focus),labeltype
) ; \
2316 $XCOps(focus).mainframe.toolbar.bt configure
-image \
2317 $XCWinOps($XCOps(focus),labelimage
)} \
2318 {if {[select
]} {move selected
} else { \
2319 xcircuit
::button1action %W arrow Move
}} \
2320 {if {[select
]} {copy selected
} else { \
2321 xcircuit
::button1action %W copy Copy
}} \
2322 {if {[select
] == 1} {edit selected
} else { \
2323 xcircuit
::button1action %W edit Edit
}} \
2324 {if {[select
]} {delete selected
} else { \
2325 xcircuit
::button1action %W scissors Delete
}} \
2326 {if {[select
]} {rotate
$XCWinOps($XCOps(focus),rotateamount
)} else {\
2327 xcircuit
::button1action %W rotate Rotate
\
2328 $XCWinOps($XCOps(focus),rotateamount
)}} \
2329 {if {[select
]} {rotate
-$XCWinOps($XCOps(focus),rotateamount
)} else {\
2330 xcircuit
::button1action %W rotate Rotate
\
2331 -$XCWinOps($XCOps(focus),rotateamount
)}} \
2332 {if {[select
]} {flip horizontal
} else { \
2333 xcircuit
::button1action %W rotate
"Flip X"}} \
2334 {if {[select
]} {flip vertical
} else { \
2335 xcircuit
::button1action %W rotate
"Flip Y"}} \
2336 {if {[select
]} {xcircuit
::promptelementsize} else { \
2337 xcircuit
::button1action %W arrow Rescale
}} \
2338 {if {[select
] == 1} {push selected
} else { \
2339 xcircuit
::button1action %W question Push
}} \
2341 {if {[select
]} {xcircuit
::promptmakeobject} else { \
2342 xcircuit
::button1action %W question
"Select Save"}} \
2343 {if {[select
]} {path
join selected
} else { \
2344 xcircuit
::button1action %W arrow Join
}} \
2345 {if {[select
] == 1} {path unjoin selected
} else { \
2346 xcircuit
::button1action %W arrow Unjoin
}} \
2347 {tk_popup $XCOps(focus).colormenu
[expr {[winfo rootx
\
2348 $XCOps(focus).mainframe.toolbar.bco
] \
2349 - [winfo width
$XCOps(focus).colormenu
]}] \
2350 [expr {[winfo rooty
$XCOps(focus).mainframe.toolbar.bco
] \
2351 - [winfo height
$XCOps(focus).colormenu
] / 2}] } \
2352 {tk_popup $XCOps(focus).bordermenu
[expr {[winfo rootx
\
2353 $XCOps(focus).mainframe.toolbar.bbd
] \
2354 - [winfo width
$XCOps(focus).bordermenu
]}] \
2355 [expr {[winfo rooty
$XCOps(focus).mainframe.toolbar.bbd
] \
2356 - [winfo height
$XCOps(focus).bordermenu
] / 2}] } \
2357 {tk_popup $XCOps(focus).fillmenu
[expr {[winfo rootx
\
2358 $XCOps(focus).mainframe.toolbar.bfi
] \
2359 - [winfo width
$XCOps(focus).fillmenu
]}] \
2360 [expr {[winfo rooty
$XCOps(focus).mainframe.toolbar.bfi
] \
2361 - [winfo height
$XCOps(focus).fillmenu
] / 2}] } \
2362 {tk_popup $XCOps(focus).parammenu
[expr {[winfo rootx
\
2363 $XCOps(focus).mainframe.toolbar.bpm
] \
2364 - [winfo width
$XCOps(focus).parammenu
]}] \
2365 [expr {[winfo rooty
$XCOps(focus).mainframe.toolbar.bpm
] \
2366 - [winfo height
$XCOps(focus).parammenu
] / 2}] } \
2367 {xcircuit
::prompteditparams} \
2369 {library directory
} {page directory
} \
2370 {zoom
1.5; refresh
} {zoom
[expr {1 / 1.5}]; refresh
} \
2371 {xcircuit
::helpwindow} ]
2373 # Make the tool images if they have not yet been created.
2374 if [catch {set XCOps
(tools
)}] {xcircuit
::maketoolimages}
2376 for {set i
0} {$i < [llength $XCOps(tools
)]} {incr i
1} {
2377 set bname
[lindex $XCOps(tools
) $i]
2378 set btip
[lindex $tooltips $i]
2379 regsub -all -- %W
[lindex $toolactions $i] \
2380 ${window
}.mainframe.toolbar.b
${bname
} bcmd
2381 button ${window
}.mainframe.toolbar.b
${bname
} -image img_
${bname
} -command \
2383 bind ${window
}.mainframe.toolbar.b
${bname
} <Enter
> \
2384 [subst {${window
}.infobar.message2 configure
-text "$btip"}]
2385 bind ${window
}.mainframe.toolbar.b
${bname
} <Leave
> \
2386 [subst {${window
}.infobar.message2 configure
-text ""}]
2389 # pack the first button so we can query its height for arrangement.
2390 # this assumes that the height of each button is the same!
2391 set bname
[lindex $XCOps(tools
) 0]
2392 place ${window
}.mainframe.toolbar.b
${bname
} -x 0 -y 0
2396 #----------------------------------------------------------------------
2398 proc xcircuit
::arrangetoolbar {window
} {
2401 set numtools
[llength $XCOps(tools
)]
2402 for {set i
0} {$i < $numtools} {incr i
1} {
2403 set bname
[lindex $XCOps(tools
) $i]
2404 place forget
${window
}.mainframe.toolbar.b
${bname
}
2406 set bname
[lindex $XCOps(tools
) 0]
2407 set bheight
[winfo height
${window
}.mainframe.toolbar.b
${bname
}]
2408 set bwidth
[winfo width
${window
}.mainframe.toolbar.b
${bname
}]
2409 set wheight
[winfo height
${window
}.mainframe
]
2410 set nrows
[expr {$wheight / $bheight}]
2411 ${window
}.mainframe.toolbar configure
-width [expr {$bwidth}]
2414 for {set i
0} {$i < [llength $XCOps(tools
)]} {incr i
; incr j
} {
2418 ${window
}.mainframe.toolbar configure
-width [expr {($k + 1) * $bwidth}]
2420 set bname
[lindex $XCOps(tools
) $i]
2421 place ${window
}.mainframe.toolbar.b
${bname
} \
2422 -x [expr {$k * $bwidth}] \
2423 -y [expr {$j * $bheight}]
2427 #----------------------------------------------------------------------
2429 proc xcircuit
::toolbar {value
} {
2431 set window
$XCOps(focus)
2436 pack forget
${window
}.mainframe.mainarea
2437 pack ${window
}.mainframe.toolbar
-side right
-fill y
-padx 2
2438 pack ${window
}.mainframe.mainarea
-expand true
-fill both
2439 set midx
[${window
}.menubar.optionsbutton.optionsmenu
\
2440 index
"Enable Toolbar"]
2441 ${window
}.menubar.optionsbutton.optionsmenu entryconfigure
$midx \
2442 -command {xcircuit
::toolbar disable
} -label \
2447 pack forget
${window
}.mainframe.toolbar
2448 set midx
[${window
}.menubar.optionsbutton.optionsmenu
\
2449 index
"Disable Toolbar"]
2450 ${window
}.menubar.optionsbutton.optionsmenu entryconfigure
$midx \
2451 -command {xcircuit
::toolbar enable
} -label \
2457 #----------------------------------------------------------------------
2458 # These variables are associated with toggle and radio buttons
2459 # but must be the same for all windows.
2460 #----------------------------------------------------------------------
2462 set XCOps
(sheetsize
) letter
2463 set XCOps
(spiceend
) true
2464 set XCOps
(forcenets
) true
2465 set XCOps
(hold
) true
2467 set XCOps
(focus) .xcircuit
2469 #----------------------------------------------------------------------
2470 # Create stipple images
2471 #----------------------------------------------------------------------
2473 image create
bitmap img_stip0
-foreground white
-background black
-file \
2474 ${XCIRCUIT_LIB_DIR
}/pixmaps
/solid.xbm
2475 image create
bitmap img_stip12
-foreground black
-background white
-file \
2476 ${XCIRCUIT_LIB_DIR
}/pixmaps
/stip12.xbm
2477 image create
bitmap img_stip25
-foreground black
-background white
-file \
2478 ${XCIRCUIT_LIB_DIR
}/pixmaps
/stip25.xbm
2479 image create
bitmap img_stip38
-foreground black
-background white
-file \
2480 ${XCIRCUIT_LIB_DIR
}/pixmaps
/stip38.xbm
2481 image create
bitmap img_stip50
-foreground black
-background white
-file \
2482 ${XCIRCUIT_LIB_DIR
}/pixmaps
/stip50.xbm
2483 image create
bitmap img_stip62
-foreground black
-background white
-file \
2484 ${XCIRCUIT_LIB_DIR
}/pixmaps
/stip62.xbm
2485 image create
bitmap img_stip75
-foreground black
-background white
-file \
2486 ${XCIRCUIT_LIB_DIR
}/pixmaps
/stip75.xbm
2487 image create
bitmap img_stip88
-foreground black
-background white
-file \
2488 ${XCIRCUIT_LIB_DIR
}/pixmaps
/stip88.xbm
2489 image create
bitmap img_stip100
-foreground black
-background white
-file \
2490 ${XCIRCUIT_LIB_DIR
}/pixmaps
/solid.xbm
2492 #----------------------------------------------------------------------
2493 # alternate label type images (info, global, and pin labels)
2494 #----------------------------------------------------------------------
2496 image create
photo img_ti
-file ${XCIRCUIT_LIB_DIR
}/pixmaps
/ti.gif
2497 image create
photo img_tg
-file ${XCIRCUIT_LIB_DIR
}/pixmaps
/tg.gif
2498 image create
photo img_tp
-file ${XCIRCUIT_LIB_DIR
}/pixmaps
/tp.gif
2500 #----------------------------------------------------------------------
2502 proc xcircuit
::makemenus {window
} {
2505 set m
[menu ${window
}.menubar.filebutton.filemenu
-tearoff 0]
2506 $m add command
-label "New Window" -command {xcircuit
::forkwindow}
2507 $m add command
-label "Close Window" -command \
2508 "xcircuit::closewindow ${window}.mainframe.mainarea.drawing"
2510 $m add command
-label "Read XCircuit File" -command {xcircuit
::promptloadfile}
2511 if {![catch {set XCOps
(module
,files
)}]} {
2512 $m add command
-label "Write All..." -command {xcircuit
::promptwriteall}
2514 $m add command
-label "Format Page Output" -command {xcircuit
::promptsavepage}
2516 $m add command
-label "Load Dependencies" -command \
2517 {while {[page links
load -replace $XCOps(technology
) \
2518 -target $XCOps(library
)]} {}}
2519 $m add cascade
-label "Import" -menu $m.importmenu
2520 $m add cascade
-label "Export" -menu $m.exportmenu
2522 $m add command
-label "Execute Script" -command {xcircuit
::promptexecscript}
2523 if {[file tail
[info nameofexecutable
]] != "xcircexec"} {
2524 $m add command
-label "Tcl Console" -command {xcircuit
::raiseconsole}
2527 if {![catch {set XCOps
(module
,library
)}]} {
2528 $m add command
-label "Library Manager" -command {xcircuit
::raisemanager}
2530 $m add command
-label "New Library Page" -command {xcircuit
::promptaddlibrary}
2531 $m add command
-label "Load Technology (.lps)" -command {xcircuit
::promptloadlibrary}
2532 $m add command
-label "Save Technology (.lps)" -command {xcircuit
::promptsavetech}
2535 $m add command
-label "Clear Page" -command {xcircuit
::page reset
}
2537 $m add command
-label "Quit" -command {quit
}
2539 # Sub-menu for Import functions
2541 set m2
[menu $m.importmenu
-tearoff 0]
2542 $m2 add command
-label "Import XCircuit File" -command {xcircuit
::promptimportfile}
2543 $m2 add command
-label "Import background PS" -command \
2544 {xcircuit
::promptimportbackground}
2545 $m2 add command
-label "Import graphic image" -command \
2546 {xcircuit
::promptimportgraphic}
2547 if {![catch {set XCOps
(module
,edif
)}]} {
2548 $m2 add command
-label "Read EDIF file" -command {xcircuit
::promptreadedif}
2550 if {![catch {set XCOps
(module
,synopsys
)}]} {
2551 $m2 add command
-label "Read Synopsys library" -command {xcircuit
::promptreadsynopsys}
2553 if {![catch {set XCOps
(module
,matgen
)}]} {
2554 $m2 add command
-label "Import Matlab PS" -command {xcircuit
::promptimportmatlab}
2556 if {![catch {set XCIRCUIT_ASG
}]} {
2557 $m2 add command
-label "Import SPICE Deck" -command \
2558 {xcircuit
::promptimportspice}
2560 if {![catch {set XCOps
(module
,text)}]} {
2561 $m2 add command
-label "Import text" -command {xcircuit
::promptimporttext}
2564 # Sub-menu for Export functions
2566 set m2
[menu $m.exportmenu
-tearoff 0]
2567 $m2 add command
-label "Export SVG" -command {svg
-fullscale}
2569 set m
[menu ${window
}.menubar.editbutton.editmenu
-tearoff 0]
2570 $m add command
-label "Undo" -command {undo
}
2571 $m add command
-label "Redo" -command {redo
}
2573 $m add command
-label "Delete" -command \
2574 "${window}.mainframe.toolbar.bd2 invoke"
2575 $m add command
-label "Copy" -command \
2576 "${window}.mainframe.toolbar.bcp invoke"
2577 $m add command
-label "Move" -command \
2578 "${window}.mainframe.toolbar.bmv invoke"
2579 $m add command
-label "Edit" -command \
2580 "${window}.mainframe.toolbar.be invoke"
2581 $m add cascade
-label "Rotate/Flip" -menu $m.rotmenu
2582 $m add command
-label "Deselect" -command {deselect selected
}
2583 $m add cascade
-label "Select Filter" -menu $m.selmenu
2584 $m add command
-label "Push Selected" -command \
2585 "${window}.mainframe.toolbar.pu2 invoke"
2586 $m add command
-label "Pop Hierarchy" -command {pop
}
2588 $m add command
-label "Change Technology" -command \
2589 {xcircuit
::prompttargettech [element selected object
]}
2591 $m add command
-label "Make User Object" -command \
2592 "${window}.mainframe.toolbar.bmk invoke"
2593 $m add command
-label "Make Arc" -command \
2594 "${window}.mainframe.toolbar.ba invoke"
2595 $m add command
-label "Make Box" -command \
2596 "${window}.mainframe.toolbar.bb invoke"
2597 $m add command
-label "Make Spline" -command \
2598 "${window}.mainframe.toolbar.bs invoke"
2599 $m add command
-label "Make Wire" -command \
2600 "${window}.mainframe.toolbar.bw invoke"
2601 $m add command
-label "Replace" -command {xcircuit
::promptreplaceobject}
2602 $m add command
-label "Join" -command \
2603 "${window}.mainframe.toolbar.bpz invoke"
2604 $m add command
-label "Unjoin" -command \
2605 "${window}.mainframe.toolbar.buj invoke"
2606 $m add command
-label "Raise/Lower" -command {element exchange
}
2608 set m2
[menu $m.rotmenu
-tearoff 0]
2609 $m2 add command
-label "Flip Horizontal" -command \
2610 "${window}.mainframe.toolbar.bfx invoke"
2611 $m2 add command
-label "Flip Vertical" -command \
2612 "${window}.mainframe.toolbar.bfy invoke"
2613 $m2 add command
-label "Rescale" -command \
2614 "${window}.mainframe.toolbar.r invoke"
2616 $m2 add command
-label "Rotate CW 90" -command \
2617 {set XCWinOps
($XCOps(focus),rotateamount
) 90; \
2618 $XCOps(focus).mainframe.toolbar.bcw invoke
}
2619 $m2 add command
-label "Rotate CW 45" -command \
2620 {set XCWinOps
($XCOps(focus),rotateamount
) 45; \
2621 $XCOps(focus).mainframe.toolbar.bcw invoke
}
2622 $m2 add command
-label "Rotate CW 30" -command \
2623 {set XCWinOps
($XCOps(focus),rotateamount
) 30; \
2624 $XCOps(focus).mainframe.toolbar.bcw invoke
}
2625 $m2 add command
-label "Rotate CW 15" -command \
2626 {set XCWinOps
($XCOps(focus),rotateamount
) 15; \
2627 $XCOps(focus).mainframe.toolbar.bcw invoke
}
2628 $m2 add command
-label "Rotate CW 5" -command \
2629 {set XCWinOps
($XCOps(focus),rotateamount
) 5; \
2630 $XCOps(focus).mainframe.toolbar.bcw invoke
}
2631 $m2 add command
-label "Rotate CW 1" -command \
2632 {set XCWinOps
($XCOps(focus),rotateamount
) 1; \
2633 $XCOps(focus).mainframe.toolbar.bcw invoke
}
2635 $m2 add command
-label "Rotate CCW 90" -command \
2636 {set XCWinOps
($XCOps(focus),rotateamount
) 90; \
2637 $XCOps(focus).mainframe.toolbar.bccw invoke
}
2638 $m2 add command
-label "Rotate CCW 45" -command \
2639 {set XCWinOps
($XCOps(focus),rotateamount
) 45; \
2640 $XCOps(focus).mainframe.toolbar.bccw invoke
}
2641 $m2 add command
-label "Rotate CCW 30" -command \
2642 {set XCWinOps
($XCOps(focus),rotateamount
) 30; \
2643 $XCOps(focus).mainframe.toolbar.bccw invoke
}
2644 $m2 add command
-label "Rotate CCW 15" -command \
2645 {set XCWinOps
($XCOps(focus),rotateamount
) 15; \
2646 $XCOps(focus).mainframe.toolbar.bccw invoke
}
2647 $m2 add command
-label "Rotate CCW 5" -command \
2648 {set XCWinOps
($XCOps(focus),rotateamount
) 5; \
2649 $XCOps(focus).mainframe.toolbar.bccw invoke
}
2650 $m2 add command
-label "Rotate CCW 1" -command \
2651 {set XCWinOps
($XCOps(focus),rotateamount
) 1; \
2652 $XCOps(focus).mainframe.toolbar.bccw invoke
}
2654 set m2
[menu $m.selmenu
-tearoff 0]
2655 $m2 add command
-label "Disable selection" -command {element select hide
}
2656 $m2 add command
-label "Remove all disabled" -command {element select allow
}
2658 $m2 add check
-label "Labels" -variable XCWinOps
(${window
},sel_lab
) \
2659 -onvalue true
-offvalue false
-command \
2660 {xcircuit
::config filter
label $XCWinOps($XCOps(focus),sel_lab
)}
2661 $m2 add check
-label "Objects" -variable XCWinOps
(${window
},sel_inst
) \
2662 -onvalue true
-offvalue false
-command \
2663 {xcircuit
::config filter instance
$XCWinOps($XCOps(focus),sel_inst
)}
2664 $m2 add check
-label "Polygons" -variable XCWinOps
(${window
},sel_poly
) \
2665 -onvalue true
-offvalue false
-command \
2666 {xcircuit
::config filter polygon
$XCWinOps($XCOps(focus),sel_poly
)}
2667 $m2 add check
-label "Arcs" -variable XCWinOps
(${window
},sel_arc
) \
2668 -onvalue true
-offvalue false
-command \
2669 {xcircuit
::config filter arc
$XCWinOps($XCOps(focus),sel_arc
)}
2670 $m2 add check
-label "Splines" -variable XCWinOps
(${window
},sel_spline
) \
2671 -onvalue true
-offvalue false
-command \
2672 {xcircuit
::config filter spline
$XCWinOps($XCOps(focus),sel_spline
)}
2673 $m2 add check
-label "Paths" -variable XCWinOps
(${window
},sel_path
) \
2674 -onvalue true
-offvalue false
-command \
2675 {xcircuit
::config filter path
$XCWinOps($XCOps(focus),sel_path
)}
2676 $m2 add check
-label "Graphic Images" -variable XCWinOps
(${window
},sel_graphic
) \
2677 -onvalue true
-offvalue false
-command \
2678 {xcircuit
::config filter graphic
$XCWinOps($XCOps(focus),sel_graphic
)}
2680 set m
[menu ${window
}.menubar.textbutton.textmenu
-tearoff 0]
2681 $m add command
-label "Text Size" -command {xcircuit
::prompttextsize}
2682 $m add cascade
-label "Font" -menu $m.fontmenu
2683 $m add cascade
-label "Style" -menu $m.stylemenu
2684 $m add cascade
-label "Encoding" -menu $m.encodingmenu
2685 $m add cascade
-label "Insert" -menu $m.insertmenu
2686 $m add cascade
-label "Anchoring" -menu $m.anchormenu
2687 $m add command
-label "Parameterize" \
2688 -command {xcircuit
::labelmakeparam}
2689 $m add command
-label "Unparameterize" \
2690 -command {xcircuit
::parameter replace substring
}
2692 $m add check
-label "LaTeX mode" -variable XCWinOps
(${window
},latexmode
) \
2693 -onvalue true
-offvalue false
-command {xcircuit
::label latex
\
2694 $XCWinOps($XCOps(focus),latexmode
)}
2695 if {![catch {set XCOps
(module
,text)}]} {
2697 $m add command
-label "Modify Text..." -command {xcircuit
::textmod}
2700 $m add command
-label "Make Text" -command \
2701 {set XCWinOps
($XCOps(focus),labeltype
) "Text"; set \
2702 XCWinOps
($XCOps(focus),labelimage
) img_t
; \
2703 $XCOps(focus).mainframe.toolbar.bt invoke
}
2705 set m2
[menu $m.fontmenu
-tearoff 0]
2706 $m2 add command
-label "Add New Font" -command {xcircuit
::promptnewfont}
2709 set m2
[menu $m.stylemenu
-tearoff 0]
2710 $m2 add radio
-label "Normal" -variable XCWinOps
(${window
},fontstyle
) \
2711 -value normal
-command "xcircuit::label style normal"
2712 $m2 add radio
-label "Bold" -variable XCWinOps
(${window
},fontstyle
) \
2713 -value bold
-command "xcircuit::label style bold"
2714 $m2 add radio
-label "Italic" -variable XCWinOps
(${window
},fontstyle
) \
2715 -value italic
-command "xcircuit::label style italic"
2716 $m2 add radio
-label "BoldItalic" -variable XCWinOps
(${window
},fontstyle
) \
2717 -value bolditalic
-command "xcircuit::label style bolditalic"
2719 $m2 add radio
-label "Subscript" -variable XCWinOps
(${window
},fontscript
) \
2720 -value subscript
-command "xcircuit::label insert subscript"
2721 $m2 add radio
-label "Superscript" -variable XCWinOps
(${window
},fontscript
) \
2722 -value superscript
-command "xcircuit::label insert superscript"
2723 $m2 add radio
-label "Normalscript" -variable XCWinOps
(${window
},fontscript
) \
2724 -value normal
-command "xcircuit::label insert normalscript"
2726 $m2 add radio
-label "Underline" -variable XCWinOps
(${window
},fontlining
) \
2727 -value underline
-command "xcircuit::label insert underline"
2728 $m2 add radio
-label "Overline" -variable XCWinOps
(${window
},fontlining
) \
2729 -value overline
-command "xcircuit::label insert overline"
2730 $m2 add radio
-label "No Line" -variable XCWinOps
(${window
},fontlining
) \
2731 -value normal
-command "xcircuit::label insert noline"
2733 set m2
[menu $m.encodingmenu
-tearoff 0]
2734 $m2 add radio
-label "Standard" -variable XCWinOps
(${window
},fontencoding
) \
2735 -value Standard
-command "xcircuit::label encoding Standard"
2736 $m2 add radio
-label "ISOLatin1" -variable XCWinOps
(${window
},fontencoding
) \
2737 -value ISOLatin1
-command "xcircuit::label encoding ISOLatin1"
2739 set m2
[menu $m.insertmenu
-tearoff 0]
2740 $m2 add command
-label "Tab stop" -command "xcircuit::label insert stop"
2741 $m2 add command
-label "Tab forward" -command "xcircuit::label insert forward"
2742 $m2 add command
-label "Tab backward" -command "xcircuit::label insert backward"
2743 $m2 add command
-label "Margin stop" -command {if {[lindex [xcircuit
::label \
2744 substring
] 1] <= 1} {xcircuit
::promptmargin} else \
2745 {xcircuit
::label insert margin
}}
2746 $m2 add command
-label "Carriage Return" -command "xcircuit::label insert return"
2747 $m2 add command
-label "1/2 space" -command "xcircuit::label insert halfspace"
2748 $m2 add command
-label "1/4 space" -command "xcircuit::label insert quarterspace"
2749 $m2 add command
-label "Kern" -command "xcircuit::promptkern"
2750 $m2 add command
-label "Character" -command "xcircuit::label insert special"
2751 $m2 add command
-label "Parameter" -command "xcircuit::prompteditparams"
2753 set m2
[menu $m.anchormenu
-tearoff 0]
2754 $m2 add radio
-label "Left Anchored" -variable XCWinOps
(${window
},jhoriz
) \
2755 -value left
-command "xcircuit::label anchor left"
2756 $m2 add radio
-label "Center Anchored" -variable XCWinOps
(${window
},jhoriz
) \
2757 -value center
-command "xcircuit::label anchor center"
2758 $m2 add radio
-label "Right Anchored" -variable XCWinOps
(${window
},jhoriz
) \
2759 -value right
-command "xcircuit::label anchor right"
2761 $m2 add radio
-label "Top Anchored" -variable XCWinOps
(${window
},jvert
) \
2762 -value top
-command "xcircuit::label anchor top"
2763 $m2 add radio
-label "Middle Anchored" -variable XCWinOps
(${window
},jvert
) \
2764 -value middle
-command "xcircuit::label anchor middle"
2765 $m2 add radio
-label "Bottom Anchored" -variable XCWinOps
(${window
},jvert
) \
2766 -value bottom
-command "xcircuit::label anchor bottom"
2768 $m2 add radio
-label "Left Justified" -variable XCWinOps
(${window
},justif
) \
2769 -value left
-command "xcircuit::label justify left"
2770 $m2 add radio
-label "Center Justified" -variable XCWinOps
(${window
},justif
) \
2771 -value center
-command "xcircuit::label justify center"
2772 $m2 add radio
-label "Right Justified" -variable XCWinOps
(${window
},justif
) \
2773 -value right
-command "xcircuit::label justify right"
2775 $m2 add check
-label "Flip Invariant" \
2776 -variable XCWinOps
(${window
},flipinvariant
) \
2777 -onvalue true
-offvalue false
-command {xcircuit
::label flipinvariant
\
2778 $XCWinOps($XCOps(focus),flipinvariant
)}
2780 set m
[menu ${window
}.menubar.optionsbutton.optionsmenu
-tearoff 0]
2781 $m add check
-label "Alt Colors" -variable XCWinOps
(${window
},colorscheme
) \
2782 -onvalue inverse
-offvalue normal
-command {xcircuit
::config \
2783 colorscheme
$XCWinOps($XCOps(focus),colorscheme
)}
2784 $m add check
-label "Show Bounding Box" -variable XCWinOps
(${window
},showbbox
) \
2785 -onvalue visible
-offvalue invisible
-command \
2786 {xcircuit
::config bbox
$XCWinOps($XCOps(focus),showbbox
)}
2787 $m add check
-label "Edit In Place" -variable XCWinOps
(${window
},editinplace
) \
2788 -onvalue true
-offvalue false
-command {xcircuit
::config editinplace
\
2789 $XCWinOps($XCOps(focus),editinplace
)}
2790 $m add check
-label "Show Pin Positions" \
2791 -variable XCWinOps
(${window
},pinpositions
) \
2792 -onvalue visible
-offvalue invisible
-command \
2793 {xcircuit
::config pinpositions
$XCWinOps($XCOps(focus),pinpositions
)}
2794 $m add check
-label "Wires Stay Attached to Pins" \
2795 -variable XCWinOps
(${window
},pinattach
) \
2796 -onvalue true
-offvalue false
-command \
2797 {xcircuit
::config pinattach
$XCWinOps($XCOps(focus),pinattach
)}
2798 $m add check
-label "Show Clipmask Outlines" \
2799 -variable XCWinOps
(${window
},showclipmasks
) \
2800 -onvalue show
-offvalue hide
-command \
2801 {xcircuit
::config clipmasks
$XCWinOps($XCOps(focus),showclipmasks
)}
2802 $m add check
-label "Show Technology Namespaces" \
2803 -variable XCWinOps
(${window
},namespaces
) \
2804 -onvalue true
-offvalue false
-command \
2805 {xcircuit
::config technologies
$XCWinOps($XCOps(focus),namespaces
)}
2807 $m add command
-label "Disable Toolbar" -command {xcircuit
::toolbar disable
}
2808 $m add check
-label "Allow HOLD Mode" -variable XCOps
(hold
) -onvalue true
\
2809 -offvalue false
-command {xcircuit
::config hold
$XCOps(hold
)}
2810 $m add cascade
-label "Grid" -menu $m.gridmenu
2811 $m add cascade
-label "Snap-to" -menu $m.snapmenu
2812 $m add cascade
-label "Linewidth" -menu $m.linemenu
2813 $m add cascade
-label "Elements" -menu $m.elementsmenu
2815 $m add command
-label "Help!" -command {xcircuit
::helpwindow}
2817 set m2
[menu $m.gridmenu
-tearoff 0]
2818 $m2 add check
-label "Grid" -variable XCWinOps
(${window
},showgrid
) \
2819 -onvalue true
-offvalue false
\
2820 -command {xcircuit
::config grid $XCWinOps($XCOps(focus),showgrid
); refresh
}
2821 $m2 add check
-label "Axes" -variable XCWinOps
(${window
},showaxes
) \
2822 -onvalue true
-offvalue false
\
2823 -command {xcircuit
::config axes
$XCWinOps($XCOps(focus),showaxes
); refresh
}
2824 $m2 add command
-label "Grid Spacing" -command {xcircuit
::promptgridspace}
2825 $m2 add cascade
-label "Grid type/display" -menu $m2.gridsubmenu
2827 set m3
[menu $m2.gridsubmenu
-tearoff 0]
2828 $m3 add radio
-label "Decimal Inches" -variable XCWinOps
(${window
},gridstyle
) \
2829 -value "decimal inches" \
2830 -command {xcircuit
::config coordstyle
"decimal inches"}
2831 $m3 add radio
-label "Fractional Inches" -variable XCWinOps
(${window
},gridstyle
) \
2832 -value "fractional inches" \
2833 -command {xcircuit
::config coordstyle
"fractional inches"}
2834 $m3 add radio
-label "Centimeters" -variable XCWinOps
(${window
},gridstyle
) \
2835 -value "centimeters" -command {xcircuit
::config coordstyle
"centimeters"}
2836 $m3 add radio
-label "Internal Units" -variable XCWinOps
(${window
},gridstyle
) \
2837 -value "internal units" -command \
2838 {xcircuit
::config coordstyle
"internal units"}
2840 $m3 add command
-label "Drawing Scale" -command {xcircuit
::promptdrawingscale}
2842 set m2
[menu $m.snapmenu
-tearoff 0]
2843 $m2 add check
-label "Snap-to" -variable XCWinOps
(${window
},showsnap
) \
2845 -offvalue false
-command {xcircuit
::config snap
\
2846 $XCWinOps($XCOps(focus),showsnap
); refresh
}
2847 $m2 add command
-label "Snap Spacing" -command {xcircuit
::promptsnapspace}
2849 set m2
[menu $m.linemenu
-tearoff 0]
2850 $m2 add command
-label "Wire Linewidth" -command {xcircuit
::promptborderwidth}
2851 $m2 add command
-label "Global Linewidth" -command {xcircuit
::promptlinewidth}
2853 set m2
[menu $m.elementsmenu
-tearoff 0]
2854 $m2 add cascade
-label "Border" -menu $m2.bordermenu
2855 $m2 add cascade
-label "Fill" -menu $m2.fillmenu
2856 $m2 add cascade
-label "Color" -menu $m2.colormenu
2858 $m2 add cascade
-label "Parameters" -menu $m2.parammenu
2859 $m2 add command
-label "Scale" -command {xcircuit
::promptelementsize}
2860 $m2 add check
-label "Center Object" -variable XCWinOps
(${window
},centerobject
) \
2861 -onvalue true
-offvalue false
-command {xcircuit
::config centering
\
2862 $XCWinOps($XCOps(focus),centerobject
)}
2863 $m2 add check
-label "Instance Scale-invariant Linewidth" \
2864 -variable XCWinOps
(${window
},scaleinvariant
) \
2865 -onvalue invariant
-offvalue variant
-command {xcircuit
::instance linewidth
\
2866 $XCWinOps($XCOps(focus),scaleinvariant
)}
2867 $m2 add check
-label "Manhattan Draw" \
2868 -variable XCWinOps
(${window
},manhattandraw
) \
2869 -onvalue true
-offvalue false
-command {xcircuit
::config manhattan
\
2870 $XCWinOps($XCOps(focus),manhattandraw
)}
2871 $m2 add check
-label "Link Curve Tangents" \
2872 -variable XCWinOps
(${window
},pathedittype
) \
2873 -onvalue tangents
-offvalue normal
-command {xcircuit
::config pathedit
\
2874 $XCWinOps($XCOps(focus),pathedittype
)}
2875 $m2 add cascade
-label "Polygon Edit" -menu $m2.polyeditmenu
2877 set m3
[menu $m2.bordermenu
-tearoff 0]
2878 $m3 add command
-label "Linewidth" -command {xcircuit
::promptborderwidth}
2880 $m3 add radio
-label "Solid" -variable XCWinOps
(${window
},linestyle
) \
2881 -value solid
-command {xcircuit
::border solid
}
2882 $m3 add radio
-label "Dashed" -variable XCWinOps
(${window
},linestyle
) \
2883 -value dashed
-command {xcircuit
::border dashed
}
2884 $m3 add radio
-label "Dotted" -variable XCWinOps
(${window
},linestyle
) \
2885 -value dotted
-command {xcircuit
::border dotted
}
2886 $m3 add radio
-label "Unbordered" -variable XCWinOps
(${window
},linestyle
) \
2887 -value unbordered
-command {xcircuit
::border unbordered
}
2889 $m3 add check
-label "Closed" -variable XCWinOps
(${window
},polyclosed
) \
2890 -onvalue closed
-offvalue unclosed
-command \
2891 {xcircuit
::border $XCWinOps($XCOps(focus),polyclosed
)}
2892 $m3 add check
-label "Square Endcaps" -variable XCWinOps
(${window
},endcaps
) \
2893 -onvalue square
-offvalue round
-command {xcircuit
::border \
2894 $XCWinOps($XCOps(focus),endcaps
)}
2895 $m3 add check
-label "Bounding Box" -variable XCWinOps
(${window
},bboxtype
) \
2896 -onvalue true
-offvalue false
-command {xcircuit
::border bbox
\
2897 $XCWinOps($XCOps(focus),bboxtype
)}
2898 $m3 add check
-label "Clipmask" -variable XCWinOps
(${window
},clipmask
) \
2899 -onvalue true
-offvalue false
-command {xcircuit
::border clipmask
\
2900 $XCWinOps($XCOps(focus),clipmask
)}
2901 $m3 add check
-label "Manhattan Draw" -variable XCWinOps
(${window
},manhattandraw
) \
2902 -onvalue true
-offvalue false
-command {xcircuit
::config manhattan
\
2903 $XCWinOps($XCOps(focus),manhattandraw
)}
2904 $m3 add check
-label "Manhattan Edit" \
2905 -variable XCWinOps
(${window
},polyedittype
) \
2906 -onvalue manhattan
-offvalue normal
\
2907 -command {xcircuit
::config boxedit
\
2908 $XCWinOps($XCOps(focus),polyedittype
)}
2910 set m3
[menu $m2.fillmenu
-tearoff 0]
2911 $m3 add radio
-image img_stip100
-variable XCWinOps
(${window
},fillamount
) \
2912 -value 100 -command {xcircuit
::fill 100 opaque
}
2913 $m3 add radio
-image img_stip88
-variable XCWinOps
(${window
},fillamount
) \
2914 -value 88 -command {xcircuit
::fill 88 opaque
}
2915 $m3 add radio
-image img_stip75
-variable XCWinOps
(${window
},fillamount
) \
2916 -value 75 -command {xcircuit
::fill 75 opaque
}
2917 $m3 add radio
-image img_stip62
-variable XCWinOps
(${window
},fillamount
) \
2918 -value 62 -command {xcircuit
::fill 62 opaque
}
2919 $m3 add radio
-image img_stip50
-variable XCWinOps
(${window
},fillamount
) \
2920 -value 50 -command {xcircuit
::fill 50 opaque
}
2921 $m3 add radio
-image img_stip38
-variable XCWinOps
(${window
},fillamount
) \
2922 -value 38 -command {xcircuit
::fill 38 opaque
}
2923 $m3 add radio
-image img_stip25
-variable XCWinOps
(${window
},fillamount
) \
2924 -value 25 -command {xcircuit
::fill 25 opaque
}
2925 $m3 add radio
-image img_stip12
-variable XCWinOps
(${window
},fillamount
) \
2926 -value 12 -command {xcircuit
::fill 12 opaque
}
2927 $m3 add radio
-image img_stip0
-variable XCWinOps
(${window
},fillamount
) \
2928 -value 0 -command {xcircuit
::fill 0 transparent
}
2930 $m3 add radio
-label "Opaque" -variable XCWinOps
(${window
},opaque
) \
2931 -value true
-command {xcircuit
::fill opaque
}
2932 $m3 add radio
-label "Transparent" -variable XCWinOps
(${window
},opaque
) \
2933 -value false
-command {xcircuit
::fill transparent
}
2935 set m3
[menu $m2.colormenu
-tearoff 0]
2936 $m3 add command
-label "Add New Color" -command {xcircuit
::picknewcolor}
2938 $m3 add radio
-label "Inherit Color" -variable XCWinOps
(${window
},colorval
) \
2939 -value inherit
-command {color
set inherit
}
2941 set m3
[menu $m2.parammenu
-tearoff 0]
2942 $m3 add command
-label "Manage Parameters" -command {xcircuit
::prompteditparams}
2944 $m3 add check
-label "X Position" -variable XCWinOps
(${window
},xposparam
) \
2945 -onvalue true
-offvalue false
-command \
2946 {if {$XCWinOps($XCOps(focus),xposparam
)} \
2947 {xcircuit
::parameter make
"x position"} \
2948 {xcircuit
::parameter replace
"x position"}}
2949 $m3 add check
-label "Y Position" -variable XCWinOps
(${window
},yposparam
) \
2950 -onvalue true
-offvalue false
-command \
2951 {if {$XCWinOps($XCOps(focus),yposparam
)} \
2952 {xcircuit
::parameter make
"y position"} \
2953 {xcircuit
::parameter replace
"y position"}}
2954 $m3 add check
-label "Anchoring" -variable XCWinOps
(${window
},anchorparam
) \
2955 -onvalue true
-offvalue false
-command \
2956 {if {$XCWinOps($XCOps(focus),anchorparam
)} \
2957 {xcircuit
::parameter make anchoring
} \
2958 {xcircuit
::parameter replace anchoring
}}
2959 $m3 add check
-label "Rotation" -variable XCWinOps
(${window
},rotationparam
) \
2960 -onvalue true
-offvalue false
-command \
2961 {if {$XCWinOps($XCOps(focus),rotationparam
)} \
2962 {xcircuit
::parameter make rotation
} \
2963 {xcircuit
::parameter replace rotation
}}
2964 $m3 add check
-label "Style" -variable XCWinOps
(${window
},styleparam
) \
2965 -onvalue true
-offvalue false
-command \
2966 {if {$XCWinOps($XCOps(focus),styleparam
)} \
2967 {xcircuit
::parameter make style
} \
2968 {xcircuit
::parameter replace style
}}
2969 $m3 add check
-label "Scale" -variable XCWinOps
(${window
},scaleparam
) \
2970 -onvalue true
-offvalue false
-command \
2971 {if {$XCWinOps($XCOps(focus),scaleparam
)} \
2972 {xcircuit
::parameter make
scale} \
2973 {xcircuit
::parameter replace
scale}}
2974 $m3 add check
-label "Linewidth" -variable XCWinOps
(${window
},linewidthparam
) \
2975 -onvalue true
-offvalue false
-command \
2976 {if {$XCWinOps($XCOps(focus),linewidthparam
)} \
2977 {xcircuit
::parameter make linewidth
} \
2978 {xcircuit
::parameter replace linewidth
}}
2979 $m3 add check
-label "Color" -variable XCWinOps
(${window
},colorparam
) \
2980 -onvalue true
-offvalue false
-command \
2981 {if {$XCWinOps($XCOps(focus),colorparam
)} \
2982 {xcircuit
::parameter make color
} \
2983 {xcircuit
::parameter replace color
}}
2984 $m3 add check
-label "Start Angle" -variable XCWinOps
(${window
},startparam
) \
2985 -onvalue true
-offvalue false
-command \
2986 {if {$XCWinOps($XCOps(focus),startparam
)} \
2987 {xcircuit
::parameter make
"start angle"} \
2988 {xcircuit
::parameter replace
"start angle"}}
2989 $m3 add check
-label "End Angle" -variable XCWinOps
(${window
},endparam
) \
2990 -onvalue true
-offvalue false
-command \
2991 {if {$XCWinOps($XCOps(focus),endparam
)} \
2992 {xcircuit
::parameter make
"end angle"} \
2993 {xcircuit
::parameter replace
"end angle"}}
2994 $m3 add check
-label "Radius" -variable XCWinOps
(${window
},radiusparam
) \
2995 -onvalue true
-offvalue false
-command \
2996 {if {$XCWinOps($XCOps(focus),radiusparam
)} \
2997 {xcircuit
::parameter make radius
} \
2998 {xcircuit
::parameter replace radius
}}
2999 $m3 add check
-label "Minor Axis" -variable XCWinOps
(${window
},minorparam
) \
3000 -onvalue true
-offvalue false
-command \
3001 {if {$XCWinOps($XCOps(focus),minorparam
)} \
3002 {xcircuit
::parameter make
"minor axis"} \
3003 {xcircuit
::parameter replace
"minor axis"}}
3005 set m3
[menu $m2.polyeditmenu
-tearoff 0]
3006 $m3 add radio
-label "Manhattan Box Edit" \
3007 -variable XCWinOps
(${window
},polyedittype
) \
3008 -value manhattan
-command {xcircuit
::config boxedit manhattan
}
3009 $m3 add radio
-label "Rhomboid X" -variable XCWinOps
(${window
},polyedittype
) \
3010 -value rhomboidx
-command {xcircuit
::config boxedit rhomboidx
}
3011 $m3 add radio
-label "Rhomboid Y" -variable XCWinOps
(${window
},polyedittype
) \
3012 -value rhomboidy
-command {xcircuit
::config boxedit rhomboidy
}
3013 $m3 add radio
-label "Rhomboid A" -variable XCWinOps
(${window
},polyedittype
) \
3014 -value rhomboida
-command {xcircuit
::config boxedit rhomboida
}
3015 $m3 add radio
-label "Normal" -variable XCWinOps
(${window
},polyedittype
) \
3016 -value normal
-command {xcircuit
::config boxedit normal
}
3018 set m
[menu ${window
}.menubar.windowbutton.windowmenu
-tearoff 0]
3019 $m add command
-label "Zoom In" -command {zoom
1.5; refresh
}
3020 $m add command
-label "Zoom Out" -command {zoom
[expr {1 / 1.5}]; refresh
}
3021 $m add command
-label "Pan" -command {$XCOps(focus).mainframe.toolbar.bp invoke
}
3022 $m add command
-label "Full View" -command {zoom view
; refresh
}
3023 $m add command
-label "Refresh" -command {refresh
}
3025 $m add command
-label "Library Directory" -command {xcircuit
::library directory
}
3026 $m add cascade
-label "Goto Library" -menu $m.librarymenu
3028 $m add command
-label "Page Directory" -command {xcircuit
::page directory
}
3029 $m add cascade
-label "Goto Page" -menu $m.pagemenu
3031 set m
[menu ${window
}.menubar.netlistbutton.netlistmenu
-tearoff 0]
3032 $m add command
-label "Make Pin" -command \
3033 {set XCWinOps
($XCOps(focus),labeltype
) "Pin Label"; set \
3034 XCWinOps
($XCOps(focus),labelimage
) img_tp
; \
3035 $XCOps(focus).mainframe.toolbar.bt invoke
}
3036 $m add command
-label "Make Info Pin" -command \
3037 {set XCWinOps
($XCOps(focus),labeltype
) "Info Label"; set \
3038 XCWinOps
($XCOps(focus),labelimage
) img_ti
; \
3039 $XCOps(focus).mainframe.toolbar.bt invoke
}
3040 $m add command
-label "Make Global Pin" -command \
3041 {set XCWinOps
($XCOps(focus),labeltype
) "Pin Global"; set \
3042 XCWinOps
($XCOps(focus),labelimage
) img_tg
; \
3043 $XCOps(focus).mainframe.toolbar.bt invoke
}
3044 $m add cascade
-label "Convert Label To..." -menu $m.pinmenu
3045 $m add check
-label "Pin Visibility" -variable XCWinOps
(${window
},pinvisible
) \
3046 -onvalue true
-offvalue false
-command {xcircuit
::label visible
\
3047 $XCWinOps($XCOps(focus),pinvisible
)}
3048 $m add check
-label "Netlistable Instance" \
3049 -variable XCWinOps
(${window
},netlistable
) \
3050 -onvalue true
-offvalue false
-command {xcircuit
::instance netlist
\
3051 $XCWinOps($XCOps(focus),netlistable
)}
3052 $m add command
-label "Make Matching Symbol" -command \
3053 {xcircuit
::promptmakesymbol [page
label]}
3054 $m add command
-label "Associate With Symbol" -command \
3055 {xcircuit
::symbol associate
}
3056 $m add command
-label "Highlight Connectivity" -command \
3057 {xcircuit
::netlist highlight
}
3058 $m add command
-label "Auto-number Components" -command \
3059 {xcircuit
::netlist autonumber
}
3060 $m add command
-label "Un-number Components" -command \
3061 {xcircuit
::netlist autonumber
-forget}
3063 $m add check
-label "SPICE .end statement" -variable XCOps
(spiceend
) \
3064 -onvalue true
-offvalue false
3065 $m add check
-label "Always regenerate netlists" -variable XCOps
(forcenets
) \
3066 -onvalue true
-offvalue false
3068 $m add command
-label "Write SPICE netlist" -command \
3069 {if {$XCOps(forcenets
)} {xcircuit
::netlist update}; \
3070 xcircuit
::netlist write spice spc
$XCOps(spiceend
)}
3071 $m add command
-label "Write flattened SPICE" -command \
3072 {if {$XCOps(forcenets
)} {xcircuit
::netlist update}; \
3073 xcircuit
::netlist write flatspice fspc
}
3074 $m add command
-label "Write sim" -command \
3075 {if {$XCOps(forcenets
)} {xcircuit
::netlist update}; \
3076 xcircuit
::netlist write flatsim sim
}
3077 $m add command
-label "Write pcb" -command \
3078 {if {$XCOps(forcenets
)} {xcircuit
::netlist update}; \
3079 xcircuit
::netlist write pcb pcbnet
}
3081 set m2
[menu $m.pinmenu
-tearoff 0]
3082 $m2 add command
-label "Normal label" -command {xcircuit
::label type normal
}
3083 $m2 add command
-label "Local Pin" -command {xcircuit
::label type pin
}
3084 $m2 add command
-label "Global Pin" -command {xcircuit
::label type
global}
3085 $m2 add command
-label "Info label" -command {xcircuit
::label type
info}
3087 #---------------------------------------------------------------------------
3088 # Create the cloned menu links used by the toolbar
3089 #---------------------------------------------------------------------------
3091 ${window
}.menubar.optionsbutton.optionsmenu.elementsmenu.parammenu
\
3092 clone
${window
}.parammenu
3093 ${window
}.menubar.optionsbutton.optionsmenu.elementsmenu.colormenu
\
3094 clone
${window
}.colormenu
3095 ${window
}.menubar.optionsbutton.optionsmenu.elementsmenu.bordermenu
\
3096 clone
${window
}.bordermenu
3097 ${window
}.menubar.optionsbutton.optionsmenu.elementsmenu.fillmenu
\
3098 clone
${window
}.fillmenu
3100 .librarymenu clone
${window
}.menubar.windowbutton.windowmenu.librarymenu
3101 .pagemenu clone
${window
}.menubar.windowbutton.windowmenu.pagemenu
3104 #-----------------------------------------------------------------
3105 # Wrapper procedure to (re)bind a key to a Tcl procedure (Ed Casas 9/4/03)
3106 # With no arguments, prints a list of bindings to stdout. Key
3107 # bindings should use "keyaction" to check for text mode, so that
3108 # rebinding of keys does not prevent text entry. Button bindings
3109 # do not need this restriction.
3110 #-----------------------------------------------------------------
3112 proc xcircuit
::keybind { {key
{}} {proc {}} {window
{}} } {
3115 if { $window == {} } { set window
$XCOps(focus).mainframe.mainarea.drawing
}
3117 switch -glob -- $key {
3119 puts stdout
"XCircuit standard key bindings:"
3120 puts stdout
"Key Binding"
3121 puts stdout
"-------------------------------------"
3122 set kpairs
[xcircuit
::bindkey]
3124 set pkey
[lindex $i 0]
3125 set pval
[lindex $i 1]
3126 puts stdout
"$pkey $pval"
3131 bind ${window
} $key $proc
3134 bind ${window
} $key "if \{!\[xcircuit::keyaction %k %s\]\} \{ $proc \}"
3139 #-----------------------------------------------------------------
3140 # Enable mouse hints in the window
3141 #-----------------------------------------------------------------
3143 # James Vernon's mouse button hints
3145 if {[catch {source $XCIRCUIT_SRC_DIR/mousehint.tcl
}]} {
3146 set XCOps
(mousehints
) -1
3148 set XCOps
(mousehints
) 0
3151 proc xcircuit
::enable_mousehints {} {
3154 if {$XCOps(mousehints
) == 0} {
3155 set XCOps
(mousehints
) 1
3156 foreach window
[config windownames
] {
3157 set frame [winfo top
$window]
3158 xcircuit
::mousehint_create $frame
3163 #-----------------------------------------------------------------
3164 # Final setup stuff before exiting back to interpreter
3165 #-----------------------------------------------------------------
3167 # This gets rid of the original "wish", in favor of our own window
3169 if {[string range
[wm title .
] 0 3] == "wish"} {
3173 #----------------------------------------------------------------------
3174 # Library and Page menus (common to all windows)
3175 #----------------------------------------------------------------------
3177 menu .librarymenu
-tearoff 0
3178 .librarymenu add command
-label "New Library Page" -command \
3179 {xcircuit
::promptaddlibrary}
3180 .librarymenu add separator
3182 menu .pagemenu
-tearoff 0
3183 .pagemenu add command
-label "Add New Page" -command {xcircuit
::page make
}
3184 .pagemenu add separator
3186 #----------------------------------------------------------------------
3187 # Source other Tcl scripts, if they exist in the $XCIRCUIT_SRC_DIR path
3188 # and add the capabilities to the GUI.
3189 #----------------------------------------------------------------------
3191 # "Write All" feature
3193 catch {source $XCIRCUIT_SRC_DIR/files.tcl
}
3195 # Library manager widget
3197 catch {source $XCIRCUIT_SRC_DIR/library.tcl
}
3199 # Fancy "Make Matching Symbol" feature
3201 catch {source $XCIRCUIT_SRC_DIR/symbol.tcl
}
3205 catch {source $XCIRCUIT_SRC_DIR/xchelp.tcl
}
3209 catch {source $XCIRCUIT_SRC_DIR/edif.tcl
}
3211 # Synopsys symbol library file parser
3213 catch {source $XCIRCUIT_SRC_DIR/synopsys.tcl
}
3215 # System Clipboard paste into labels
3217 catch {source $XCIRCUIT_SRC_DIR/selection.tcl
}
3219 # Regexp label substitutions and auto-increment feature
3221 catch {source $XCIRCUIT_SRC_DIR/text.tcl
}
3223 # Wim Vereecken's Matlab PostScript import function
3225 catch {source $XCIRCUIT_SRC_DIR/matgen.tcl
}
3227 #----------------------------------------------------------------------
3228 # Create the initial window.
3229 #----------------------------------------------------------------------
3231 xcircuit
::new_window $XCOps(focus)
3233 #----------------------------------------------------------------------
3234 # Add buttons for the pre-allocated pages
3235 #----------------------------------------------------------------------
3237 xcircuit
::newpagebutton "Page 1" 1
3238 xcircuit
::newpagebutton "Page 2" 2
3239 xcircuit
::newpagebutton "Page 3" 3
3240 xcircuit
::newpagebutton "Page 4" 4
3241 xcircuit
::newpagebutton "Page 5" 5
3242 xcircuit
::newpagebutton "Page 6" 6
3243 xcircuit
::newpagebutton "Page 7" 7
3244 xcircuit
::newpagebutton "Page 8" 8
3245 xcircuit
::newpagebutton "Page 9" 9
3246 xcircuit
::newpagebutton "Page 10" 10
3248 #----------------------------------------------------------------------
3249 # Add buttons for the pre-allocated libraries
3250 #----------------------------------------------------------------------
3252 xcircuit
::newlibrarybutton "User Library"
3254 #-----------------------------------------------------------------
3255 # New key bindings should pass through this function so that key
3256 # strokes are captured correctly for label editing.
3257 #----------------------------------------------------------------------
3259 proc xcircuit
::keyaction {keycode
{keystate
0}} {
3260 switch -- [eventmode
] {
3264 standardaction
$keycode down
$keystate
3271 #-----------------------------------------------------------------
3273 proc scrollboth
{ lists args
} {
3275 eval {$l yview
} $args
3279 #-----------------------------------------------------------------
3280 # Procedure to generate the help window
3281 #-----------------------------------------------------------------
3283 proc xcircuit
::makehelpwindow {} {
3285 toplevel .help
-bg beige
3289 frame .help.title
-bg beige
3292 pack .help.title
-side top
-fill x
3293 pack .help.listwin
-side top
-fill both
-expand true
3295 label .help.title.field
-text "XCircuit Help" -bg beige
3296 button .help.title.dbut
-text "Dismiss" -bg beige
-command {wm withdraw .help
}
3297 pack .help.title.field
-side left
-padx 10
3298 pack .help.title.dbut
-side right
-ipadx 10
3300 listbox .help.listwin.func
-yscrollcommand ".help.listwin.sb set" \
3301 -setgrid 1 -height [expr {20 * $XCOps(scale)}]
3302 listbox .help.listwin.keys
-yscrollcommand ".help.listwin.sb set" \
3303 -setgrid 1 -height [expr {20 * $XCOps(scale)}]
3304 scrollbar .help.listwin.sb
-orient vertical
-command \
3305 [list scrollboth
[list .help.listwin.func .help.listwin.keys
]]
3306 message .help.listwin.win
-width 200 -justify left
-anchor n
\
3307 -relief groove
-text "Click on a function for help text"
3309 # Keep boxes aligned!
3310 bind .help.listwin.keys
<Button-4
> {xcircuit
::helpscroll -1}
3311 bind .help.listwin.keys
<Button-5
> {xcircuit
::helpscroll 1}
3312 bind .help.listwin.func
<Button-4
> {xcircuit
::helpscroll -1}
3313 bind .help.listwin.func
<Button-5
> {xcircuit
::helpscroll 1}
3314 # Also bind to the mouse wheel (Windows-specific, generally)
3315 bind .help.listwin.keys
<MouseWheel
> {xcircuit
::helpscroll %D
}
3316 bind .help.listwin.func
<MouseWheel
> {xcircuit
::helpscroll %D
}
3318 grid .help.listwin.func
-row 0 -column 0 -sticky news
-padx 1 -pady 1
3319 grid .help.listwin.keys
-row 0 -column 1 -sticky news
-padx 1 -pady 1
3320 grid .help.listwin.sb
-row 0 -column 2 -sticky ns
-padx 1 -pady 1
3321 grid .help.listwin.win
-row 0 -column 3 -sticky news
-padx 1 -pady 1
3323 grid columnconfigure .help.listwin
1 -weight 1 -minsize 100
3324 grid rowconfigure .help.listwin
0 -weight 1 -minsize 100
3326 bind .help.listwin.func
<ButtonRelease-1
> "xcircuit::printhelp"
3329 #-----------------------------------------------------------------
3330 # Scroll all listboxes in the .help.listwin window at the same
3331 # time, in reponse to any one of them receiving a scroll event.
3332 #-----------------------------------------------------------------
3334 proc xcircuit
::helpscroll {value
} {
3336 set idx
[.help.listwin.func nearest
0]
3338 if {$tcl_platform(platform
) == "windows"} {
3339 set idx
[expr {$idx + $value / 120}]
3341 set idx
[expr {$idx + $value}]
3344 .help.listwin.func yview
$idx
3345 .help.listwin.keys yview
$idx
3347 # Important! This prohibits the default binding actions.
3351 #-----------------------------------------------------------------
3352 # Procedure to update and display the help window
3353 #-----------------------------------------------------------------
3355 proc xcircuit
::helpwindow {} {
3357 # Create the help window if it doesn't exist
3358 if {[catch {wm state .help
}]} {
3359 xcircuit
::makehelpwindow
3361 set wstate
[xcircuit
::getinitstate .help
]
3363 .help.listwin.func delete
0 end
3364 .help.listwin.keys delete
0 end
3366 set k
[lsort -dictionary [xcircuit
::bindkey]]
3368 .help.listwin.func insert end
"Function"
3369 .help.listwin.keys insert end
"Keys"
3370 .help.listwin.func insert end
""
3371 .help.listwin.keys insert end
""
3374 set pkeys
[xcircuit
::bindkey -func $i]
3375 .help.listwin.func insert end
"$i"
3376 .help.listwin.keys insert end
"$pkeys"
3379 if {"$wstate" != "normal"} {
3381 xcircuit
::centerwin .help
3386 #-----------------------------------------------------------------
3387 # Prevent "Tab" from removing focus from the window during text edits,
3388 # but allow it to take its normal meaning at other times.
3389 #-----------------------------------------------------------------
3392 switch -- [eventmode
] {
3396 default {tk::TabToWindow [tk_focusNext %W
]}
3400 bind all
<<PrevWindow
>> {
3401 switch -- [eventmode
] {
3405 default {tk::TabToWindow [tk_focusPrev %W
]}
3409 #-----------------------------------------------------------------
3410 # Wait for the drawing area to become visible, and set the focus on it.
3411 # Invoke the "wire" button so we have a default button1 action.
3412 #-----------------------------------------------------------------
3414 tkwait visibility
$XCOps(focus).mainframe.mainarea.drawing
3415 focus -force $XCOps(focus).mainframe.mainarea.drawing
3417 #-----------------------------------------------------------------
3418 # This pops down the interpreter window, if the "console.tcl" script was run.
3419 #-----------------------------------------------------------------
3421 catch xcircuit
::consoledown
3423 #-----------------------------------------------------------------
3424 # End of GUI configuration file. Xcircuit continues to load the xcircuit
3425 # startup configuration files.
3426 #-----------------------------------------------------------------