Update of /cvsroot/pure-data/pd/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27547
Modified Files: Tag: devel_0_39 desire.tk Log Message: breaking down def Dialog add.
Index: desire.tk =================================================================== RCS file: /cvsroot/pure-data/pd/src/Attic/desire.tk,v retrieving revision 1.1.2.553 retrieving revision 1.1.2.554 diff -C2 -d -r1.1.2.553 -r1.1.2.554 *** desire.tk 17 Nov 2006 02:13:29 -0000 1.1.2.553 --- desire.tk 17 Nov 2006 05:45:01 -0000 1.1.2.554 *************** *** 6138,6143 **** class_new Dialog {Thing}
! def Dialog add_side {w args} {
}
--- 6138,6273 ---- class_new Dialog {Thing}
! def Dialog add_side {f name label} { ! frame $f ! pack [label $f.label -text $label] -side left ! frame $f.side -relief ridge -borderwidth 2 ! foreach {i side} {0 left 1 right 2 top 3 bottom} { ! radiobutton $f.side.$side -value $i -variable @$name -text $side ! } ! pack $f.side.left -side left -fill y ! pack $f.side.right -side right -fill y ! pack $f.side.top -side top ! pack $f.side.bottom -side bottom ! pack $f.side -side left ! } ! ! def Dialog add_color {f name label} { ! set v $_($self:$name) ;# bug in poetcl ! frame $f ! label $f.label -text $label ! set text_color [complement $v] ! button $f.color -text $v -font {Courier 10} -width 10 -pady 2 -fg $text_color \ ! -command [list $self choose_col $f $name $v] -relief sunken -background $v \ ! -highlightbackground "#ffffff" -activebackground [darker $v] ! button $f.preset -text "preset" -pady 2 -font {Helvetica 8} \ ! -command [list $self color_popup $f $name 10] ! bind $f.preset <Return> "$self color_popup $f $name 10" ! pack $f.label $f.color $f.preset -side left ! } ! ! def Dialog add_choice {f name label choices options} { ! set v $_($self:$name) ;# bug in poetcl ! frame $f ! label $f.label -text $label ! menu $f.menu -tearoff 0 ! set i 0 ! foreach part $choices { ! $f.menu add command -label [say $part] \ ! -command [list $self dropmenu_set $f $name $part $i] ! incr i ! } ! if {[llength $v]==0} {set v 0; set @$name 0} ;# hack ! label $f.butt -text [say [lindex $choices $v]] -relief raised -width 20 ! balloon $f.butt "click to change setting" ! pack $f.label $f.butt -side left ! bind $f.butt <1> [list $self dropmenu_open $f] ! } ! ! def Dialog add_key {f name label} { ! frame $f ! set text "" ! set n 0 ! foreach item $name { ! if {$n != 0} {append text " & " [say $item]} else {set text [say $item]} ! incr n ! } ! pack [label $f.label -text $text] -side left ! #balloon $f.label $name ! foreach item $name { ! set v $_($self:$item) ;# bug in objtcl ! set item_lower [string tolower $item] ! #eval "entry $f.$item_lower -textvariable $_($self:$item) -width 15" ! eval "entry $f.$item_lower -width 15" ! $f.$item_lower insert 0 $v ! pack $f.$item_lower -side left ! #bind $f.$item <Return> "" ! } ! } ! ! def Dialog add_folders {f name label} { ! set v $_($self:$name) ;# bug in poetcl ! set no_max_label 1 ! frame $f ! frame $f.a ! pack [label $f.label -text $label -width 20 -anchor e] -side left ! listbox $f.a.list -width 50 -height 8 -yscrollcommand "$f.a.yscroll set" \ ! -activestyle none -xscrollcommand "$f.a.xscroll set" ! foreach line $v {$f.a.list insert end $line} ! set @$name $f.a.list ;# save the listbox path at @$name instead ! scrollbar $f.a.yscroll -command "$f.a.list yview" ! scrollbar $f.a.xscroll -command "$f.a.list xview" -orient horizontal ! pack $f.a.xscroll -side bottom -fill x ! pack $f.a.list -side left -fill both -expand 1 ! pack $f.a.yscroll -side left -fill y ! pack $f.a -side left ! frame $f.b -borderwidth 0 ! foreach {cmd lab} {dir_add add listbox_remove remove listbox_up up listbox_down down} { ! pack [button $f.b.$cmd -command "$self $cmd $f.a.list" -text [say $lab] -width 6] -side top ! balloon $f.b.$cmd [say dir_$lab] ! } ! pack $f.b -side top ! } ! ! def Dialog add_libraries {f name label} { ! set v $_($self:$name) ;# bug in objtcl ! set no_max_label 1 ! frame $f ! frame $f.a ! pack [label $f.label -text $label -width 20 -anchor e] -side left ! listbox $f.a.list -width 33 -height 10 -yscrollcommand "$f.a.yscroll set" \ ! -activestyle none -xscrollcommand "$f.a.xscroll set" ! #foreach line $@$name {$f.a.list insert end $line} ! foreach line $v {$f.a.list insert end $line} ! # save the listbox path at @$name instead ! set @$name $f.a.list ! scrollbar $f.a.yscroll -command "$f.a.list yview" ! scrollbar $f.a.xscroll -command "$f.a.list xview" -orient horizontal ! ! pack $f.a.xscroll -side bottom -fill x ! pack $f.a.list -side left -fill both -expand 1 ! pack $f.a.yscroll -side left -fill y ! pack $f.a -side left ! ! frame $f.b -borderwidth 0 ! frame $f.b.entry -borderwidth 0 ! frame $f.b.butts -borderwidth 0 ! ! entry $f.b.entry.add -width 15 -borderwidth 5 -relief ridge ! bind $f.b.entry.add <Return> "$self lib_add $f" ! pack $f.b.entry.add -side left
+ foreach {w cmd lab width padx} { + entry.3 lib_add add 6 0 + butts.4 listbox_up up 4 3 + butts.5 listbox_down down 4 2 + butts.6 listbox_remove remove 6 2 + } { + button $f.b.$w -command "$self $cmd $f" -text [say $lab] -width $width + balloon $f.b.$w [say lib_$lab] + pack $f.b.$w -side left -padx $padx + } + pack $f.b.entry -side top + pack $f.b.butts -side top + pack $f.b -side top }
*************** *** 6157,6210 **** } #set v $@$name ! #set v $_($self:$name) ;# bug in objtcl switch -- $type { ! side { ! frame $f ! pack [label $f.label -text $label] -side left ! frame $f.side -relief ridge -borderwidth 2 ! foreach {i side} {0 left 1 right 2 top 3 bottom} { ! radiobutton $f.side.$side -value $i \ ! -variable @$name -text $side ! } ! pack $f.side.left -side left -fill y ! pack $f.side.right -side right -fill y ! pack $f.side.top -side top ! pack $f.side.bottom -side bottom ! pack $f.side -side left ! } ! color { ! set v $_($self:$name) ;# bug in objtcl ! frame $f ! label $f.label -text $label ! set text_color [complement $v] ! button $f.color -text $v -font {Courier 10} -width 10 -pady 2 -fg $text_color \ ! -command [list $self choose_col $f $name $v] \ ! -relief sunken -background $v \ ! -highlightbackground "#ffffff" -activebackground [darker $v] ! button $f.preset -text "preset" -pady 2 -font {Helvetica 8} \ ! -command [list $self color_popup $f $name 10] ! bind $f.preset <Return> "$self color_popup $f $name 10" ! pack $f.label $f.color $f.preset -side left ! } ! choice { ! set v $_($self:$name) ;# bug in objtcl ! frame $f ! label $f.label -text $label ! menu $f.menu -tearoff 0 ! set i 0 ! foreach part $choices { ! $f.menu add command -label [say $part] \ ! -command [list $self dropmenu_set $f $name $part $i] ! incr i ! } ! if {[llength $v]==0} {set v 0; set @$name 0} ;# hack ! label $f.butt -text [say [lindex $choices $v]] -relief raised -width 20 ! balloon $f.butt "click to change setting" ! pack $f.label $f.butt -side left ! bind $f.butt <1> [list $self dropmenu_open $f] ! } ! subsection { ! label $f -text $label -bg "#0000aa" -fg "#ffff55" -font {helvetica -10 bold} ! } toggle { frame $f --- 6287,6301 ---- } #set v $@$name ! #set v $_($self:$name) ;# bug in poetcl switch -- $type { ! side {$self add_side $f $name $label} ! color {$self add_color $f $name $label} ! choice {$self add_choice $f $name $label $choices $options} ! key {set f $w.[string tolower [lindex $name 0]] ! $self add_key $f $name $label} ! folders {$self add_folders $f $name $label} ! libraries {$self add_libraries $f $name $label} ! section {label $f -text $label -bg "#0000aa" -fg "#ffff55" -font {helvetica -10 bold}} ! subsection {label $f -text $label -bg "#0000aa" -fg "#ffff55" -font {helvetica -10 bold}} toggle { frame $f *************** *** 6213,6320 **** pack $f.label -side left pack $f.toggle -side left - #pack $f.label -side right - } - section { - label $f -text $label -bg "#0000aa" -fg "#ffff55" -font {helvetica -10 bold} - } - key { - set f $w.[string tolower [lindex $name 0]] - frame $f - set text "" - set n 0 - #foreach item $choices { - # if {$n != 0} {append text " & " [say $item]} else {set text [say $item]} - # incr n - #} - foreach item $name { - if {$n != 0} {append text " & " [say $item]} else {set text [say $item]} - incr n - } - pack [label $f.label -text $text] -side left - #balloon $f.label $name - foreach item $name { - set v $_($self:$item) ;# bug in objtcl - set item_lower [string tolower $item] - #eval "entry $f.$item_lower -textvariable $_($self:$item) -width 15" - eval "entry $f.$item_lower -width 15" - $f.$item_lower insert 0 $v - pack $f.$item_lower -side left - #bind $f.$item <Return> "" - } - } - folders { - set v $_($self:$name) ;# bug in objtcl - set no_max_label 1 - frame $f - frame $f.a - pack [label $f.label -text $label -width 20 -anchor e] -side left - listbox $f.a.list -width 50 -height 8 -yscrollcommand "$f.a.yscroll set" \ - -activestyle none -xscrollcommand "$f.a.xscroll set" - foreach line $v {$f.a.list insert end $line} - set @$name $f.a.list ;# save the listbox path at @$name instead - scrollbar $f.a.yscroll -command "$f.a.list yview" - scrollbar $f.a.xscroll -command "$f.a.list xview" -orient horizontal - - pack $f.a.xscroll -side bottom -fill x - pack $f.a.list -side left -fill both -expand 1 - pack $f.a.yscroll -side left -fill y - pack $f.a -side left - - frame $f.b -borderwidth 0 - button $f.b.3 -command "$self dir_select $f.a.list" -text [say add] -width 6 - button $f.b.4 -command "$self dir_remove $f.a.list" -text [say remove] -width 6 - button $f.b.5 -command "$self dir_up $f.a.list" -text [say up] -width 6 - button $f.b.6 -command "$self dir_down $f.a.list" -text [say down] -width 6 - balloon $f.b.3 [say dir_add] - balloon $f.b.4 [say dir_remove] - balloon $f.b.5 [say dir_up] - balloon $f.b.6 [say dir_down] - pack $f.b.3 $f.b.4 $f.b.5 $f.b.6 -side top - - pack $f.b -side top - } - libraries { - set v $_($self:$name) ;# bug in objtcl - set no_max_label 1 - frame $f - frame $f.a - pack [label $f.label -text $label -width 20 -anchor e] -side left - listbox $f.a.list -width 33 -height 10 -yscrollcommand "$f.a.yscroll set" \ - -activestyle none -xscrollcommand "$f.a.xscroll set" - #foreach line $@$name {$f.a.list insert end $line} - foreach line $v {$f.a.list insert end $line} - # save the listbox path at @$name instead - set @$name $f.a.list - scrollbar $f.a.yscroll -command "$f.a.list yview" - scrollbar $f.a.xscroll -command "$f.a.list xview" -orient horizontal - - pack $f.a.xscroll -side bottom -fill x - pack $f.a.list -side left -fill both -expand 1 - pack $f.a.yscroll -side left -fill y - pack $f.a -side left - - frame $f.b -borderwidth 0 - frame $f.b.entry -borderwidth 0 - frame $f.b.butts -borderwidth 0 - - entry $f.b.entry.add -width 15 -borderwidth 5 -relief ridge - bind $f.b.entry.add <Return> "$self lib_add $f" - pack $f.b.entry.add -side left - - button $f.b.entry.3 -command "$self lib_add $f" -text [say add] -width 6 - button $f.b.butts.5 -command "$self dir_up $f.a.list" -text [say up] -width 4 - button $f.b.butts.6 -command "$self dir_down $f.a.list" -text [say down] -width 4 - button $f.b.butts.4 -command "$self dir_remove $f.a.list" -text [say remove] -width 6 - balloon $f.b.entry.3 [say lib_add] - balloon $f.b.butts.5 [say lib_up] - balloon $f.b.butts.6 [say lib_down] - balloon $f.b.butts.4 [say lib_remove] - pack $f.b.entry.3 -side left - pack $f.b.butts.5 -side left -padx 3 - pack $f.b.butts.6 -side left -padx 2 - pack $f.b.butts.4 -side left -padx 2 - pack $f.b.entry -side top - pack $f.b.butts -side top - pack $f.b -side top } default { --- 6304,6307 ---- *************** *** 6325,6329 **** pack $f.entry -side left bind $f.entry <Return> "$self ok" ! switch -regexp -- $type { integer|float|fontsize { frame $f.b -borderwidth 0 --- 6312,6316 ---- pack $f.entry -side left bind $f.entry <Return> "$self ok" ! switch -regexp -- $type { integer|float|fontsize { frame $f.b -borderwidth 0 *************** *** 6335,6345 **** bind $f.entry <Button-5> "change_entry $f.entry -1" } - #folders { - # frame $f.b -borderwidth 0 - # button $f.b.3 -command "$self dir_select $f.entry" -text "open" - # balloon $f.b.3 "click to select folder" - # pack $f.b.3 -side top - # pack $f.b -side left - # } entry {} default { --- 6322,6325 ---- *************** *** 6640,6644 **** }
! def PagedDialog dir_select {listbox} { set dir [tk_chooseDirectory -initialdir ~ -title "Choose a folder" -parent .$self] if {$dir == ""} {return} --- 6620,6624 ---- }
! def PagedDialog dir_add {listbox} { set dir [tk_chooseDirectory -initialdir ~ -title "Choose a folder" -parent .$self] if {$dir == ""} {return} *************** *** 6658,6662 **** }
! def PagedDialog dir_remove {listbox} { set sel [$listbox curselection] if {$sel == ""} {return} --- 6638,6642 ---- }
! def Dialog listbox_remove {listbox} { set sel [$listbox curselection] if {$sel == ""} {return} *************** *** 6665,6669 **** }
! def PagedDialog dir_up {listbox} { set sel [$listbox curselection] if {$sel == 0} {return} --- 6645,6649 ---- }
! def Dialog listbox_up {listbox} { set sel [$listbox curselection] if {$sel == 0} {return} *************** *** 6675,6679 **** }
! def PagedDialog dir_down {listbox} { set sel [$listbox curselection] if {$sel == "" || $sel == [expr [$listbox size] - 1]} {return} --- 6655,6659 ---- }
! def Dialog listbox_down {listbox} { set sel [$listbox curselection] if {$sel == "" || $sel == [expr [$listbox size] - 1]} {return} *************** *** 7373,7378 **** lappend r #N canvas $@canvasx1 $@canvasy1 $@canvasxs $@canvasys if {$@subpatch} {lappend r $@name $@mapped} else {lappend r $@fontsize} ! $stream << $r ! $stream << ";\n" foreach child $@children {eval [concat [list $child deconstruct_to $stream]]} foreach wire $@wires {eval [concat [list $wire deconstruct_to $stream]]} --- 7353,7357 ---- lappend r #N canvas $@canvasx1 $@canvasy1 $@canvasxs $@canvasys if {$@subpatch} {lappend r $@name $@mapped} else {lappend r $@fontsize} ! $stream << "$r;\n" foreach child $@children {eval [concat [list $child deconstruct_to $stream]]} foreach wire $@wires {eval [concat [list $wire deconstruct_to $stream]]}