/[ascend]/trunk/ascend4/TK/library.tcl
ViewVC logotype

Contents of /trunk/ascend4/TK/library.tcl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1 - (show annotations) (download) (as text)
Fri Oct 29 20:54:12 2004 UTC (20 years, 4 months ago) by aw0a
File MIME type: text/x-tcl
File size: 18220 byte(s)
Setting up web subdirectory in repository
1 # library.tcl
2 # by Benjamin A. Allan and Kirk A. Abbott
3 # Created: January 1994
4 # Part of ASCEND
5 # Revision: $Revision: 1.28 $
6 # Last modified on: $Date: 2003/01/19 01:27:47 $
7 # Last modified by: $Author: ballan $
8 # Revision control file: $RCSfile: library.tcl,v $
9 #
10 # This file is part of the ASCEND Tcl/Tk Interface.
11 #
12 # Copyright (C) 1994-1998 Carnegie Mellon University
13 #
14 # The ASCEND Tcl/Tk Interface is free software; you can redistribute
15 # it and/or modify it under the terms of the GNU General Public
16 # License as published by the Free Software Foundation; either
17 # version 2 of the License, or (at your option) any later version.
18 #
19 # The ASCEND Tcl/Tk Interface is distributed in hope that it will be
20 # useful, but WITHOUT ANY WARRANTY; without even the implied warranty
21 # of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 # GNU General Public License for more details.
23 #
24 # You should have received a copy of the GNU General Public License
25 # along with the program; if not, write to the Free Software
26 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139 USA. Check the
27 # file named COPYING. COPYING is found in ../compiler.
28
29 # Module: library.tcl
30 # Tcl version: 7.1 (Tcl/Tk/XF)
31 # Tk version: 3.4
32 # XF version: 2.2
33 #
34
35 # module contents
36 global moduleList
37 global autoLoadList
38 set moduleList(library.tcl) {.library}
39 set autoLoadList(library.tcl) {0}
40
41 # procedures to show toplevel windows
42
43
44 # procedure to show window ShowWindow.library
45 # proc ShowWindow.library { args}
46 proc ShowWindow.library { args} {
47 # xf ignore me 7
48
49 global env ascGlobalVect ascLibrVect
50 StartupSrc.library
51
52 # build widget .library
53 if {"[info procs XFEdit]" != ""} {
54 catch "XFDestroy .library"
55 } {
56 catch "destroy .library"
57 }
58 toplevel .library
59
60 # Ascend patched window manager configurations
61 wm iconify .library
62 wm positionfrom .library user
63 wm sizefrom .library user
64 wm iconname .library {Library}
65 wm minsize .library 100 100
66 wm title .library {A4 Library}
67 wm protocol .library WM_DELETE_WINDOW {Toggle_Remote ascLibrVect}
68
69 # build widget .library.main_frm
70 frame .library.main_frm \
71 -borderwidth 0
72
73 # build widget .library.main_frm.file_box
74 frame .library.main_frm.file_box
75
76 # build widget .library.main_frm.file_box.scrollbar2
77 scrollbar .library.main_frm.file_box.scrollbar2 \
78 -command {.library.main_frm.file_box.listbox1 yview}
79
80 # build widget .library.main_frm.file_box.listbox1
81 listbox .library.main_frm.file_box.listbox1 \
82 -relief {raised} \
83 -yscrollcommand {.library.main_frm.file_box.scrollbar2 set} \
84 -font $ascLibrVect(font) \
85 -exportselection 0 \
86 -width 20 \
87 -height 2
88
89 # pack widget .library.main_frm.file_box
90 pack append .library.main_frm.file_box \
91 .library.main_frm.file_box.scrollbar2 {left frame center filly} \
92 .library.main_frm.file_box.listbox1 {top frame center expand fill}
93
94 # build widget .library.main_frm.model_box
95 frame .library.main_frm.model_box
96
97 # build widget .library.main_frm.model_box.scrollbar2
98 scrollbar .library.main_frm.model_box.scrollbar2 \
99 -command {.library.main_frm.model_box.listbox1 yview}
100
101 # build widget .library.main_frm.model_box.listbox1
102 listbox .library.main_frm.model_box.listbox1 \
103 -relief {raised} \
104 -yscrollcommand {.library.main_frm.model_box.scrollbar2 set} \
105 -font $ascLibrVect(font) \
106 -exportselection 0 \
107 -width 8 \
108 -height 2
109
110 # pack widget .library.main_frm.model_box
111 pack append .library.main_frm.model_box \
112 .library.main_frm.model_box.scrollbar2 {right frame center filly} \
113 .library.main_frm.model_box.listbox1 {top frame center expand fill}
114
115 # pack widget .library.main_frm
116 pack append .library.main_frm \
117 .library.main_frm.file_box {left frame center fill} \
118 .library.main_frm.model_box {left frame center expand fill}
119
120
121 #
122 # Build the entry box
123 #
124 frame .library.entry_frm \
125 -borderwidth {0} \
126 -relief {raised}
127
128 entry .library.entry_frm.lib_entry \
129 -relief {raised} \
130 -width {24} \
131 -textvariable ascLibrVect(entryline) \
132 -font $ascLibrVect(entryFont) \
133 -exportselection 0 \
134 -cursor hand2
135
136 # pack widget .library.entry_frm
137 pack append .library.entry_frm \
138 .library.entry_frm.lib_entry {left frame w pady 5 expand fill}
139
140
141 #
142 # Build the scrollable listbox to hold the simulation names
143 #
144 frame .library.sims_frm \
145 -borderwidth {0}
146 frame .library.sims_frm.sims_box \
147 -borderwidth {0}
148
149 # pack widget .library.sims_frm
150 pack append .library.sims_frm \
151 .library.sims_frm.sims_box {left frame center expand fill}
152
153 # build widget .library.sims_frm.sims_box.listbox1
154 listbox .library.sims_frm.sims_box.listbox1 \
155 -relief {raised} \
156 -xscrollcommand {.library.sims_frm.sims_box.scrollbar3 set} \
157 -yscrollcommand {.library.sims_frm.sims_box.scrollbar2 set} \
158 -font $ascLibrVect(font) \
159 -exportselection 0 \
160 -width 1 \
161 -height 3
162
163 # build widget .library.sims_frm.sims_box.scrollbar2
164 scrollbar .library.sims_frm.sims_box.scrollbar2 \
165 -command {.library.sims_frm.sims_box.listbox1 yview}
166
167 # build widget .library.sims_frm.sims_box.scrollbar3
168 scrollbar .library.sims_frm.sims_box.scrollbar3 \
169 -command {.library.sims_frm.sims_box.listbox1 xview} \
170 -orient {horizontal}
171
172 # pack widget .library.sims_frm.sims_box
173 pack append .library.sims_frm.sims_box \
174 .library.sims_frm.sims_box.scrollbar2 {right frame center filly} \
175 .library.sims_frm.sims_box.listbox1 {top frame center expand fill} \
176 .library.sims_frm.sims_box.scrollbar3 {bottom frame center fillx}
177
178
179 #
180 # Build the menu bar and submenus
181 #
182 menu .library.menubar \
183 -tearoffcommand .LIBRARY.MENUBAR \
184 -tearoff 0
185
186 # The Display menu
187 menu .library.menubar.display \
188 -tearoffcommand .LIBRARY.MENUBAR.DISPLAY \
189 -tearoff 0
190 .library.menubar.display add command \
191 -command {Disp_do_ShowCode} \
192 -label {Code} \
193 -accelerator {Alt-d c} \
194 -underline 0
195 .library.menubar.display add command \
196 -command {Disp_do_ShowAncestry} \
197 -label {Ancestry} \
198 -accelerator {Alt-d a} \
199 -underline 0
200 .library.menubar.display add command \
201 -command {Disp_do_Hierarchy} \
202 -label {Refinement hierarchy} \
203 -accelerator {Alt-d r} \
204 -underline 0
205 .library.menubar.display add command \
206 -command {Disp_do_PrintExtFuncLibrary} \
207 -label {External functions} \
208 -accelerator {Alt-d e} \
209 -underline 0
210 .library.menubar.display add cascade \
211 -menu .library.menubar.display.hide \
212 -label {Hide type} \
213 -accelerator {Alt-d h} \
214 -underline 0
215 .library.menubar.display add cascade \
216 -menu .library.menubar.display.unhide \
217 -label {UnHide type} \
218 -accelerator {Alt-d u} \
219 -underline 0
220 .library.menubar.display add command \
221 -command {Libr_do_Hide_Fundamentals} \
222 -label {Hide/Show Fundamentals...} \
223 -accelerator {Alt-d f} \
224 -underline 10
225
226 # The Hide menu under the Display menu
227 menu .library.menubar.display.hide \
228 -tearoffcommand .LIBRARY.MENUBAR.DISPLAY.HIDE \
229 -tearoff 0
230 .library.menubar.display.hide add command \
231 -command {Libr_do_Hide_Type} \
232 -label {Hide selected type} \
233 -accelerator {Alt-d h t} \
234 -underline 14
235 .library.menubar.display.hide add command \
236 -command {Libr_do_Hide_Type_Refinements} \
237 -label {Hide type and its refinements} \
238 -accelerator {Alt-d h r} \
239 -underline 18
240
241 # The UnHide menu under the Display menu
242 menu .library.menubar.display.unhide \
243 -tearoffcommand .LIBRARY.MENUBAR.DISPLAY.UNHIDE \
244 -tearoff 0
245 .library.menubar.display.unhide add command \
246 -command {Libr_do_UnHide_Type} \
247 -label {UnHide selected type} \
248 -accelerator {Alt-d u t} \
249 -underline 16
250 .library.menubar.display.unhide add command \
251 -command {Libr_do_UnHide_Type_Refinements} \
252 -label {UnHide type and its refinements} \
253 -accelerator {Alt-d u r} \
254 -underline 20
255
256 # The Edit menu
257 menu .library.menubar.edit \
258 -tearoffcommand .LIBRARY.MENUBAR.EDIT \
259 -tearoff 0
260 .library.menubar.edit add command \
261 -command {Libr_do_compile} \
262 -label {Create simulation...} \
263 -accelerator {Alt-e c} \
264 -underline 0
265 .library.menubar.edit add command \
266 -command Libr_SuggestMethods \
267 -label {Suggest methods...} \
268 -accelerator {Alt-e m} \
269 -underline 8
270 .library.menubar.edit add separator
271 .library.menubar.edit add command \
272 -command {Sims_do_Delete} \
273 -label {Delete simulation...} \
274 -accelerator {Alt-e s} \
275 -underline 7
276 .library.menubar.edit add command \
277 -command {Libr_do_DeleteAll} \
278 -label {Delete all types...} \
279 -accelerator {Alt-e t} \
280 -underline 11
281
282
283 # The Export menu
284 menu .library.menubar.export \
285 -tearoffcommand .LIBRARY.MENUBAR.EXPORT \
286 -tearoff 0
287 .library.menubar.export add command \
288 -command {Sims_do_Export2Browser} \
289 -label {Simulation to Browser} \
290 -accelerator {Alt-x b} \
291 -underline 14
292 .library.menubar.export add command \
293 -command {Sims_do_Export2Solver} \
294 -label {Simulation to Solver} \
295 -accelerator {Alt-x s} \
296 -underline 14
297 .library.menubar.export add command \
298 -command {Sims_do_Export2Probe} \
299 -label {Simulation to Probe} \
300 -accelerator {Alt-x p} \
301 -underline 14
302
303
304 # The File menu
305 menu .library.menubar.file \
306 -tearoffcommand .LIBRARY.MENUBAR.FILE \
307 -tearoff 0
308 .library.menubar.file add command \
309 -command {Libr_do_read} \
310 -label {Read types from file...} \
311 -accelerator {Alt-f r} \
312 -underline 0
313 .library.menubar.file add separator
314 .library.menubar.file add command \
315 -command {Toggle_Remote ascLibrVect} \
316 -label {Close window} \
317 -accelerator {Alt-f c} \
318 -underline 0
319 .library.menubar.file add command \
320 -command {Script_do_Exit} \
321 -accelerator {Alt-f e} \
322 -label {Exit ASCEND...} \
323 -underline 0
324
325
326 # The Find menu
327 menu .library.menubar.find \
328 -tearoffcommand .LIBRARY.MENUBAR.FIND \
329 -tearoff 0
330 .library.menubar.find add command \
331 -command {Libr_do_FindAtom} \
332 -label {ATOM by units...} \
333 -accelerator {Alt-i a} \
334 -underline 0
335 .library.menubar.find add command \
336 -command {Libr_do_FindType} \
337 -label {Type by name...} \
338 -accelerator {Alt-i t} \
339 -underline 0
340 .library.menubar.find add command \
341 -command {Libr_do_FindFuzzy} \
342 -label {Type by fuzzy name...} \
343 -accelerator {Alt-i f} \
344 -underline 8
345 .library.menubar.find add cascade \
346 -menu .library.menubar.find.pendings \
347 -accelerator {Alt-i p} \
348 -label {Pending statements} \
349 -underline 0
350
351 # The Pendings submenu under the Find menu
352 menu .library.menubar.find.pendings \
353 -tearoffcommand .LIBRARY.MENUBAR.FIND.PENDINGS \
354 -tearoff 0
355 .library.menubar.find.pendings add command \
356 -command {Disp_do_ShowPendings} \
357 -accelerator {Alt-i p d} \
358 -label {To Display} \
359 -underline 3
360 .library.menubar.find.pendings add command \
361 -command {Sims_Pendings_To_Stdout} \
362 -accelerator {Alt-i p c} \
363 -label {To Console} \
364 -underline 3
365 .library.menubar.find.pendings add command \
366 -command {Sims_Pendings_To_File} \
367 -accelerator {Alt-i p f} \
368 -label {To File ...} \
369 -underline 3
370
371
372
373 # The Help menu
374 menu .library.menubar.help \
375 -tearoffcommand .LIBRARY.MENUBAR.HELP \
376 -tearoff 0
377 .library.menubar.help add command \
378 -command {Libr_do_Help} \
379 -label {On Library} \
380 -underline 3
381
382
383 # The option menu
384 menu .library.menubar.option \
385 -tearoffcommand .LIBRARY.MENUBAR.OPTION \
386 -tearoff 0
387 .library.menubar.option add radiobutton \
388 -label {Report all parser messages} \
389 -underline 6 \
390 -accelerator {Alt-o a} \
391 -selectcolor red \
392 -variable ascLibrVect(parserWarnings) \
393 -value 1
394 .library.menubar.option add radiobutton \
395 -label {Suppress parser style messages} \
396 -underline 9 \
397 -accelerator {Alt-o p} \
398 -selectcolor red \
399 -variable ascLibrVect(parserWarnings) \
400 -value 2
401 .library.menubar.option add radiobutton \
402 -label {Suppress parser warning messages} \
403 -underline 16 \
404 -accelerator {Alt-o w} \
405 -selectcolor red \
406 -variable ascLibrVect(parserWarnings) \
407 -value 3
408 .library.menubar.option add radiobutton \
409 -label {Suppress parser error messages} \
410 -underline 16 \
411 -accelerator {Alt-o e} \
412 -selectcolor red \
413 -variable ascLibrVect(parserWarnings) \
414 -value 4
415 .library.menubar.option add separator
416 .library.menubar.option add checkbutton \
417 -offvalue {0} \
418 -onvalue {1} \
419 -variable {ascLibrVect(compileC)} \
420 -label {Generate C binary} \
421 -accelerator {Alt-o b} \
422 -underline 11
423 .library.menubar.option add checkbutton \
424 -offvalue {1} \
425 -onvalue {0} \
426 -variable {ascLibrVect(ignorestop)} \
427 -label {Ignore STOP in METHODS} \
428 -accelerator {Alt-o i} \
429 -underline 0
430 .library.menubar.option add checkbutton \
431 -offvalue {1} \
432 -onvalue {0} \
433 -variable {ascLibrVect(compilerWarnings)} \
434 -label {Suppress compiler error messages} \
435 -accelerator {Alt-o m} \
436 -underline 24
437 .library.menubar.option add checkbutton \
438 -offvalue {0} \
439 -onvalue {1} \
440 -variable {ascLibrVect(simplifyRelations)} \
441 -label {Simplify compiled equations} \
442 -accelerator {Alt-o c} \
443 -underline 9
444 .library.menubar.option add checkbutton \
445 -offvalue {0} \
446 -onvalue {1} \
447 -variable {ascLibrVect(useCopyAnon)} \
448 -label {Use relation sharing by anonymous type} \
449 -accelerator {Alt-o r} \
450 -underline 4
451 .library.menubar.option add separator
452 .library.menubar.option add command \
453 -command {Libr_do_SaveOption} \
454 -label {Save options} \
455 -accelerator {Alt-o s} \
456 -underline 0
457
458 # The view menu
459 menu .library.menubar.view \
460 -tearoffcommand .LIBRARY.MENUBAR.VIEW \
461 -tearoff 0
462 .library.menubar.view add command \
463 -command {Libr_do_Font} \
464 -label {Font ...} \
465 -accelerator {Alt-v f} \
466 -underline 0
467 .library.menubar.view add checkbutton \
468 -offvalue {0} \
469 -onvalue {1} \
470 -variable {ascLibrVect(visibility)} \
471 -label {Open automatically} \
472 -accelerator {Alt-v o} \
473 -underline 0
474 .library.menubar.view add command \
475 -command {View_Save_Window_Appearance library} \
476 -accelerator {Alt-v s} \
477 -label {Save appearance} \
478 -underline 0
479
480 #
481 # Add the menus as cascades of the toplevel's menu;
482 # add the toplevel's menu to the toplevel
483 #
484 .library.menubar add cascade \
485 -menu .library.menubar.file \
486 -label {File} \
487 -underline 0
488 .library.menubar add cascade \
489 -menu .library.menubar.edit \
490 -label {Edit} \
491 -underline 0
492 .library.menubar add cascade \
493 -menu .library.menubar.display \
494 -label {Display} \
495 -underline 0
496 .library.menubar add cascade \
497 -menu .library.menubar.find \
498 -label {Find} \
499 -underline 1
500 .library.menubar add cascade \
501 -menu .library.menubar.option \
502 -label {Options} \
503 -underline 0
504 .library.menubar add cascade \
505 -menu .library.menubar.view \
506 -label {View} \
507 -underline 0
508 .library.menubar add cascade \
509 -menu .library.menubar.export \
510 -label {Export} \
511 -underline 1
512 .library.menubar add cascade \
513 -menu .library.menubar.help \
514 -label {Help} \
515 -underline 0
516 .library configure \
517 -menu .library.menubar
518
519
520 #
521 # Pack the library widget
522 #
523 pack append .library \
524 .library.main_frm {top frame center expand fill} \
525 .library.entry_frm {top frame center fillx} \
526 .library.sims_frm {top frame center fillx}
527
528 EndSrc.library
529
530 if {"[info procs XFEdit]" != ""} {
531 catch "XFMiscBindWidgetTree .library"
532 after 2 "catch {XFEditSetShowWindows}"
533 }
534 }
535
536 # proc DestroyWindow.library {}
537 proc DestroyWindow.library {} {# xf ignore me 7
538 if {"[info procs XFEdit]" != ""} {
539 if {"[info commands .library]" != ""} {
540 global xfShowWindow.library
541 set xfShowWindow.library 0
542 XFEditSetPath .
543 after 2 "XFSaveAsProc .library; XFEditSetShowWindows"
544 }
545 } {
546 catch "destroy .library"
547 update
548 }
549 }
550
551 # proc StartupSrc.library {args}
552 proc StartupSrc.library {args} {
553 # library startup entrance
554 # as much of the C/global dependencies managed here as possible
555 global ascLibrVect ascGlobalVect env
556 if {[catch {set ascLibrVect(windowname)} ]} {
557 set ascLibrVect(minsize) 100x100
558 set ascLibrVect(geometry) 350x350+10+10
559 set ascLibrVect(iconname) Library
560 set ascLibrVect(initialstate) normal
561 }
562 if {[catch {set ascGlobalVect(font)} ]} {
563 set ascGlobalVect(font) "-*-*"
564 set ascGlobalVect(labelfont) "-*-*"
565 set ascGlobalVect(tbg) "white"
566 set ascGlobalVect(tfg) "black"
567 set ascGlobalVect(bg) "white"
568 set ascGlobalVect(fg) "black"
569 set ascGlobalVect(afg) "white"
570 set ascGlobalVect(abg) "black"
571 set ascGlobalVect(sfg) "white"
572 set ascGlobalVect(sbg) "black"
573 set ascGlobalVect(visibility) 1
574 set ascGlobalVect(c_loaded) "0"
575 set ascGlobalVect(toolbitmap) \
576 "@$env(ASCENDBITMAPS)/toolAttributes.xbm"
577 }
578 }
579
580 # proc EndSrc.library {}
581 proc EndSrc.library {} {
582 # library startup exit
583 global ascLibrVect env
584 set ascLibrVect(geometry) [sanegeometry $ascLibrVect(geometry)]
585 set minw [lindex [split $ascLibrVect(minsize) x] 0]
586 set minh [lindex [split $ascLibrVect(minsize) x] 1]
587 set gw [lindex [split [lindex [split $ascLibrVect(geometry) +] 0] x] 0]
588 set gh [lindex [split [lindex [split $ascLibrVect(geometry) +] 0] x] 1]
589 set gp "+[lindex [split [split $ascLibrVect(geometry) x] +] 1]+[lindex [split [split $ascLibrVect(geometry) x] +] 2]"
590 if {[expr $gw < $minw]} {set gw $minw}
591 if {[expr $gh < $minh]} {set gh $minh}
592 set gwh "${gw}x${gh}"
593 wm minsize .library $minw $minh
594 wm geometry .library [osgpos $gwh$gp]
595 wm iconname .library $ascLibrVect(iconname)
596
597 if {$ascLibrVect(initialstate)!="iconic" && \
598 $ascLibrVect(initialstate)!="iconified" && \
599 $ascLibrVect(initialstate)!="withdrawn"} {
600 wm deiconify .library
601 }
602 if {$ascLibrVect(initialstate)=="withdrawn"} {
603 wm withdraw .library
604 }
605 }
606
607
608 # eof
609 #

john.pye@anu.edu.au
ViewVC Help
Powered by ViewVC 1.1.22