File: cmd.tk

package info (click to toggle)
dstooltk 2.0-4
  • links: PTS
  • area: main
  • in suites: woody
  • size: 2,520 kB
  • ctags: 3,169
  • sloc: ansic: 27,185; tcl: 4,770; makefile: 588; sh: 81; csh: 7
file content (158 lines) | stat: -rw-r--r-- 4,522 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
#
# cmd.tk
#

proc cmd(build) name {
    global COLOR FONT Control Model env

    wm title .cmd "$Control(Version)"

    build_Menubar $name mbar \
	{"Help" \
	     {"Model..." "window(open) help_model"} \
	     {"File..." "help_file(build)"} \
	     {} \
	     {"About DsTool..." "window(open) version"} \
	 } \
	{"File" \
	     {"Save ..." "window(open) save"} \
	     {"Load ..." "window(open) load"} \
	     {"Print..." "window(open) print"} \
	     {} \
	     {"Exit" cmd(exit)} \
	 } \
	{"Models" \
	 } \
	{"Panels" \
	     {"One-D..." "window(mult_open) oneD"} \
	     {"Two-D..." "window(mult_open) twoD"} \
	     {"Three-D(Geomview)..." "window(open) threeD"} \
	     {"Animation(Geomview)..." "window(open) geomview"} \
	     {} \
	     {"Selected..." "window(open) selected"} \
	     {"Function..." "window(open) function"} \
	     {"Defaults..." "window(open) defaults"} \
	     {"Browser..."  "window(open) browser"} \
	     {} \
	     {"Orbits..." "window(open) orbits"} \
	     {"Multiple..." "window(open) multiple"} \
	     {"Fixed points..." "window(open) fixed"} \
	     {"Periodic orbits..." "window(open) periodic"} \
	     {"Equilibrium Continuation..." "window(open) continuation"} \
	 }

    # create message labels
    if { [ winfo exists $name.cmd ] == 0 } {
	set cmd [build_CmdFrame $name cmd]
	set cm1 [build_StdFrame $cmd cm1]
	label $cm1.modeltag -text "Model:" -bg $COLOR(bg) -font $FONT(label)
	label $cm1.model -textvariable Model(Name) -bg $COLOR(bg) -font $FONT(label) -fg $COLOR(info)
	label $cm1.pointstag -text "Points:" -bg $COLOR(bg) -font $FONT(label)
	label $cm1.points -textvariable Memory(Points) -bg $COLOR(bg) -font $FONT(label) -fg $COLOR(info)
	pack $cm1.modeltag $cm1.model -side left -in $cm1 -anchor w
	pack $cm1.points $cm1.pointstag -in $cm1 -side right 
	pack $cm1 -fill x

	label $cmd.main_label -width 40 -textvariable main(message) \
	    -bg $COLOR(bg) -font $FONT(biglabel) -fg red
	pack $cmd.main_label -anchor n -fill both -expand 1

	pack $cmd

	# build models
	cmd_models $name.mbar.b1.menu
	
	bind $cmd.main_label <Control-c> {tcl_interrupt}
    }

    # enable/disable oneD maps option
    if {$Model(Mapping_Flag) && ($Model(Varb_Dim) == 2)} {
	$name.mbar.b2.menu entryconfigure \
	    [$name.mbar.b2.menu index "One-D..."] \
	    -state normal
    } {
	$name.mbar.b2.menu entryconfigure \
	    [$name.mbar.b2.menu index "One-D..."] \
	    -state disabled
    }

    # don't allow resizing of cmd window
    update
    window(fix_size) $name

    # set icon name and pixmap
    wm iconname $name DsTool
    wm iconbitmap .cmd @$env(DSTOOL)/tcl/dstool.xbm
}

#
# Add models and categories to the models button on the menu bar.
#
proc cmd_models mname {
    global Model COLOR FONT

    # create model categories
    for {set i 0} {$i < $Model(N_Categories)} {incr i} {
	$mname add cascade -label $Model(Cat_Names,$i) -menu $mname.m$i
	menu $mname.m$i -bg $COLOR(bg) -activebackground $COLOR(abg) -font $FONT(label)
    }
    # add model names
    for {set i 0} {$i < $Model(N_Models)} {incr i} {
	$mname.m$Model(Categories,$i) add command -label $Model(Names,$i) \
	    -command "load_model $i"
    }
    # add parser option
    $mname add command -label "Parser..." -command "window(open) parser"
}

proc cmd(exit) {} {
#    if {[build_Dialog dialog "Exit" "Really EXIT DSTool?" \
#	 0 EXIT Cancel] == 0} {
	exit
#    }
}


proc cmd(add_to_panels) {name command} {
    set cmd [build_Wname cmd]
    if {[string length $name] > 0} {
	# add menu item
	$cmd.mbar.b2.menu add command -label $name -command $command
    } else {
	# add separator
	$cmd.mbar.b2.menu add separator
    }
}

proc cmd(remove_from_panels) name {
    set cmd [build_Wname cmd]
    set i [$cmd.mbar.b2.menu index $name]
    $cmd.mbar.b2.menu delete $i
}

proc cmd(dismiss) {} {
    exit
}

proc cmd(update_features) {} {
    global COLOR FONT Model

    set cmd .cmd.cmd
    set cm1 .cmd.cmd.cm1

    $cmd configure -bg $COLOR(bg) 
    .cmd.mbar configure -bg $COLOR(bg)
    
    $cm1.modeltag configure -bg $COLOR(bg) -font $FONT(label)
    $cm1.model configure -bg $COLOR(bg) -font $FONT(label)
    $cm1.pointstag configure -bg $COLOR(bg) -font $FONT(label)
    $cm1.points configure -bg $COLOR(bg) -font $FONT(label) -fg $COLOR(info)

    $cmd.main_label configure -bg $COLOR(bg) -font $FONT(biglabel) -fg red

    for {set i 0} {$i < $Model(N_Categories)} {incr i} {
        .cmd.mbar.b1.menu.m$i configure -bg $COLOR(bg) -activebackground $COLOR(abg) -font $FONT(label)
    }

}