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

Annotation of /trunk/tcltk/TK/library.tcl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 659 - (hide annotations) (download) (as text)
Sun Jun 4 20:01:04 2006 UTC (16 years, 9 months ago) by ben.allan
File MIME type: text/x-tcl
File size: 18367 byte(s)
added File->Open everywhere equivalent to File->Read ...  to resolve pye request.
At a 1.0 release of tcltk, we should consider getting rid of
the file reads, but not before. existing users have muscle memories
that are not to be toyed with.
1 johnpye 571 # 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 ben.allan 659 .library.menubar.file add command \
314     -command {Libr_do_read} \
315     -label {Open type file...} \
316     -accelerator {Alt-f o} \
317     -underline 0
318 johnpye 571 .library.menubar.file add separator
319     .library.menubar.file add command \
320     -command {Toggle_Remote ascLibrVect} \
321     -label {Close window} \
322     -accelerator {Alt-f c} \
323     -underline 0
324     .library.menubar.file add command \
325     -command {Script_do_Exit} \
326     -accelerator {Alt-f e} \
327     -label {Exit ASCEND...} \
328     -underline 0
329    
330    
331     # The Find menu
332     menu .library.menubar.find \
333     -tearoffcommand .LIBRARY.MENUBAR.FIND \
334     -tearoff 0
335     .library.menubar.find add command \
336     -command {Libr_do_FindAtom} \
337     -label {ATOM by units...} \
338     -accelerator {Alt-i a} \
339     -underline 0
340     .library.menubar.find add command \
341     -command {Libr_do_FindType} \
342     -label {Type by name...} \
343     -accelerator {Alt-i t} \
344     -underline 0
345     .library.menubar.find add command \
346     -command {Libr_do_FindFuzzy} \
347     -label {Type by fuzzy name...} \
348     -accelerator {Alt-i f} \
349     -underline 8
350     .library.menubar.find add cascade \
351     -menu .library.menubar.find.pendings \
352     -accelerator {Alt-i p} \
353     -label {Pending statements} \
354     -underline 0
355    
356     # The Pendings submenu under the Find menu
357     menu .library.menubar.find.pendings \
358     -tearoffcommand .LIBRARY.MENUBAR.FIND.PENDINGS \
359     -tearoff 0
360     .library.menubar.find.pendings add command \
361     -command {Disp_do_ShowPendings} \
362     -accelerator {Alt-i p d} \
363     -label {To Display} \
364     -underline 3
365     .library.menubar.find.pendings add command \
366     -command {Sims_Pendings_To_Stdout} \
367     -accelerator {Alt-i p c} \
368     -label {To Console} \
369     -underline 3
370     .library.menubar.find.pendings add command \
371     -command {Sims_Pendings_To_File} \
372     -accelerator {Alt-i p f} \
373     -label {To File ...} \
374     -underline 3
375    
376    
377    
378     # The Help menu
379     menu .library.menubar.help \
380     -tearoffcommand .LIBRARY.MENUBAR.HELP \
381     -tearoff 0
382     .library.menubar.help add command \
383     -command {Libr_do_Help} \
384     -label {On Library} \
385     -underline 3
386    
387    
388     # The option menu
389     menu .library.menubar.option \
390     -tearoffcommand .LIBRARY.MENUBAR.OPTION \
391     -tearoff 0
392     .library.menubar.option add radiobutton \
393     -label {Report all parser messages} \
394     -underline 6 \
395     -accelerator {Alt-o a} \
396     -selectcolor red \
397     -variable ascLibrVect(parserWarnings) \
398     -value 1
399     .library.menubar.option add radiobutton \
400     -label {Suppress parser style messages} \
401     -underline 9 \
402     -accelerator {Alt-o p} \
403     -selectcolor red \
404     -variable ascLibrVect(parserWarnings) \
405     -value 2
406     .library.menubar.option add radiobutton \
407     -label {Suppress parser warning messages} \
408     -underline 16 \
409     -accelerator {Alt-o w} \
410     -selectcolor red \
411     -variable ascLibrVect(parserWarnings) \
412     -value 3
413     .library.menubar.option add radiobutton \
414     -label {Suppress parser error messages} \
415     -underline 16 \
416     -accelerator {Alt-o e} \
417     -selectcolor red \
418     -variable ascLibrVect(parserWarnings) \
419     -value 4
420     .library.menubar.option add separator
421     .library.menubar.option add checkbutton \
422     -offvalue {0} \
423     -onvalue {1} \
424     -variable {ascLibrVect(compileC)} \
425     -label {Generate C binary} \
426     -accelerator {Alt-o b} \
427     -underline 11
428     .library.menubar.option add checkbutton \
429     -offvalue {1} \
430     -onvalue {0} \
431     -variable {ascLibrVect(ignorestop)} \
432     -label {Ignore STOP in METHODS} \
433     -accelerator {Alt-o i} \
434     -underline 0
435     .library.menubar.option add checkbutton \
436     -offvalue {1} \
437     -onvalue {0} \
438     -variable {ascLibrVect(compilerWarnings)} \
439     -label {Suppress compiler error messages} \
440     -accelerator {Alt-o m} \
441     -underline 24
442     .library.menubar.option add checkbutton \
443     -offvalue {0} \
444     -onvalue {1} \
445     -variable {ascLibrVect(simplifyRelations)} \
446     -label {Simplify compiled equations} \
447     -accelerator {Alt-o c} \
448     -underline 9
449     .library.menubar.option add checkbutton \
450     -offvalue {0} \
451     -onvalue {1} \
452     -variable {ascLibrVect(useCopyAnon)} \
453     -label {Use relation sharing by anonymous type} \
454     -accelerator {Alt-o r} \
455     -underline 4
456     .library.menubar.option add separator
457     .library.menubar.option add command \
458     -command {Libr_do_SaveOption} \
459     -label {Save options} \
460     -accelerator {Alt-o s} \
461     -underline 0
462    
463     # The view menu
464     menu .library.menubar.view \
465     -tearoffcommand .LIBRARY.MENUBAR.VIEW \
466     -tearoff 0
467     .library.menubar.view add command \
468     -command {Libr_do_Font} \
469     -label {Font ...} \
470     -accelerator {Alt-v f} \
471     -underline 0
472     .library.menubar.view add checkbutton \
473     -offvalue {0} \
474     -onvalue {1} \
475     -variable {ascLibrVect(visibility)} \
476     -label {Open automatically} \
477     -accelerator {Alt-v o} \
478     -underline 0
479     .library.menubar.view add command \
480     -command {View_Save_Window_Appearance library} \
481     -accelerator {Alt-v s} \
482     -label {Save appearance} \
483     -underline 0
484    
485     #
486     # Add the menus as cascades of the toplevel's menu;
487     # add the toplevel's menu to the toplevel
488     #
489     .library.menubar add cascade \
490     -menu .library.menubar.file \
491     -label {File} \
492     -underline 0
493     .library.menubar add cascade \
494     -menu .library.menubar.edit \
495     -label {Edit} \
496     -underline 0
497     .library.menubar add cascade \
498     -menu .library.menubar.display \
499     -label {Display} \
500     -underline 0
501     .library.menubar add cascade \
502     -menu .library.menubar.find \
503     -label {Find} \
504     -underline 1
505     .library.menubar add cascade \
506     -menu .library.menubar.option \
507     -label {Options} \
508     -underline 0
509     .library.menubar add cascade \
510     -menu .library.menubar.view \
511     -label {View} \
512     -underline 0
513     .library.menubar add cascade \
514     -menu .library.menubar.export \
515     -label {Export} \
516     -underline 1
517     .library.menubar add cascade \
518     -menu .library.menubar.help \
519     -label {Help} \
520     -underline 0
521     .library configure \
522     -menu .library.menubar
523    
524    
525     #
526     # Pack the library widget
527     #
528     pack append .library \
529     .library.main_frm {top frame center expand fill} \
530     .library.entry_frm {top frame center fillx} \
531     .library.sims_frm {top frame center fillx}
532    
533     EndSrc.library
534    
535     if {"[info procs XFEdit]" != ""} {
536     catch "XFMiscBindWidgetTree .library"
537     after 2 "catch {XFEditSetShowWindows}"
538     }
539     }
540    
541     # proc DestroyWindow.library {}
542     proc DestroyWindow.library {} {# xf ignore me 7
543     if {"[info procs XFEdit]" != ""} {
544     if {"[info commands .library]" != ""} {
545     global xfShowWindow.library
546     set xfShowWindow.library 0
547     XFEditSetPath .
548     after 2 "XFSaveAsProc .library; XFEditSetShowWindows"
549     }
550     } {
551     catch "destroy .library"
552     update
553     }
554     }
555    
556     # proc StartupSrc.library {args}
557     proc StartupSrc.library {args} {
558     # library startup entrance
559     # as much of the C/global dependencies managed here as possible
560     global ascLibrVect ascGlobalVect env
561     if {[catch {set ascLibrVect(windowname)} ]} {
562     set ascLibrVect(minsize) 100x100
563     set ascLibrVect(geometry) 350x350+10+10
564     set ascLibrVect(iconname) Library
565     set ascLibrVect(initialstate) normal
566     }
567     if {[catch {set ascGlobalVect(font)} ]} {
568     set ascGlobalVect(font) "-*-*"
569     set ascGlobalVect(labelfont) "-*-*"
570     set ascGlobalVect(tbg) "white"
571     set ascGlobalVect(tfg) "black"
572     set ascGlobalVect(bg) "white"
573     set ascGlobalVect(fg) "black"
574     set ascGlobalVect(afg) "white"
575     set ascGlobalVect(abg) "black"
576     set ascGlobalVect(sfg) "white"
577     set ascGlobalVect(sbg) "black"
578     set ascGlobalVect(visibility) 1
579     set ascGlobalVect(c_loaded) "0"
580     set ascGlobalVect(toolbitmap) \
581     "@$env(ASCENDBITMAPS)/toolAttributes.xbm"
582     }
583     }
584    
585     # proc EndSrc.library {}
586     proc EndSrc.library {} {
587     # library startup exit
588     global ascLibrVect env
589     set ascLibrVect(geometry) [sanegeometry $ascLibrVect(geometry)]
590     set minw [lindex [split $ascLibrVect(minsize) x] 0]
591     set minh [lindex [split $ascLibrVect(minsize) x] 1]
592     set gw [lindex [split [lindex [split $ascLibrVect(geometry) +] 0] x] 0]
593     set gh [lindex [split [lindex [split $ascLibrVect(geometry) +] 0] x] 1]
594     set gp "+[lindex [split [split $ascLibrVect(geometry) x] +] 1]+[lindex [split [split $ascLibrVect(geometry) x] +] 2]"
595     if {[expr $gw < $minw]} {set gw $minw}
596     if {[expr $gh < $minh]} {set gh $minh}
597     set gwh "${gw}x${gh}"
598     wm minsize .library $minw $minh
599     wm geometry .library [osgpos $gwh$gp]
600     wm iconname .library $ascLibrVect(iconname)
601    
602     if {$ascLibrVect(initialstate)!="iconic" && \
603     $ascLibrVect(initialstate)!="iconified" && \
604     $ascLibrVect(initialstate)!="withdrawn"} {
605     wm deiconify .library
606     }
607     if {$ascLibrVect(initialstate)=="withdrawn"} {
608     wm withdraw .library
609     }
610     }
611    
612    
613     # eof
614     #

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