Minsky
variablePane.tcl
Go to the documentation of this file.
1 set checkButtons {}
2 set varTypes {parameter flow integral stock}
3 
4 proc variablePane {} {
5  global varTypes checkButtons
6  if {![winfo exists .variablePane]} {
7  toplevel .variablePane
8  wm title .variablePane "Variables"
9  # selection buttons
10  frame .variablePane.buttons
11  button .variablePane.buttons.all -text All -command {
12  foreach button $checkButtons {$button select}
13  minsky.variablePane.selection $varTypes
14  minsky.variablePane.updateWithHeight [.variablePane.canvas cget -height]
15  }
16  pack .variablePane.buttons.all -side left
17  foreach type $varTypes {
18  label .variablePane.buttons.${type}Text -text $type
19  checkbutton .variablePane.buttons.$type -variable variablePaneButtons($type) -command "variablePaneButtonProc $type"
20  lappend checkButtons .variablePane.buttons.$type
21  .variablePane.buttons.$type select
22  pack .variablePane.buttons.$type .variablePane.buttons.${type}Text -side left
23  }
24  pack .variablePane.buttons
25  image create cairoSurface variableImage -surface minsky.variablePane
26  label .variablePane.canvas -image variableImage -width 300 -height 1000
27  pack .variablePane.canvas -fill both -expand 1
28  bind .variablePane.canvas <Configure> {minsky.variablePane.updateWithHeight %h}
29  bind .variablePane <KeyPress-Shift_L> {minsky.variablePane.shift 1; .variablePane.canvas configure -cursor $panIcon}
30  bind .variablePane <KeyRelease-Shift_L> {minsky.variablePane.shift 0; .variablePane.canvas configure -cursor {}}
31  bind .variablePane.canvas <ButtonPress-1> {catch {minsky.variablePane.mouseDown %x %y}}
32  bind .variablePane.canvas <ButtonRelease-1> {minsky.variablePane.mouseUp %x %y}
33  bind .variablePane.canvas <B1-Motion> {minsky.variablePane.mouseMove %x %y}
34  }
35  raise .variablePane
37 }
38 
39 proc updateVariablePane {} {minsky.variablePane.updateWithHeight [winfo height .variablePane]}
40 
41 proc variablePaneButtonProc {type} {
42  global variablePaneButtons
43  if {$variablePaneButtons($type)} {
44  minsky.variablePane.select $type
45  } else {
46  minsky.variablePane.deselect $type
47  }
49 }