Update of /cvsroot/pure-data/pd/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15516
Modified Files: Tag: desiredata desire.tk Log Message: new font editor part I
Index: desire.tk =================================================================== RCS file: /cvsroot/pure-data/pd/src/Attic/desire.tk,v retrieving revision 1.1.2.600.2.276 retrieving revision 1.1.2.600.2.277 diff -C2 -d -r1.1.2.600.2.276 -r1.1.2.600.2.277 *** desire.tk 4 Aug 2007 03:23:28 -0000 1.1.2.600.2.276 --- desire.tk 4 Aug 2007 03:33:15 -0000 1.1.2.600.2.277 *************** *** 6881,6885 **** }
! class_new Dialog {Thing}
def Dialog add_stuff {f name label} { --- 6881,6885 ---- }
! class_new Dialog {View}
def Dialog add_stuff {f name label} { *************** *** 7111,7114 **** --- 7111,7115 ---- side {$self add_side $f $name $label} color {$self add_color $f $name $label} + font {$self add_font $f $name $label $options} choice {$self add_choice $f $name $label $choices} key {set f $w.[string tolower [lindex $name 0]] *************** *** 7162,7235 **** }
! def Dialog add_font {f args} { ! global look ! if {[winfo exists $f.font]} {return} bind all <KeyPress-F1> help ! set font $look(View:font) set @family [lindex $font 0] set @size [expr -[lindex $font 1]] set @bold [expr [lsearch $font bold ]>=0] set @italic [expr [lsearch $font italic]>=0] logvar @family @size @bold @italic ! $f configure ! frame $f.font ! pack [label $f.font.label -text [say font_family] -anchor w] -side top -fill x ! frame $f.font.list ! pack [listbox $f.font.list.box -relief sunken -yscrollcommand "$f.font.list.scroll set"] -side left ! pack [scrollbar $f.font.list.scroll -relief sunken -command "$f.font.list.box yview"] -side right -fill y ! bind $f.font.list.box <<ListboxSelect>> "$self font_update $f" ! foreach name [lsort [font families]] {$f.font.list.box insert end $name}
! set fontlist [$f.font.list.box get 0 end] set find [lsearch $fontlist $@family] if {$find < 0} {set find 0} ! $f.font.list.box selection set $find $find ! $f.font.list.box see $find ! bind $f.font.list.box <ButtonRelease-1> "$self font_update $f"
! frame $f.font.size ! pack [label $f.font.size.label -text [say font_size]] -side left ! pack [spinbox $f.font.size.entry -relief sunken -textvariable fontsize -width 4 \ -command "$self font_changesize $f %d"] -side left ! bind $f.font.size.entry <KeyPress-Return> "$self font_update_size $f" ! #pack [scrollbar $f.font.size.scroll -command "$self font_changesize $f"] -side right -fill y ! $f.font.size.entry delete 0 end ! $f.font.size.entry insert 0 $@size
! frame $f.font.style ! pack [label $f.font.style.label -text [say font_style]] -side left -fill y set cmd [list $self font_update $f] ! pack [checkbutton $f.font.style.bold -text [say font_bold] -variable @bold -command $cmd] -side top ! pack [checkbutton $f.font.style.italic -text [say font_italic] -variable @italic -command $cmd] -side top ! ! frame $f.font2 ! frame $f.font2.preview ! pack [label $f.font2.preview.label -text [say font_preview]] -side left -fill y ! pack [canvas $f.font2.preview.canvas -width 250 -height 50 -relief sunken -borderwidth 1] -side left -fill x ! $f.font2.preview.canvas create text 4 4 -tags ${self}TEXT -anchor nw -text [say font_preview_2] -font $look(View:font)
! set parent [string range $f 1 [expr [string first "." $f 1]-1]] ! if {$parent == "ddrc"} { ! set padx 150; set pady 20; set padx2 50; set pady2 5 ! } else { ! set padx 0; set pady 0; set padx2 0; set pady2 0 ! }
! pack $f.font.list -side left -fill y ! pack $f.font.size -side top -fill x ! pack $f.font.style -side top -fill x ! pack $f.font2.preview -side bottom -fill x ! pack $f.font -side top -fill both -padx $padx -pady $pady ! pack $f.font2 -side top -fill x -padx $padx -pady $pady ! $self font_update $f ! }
! def Dialog spinbox_update {mode} { ! puts " $mode" }
! def Dialog font_update {f} { global font ! set lb $f.font.list.box set @family [$lb get [$lb curselection]] set @str [list $@family [expr -$@size]] --- 7163,7245 ---- }
! def Dialog spinbox_update {mode} {puts " $mode"} ! ! def Dialog add_font {f name label class} { ! $self add_stuff $f $name $label ! set v $@$name ! label $f.font -text "DesireData" -font [lreplace $v 1 1 -12] -width 13 -height 1 -pady 3 -fg black \ ! -relief sunken -bg white ! button $f.preset -text [say "edit"] -pady 2 -font {Helvetica 8} \ ! -command "FontDialog new_as $name $class $f.font" ! pack $f.font $f.preset -side left ! } ! ! class_new FontDialog {Dialog} ! ! def Canvas fd {} {FontDialog new_as view_font [$self look font] "View"} ! ! def FontDialog init {class orig} { ! if {[winfo exists .$self]} {return} ! super cancel ok ! set f .$self ! set @class $class ! set @orig $orig bind all <KeyPress-F1> help ! set font $::look($@class:font) set @family [lindex $font 0] set @size [expr -[lindex $font 1]] set @bold [expr [lsearch $font bold ]>=0] set @italic [expr [lsearch $font italic]>=0] + set @str $font logvar @family @size @bold @italic ! pack [label $f.label -text [say font_family] -anchor w] -side top -fill x ! frame $f.list -bd 2 ! ! pack [listbox $f.list.box -relief sunken -yscrollcommand "$f.list.scroll set"] -side left ! pack [scrollbar $f.list.scroll -relief sunken -command "$f.list.box yview" -takefocus 0] -side right -fill y ! bind $f.list.box <<ListboxSelect>> "$self font_update $f" ! foreach name [lsort [font families]] {$f.list.box insert end $name}
! set fontlist [$f.list.box get 0 end] set find [lsearch $fontlist $@family] if {$find < 0} {set find 0} ! $f.list.box selection set $find $find ! $f.list.box activate $find ! $f.list.box see $find ! bind $f.list.box <ButtonRelease-1> "$self font_update $f" ! bind $f.list.box <ButtonPress-1> "focus $f.list.box"
! frame $f.var ! frame $f.var.size ! pack [label $f.var.size.label -text [say font_size]] -side left ! pack [spinbox $f.var.size.entry -relief sunken -textvariable fontsize -width 4 \ -command "$self font_changesize $f %d"] -side left ! bind $f.var.size.entry <KeyPress-Return> "$self font_update_size $f" ! $f.var.size.entry delete 0 end ! $f.var.size.entry insert 0 $@size
! frame $f.var.style ! pack [label $f.var.style.label -text [say font_style]] -side left set cmd [list $self font_update $f] ! pack [checkbutton $f.var.style.bold -text [say font_bold] -variable @bold -command $cmd] -side top ! pack [checkbutton $f.var.style.italic -text [say font_italic] -variable @italic -command $cmd] -side top
! pack $f.var.size -side left ! pack $f.var.style -side left -padx 20
! frame $f.preview ! pack [label $f.preview.label -text [say font_preview]] -side left ! pack [canvas $f.preview.canvas -width 250 -height 50 -relief sunken -borderwidth 1] -side left -fill x ! $f.preview.canvas create text 4 4 -tags ${self}TEXT -anchor nw -text [say font_preview_2] -font $font
! pack $f.list -side left ! pack $f.var -side top -fill x ! pack $f.preview -side top -pady 10 ! focus $f.list.box }
! def FontDialog font_update {f} { global font ! set lb $f.list.box set @family [$lb get [$lb curselection]] set @str [list $@family [expr -$@size]] *************** *** 7237,7266 **** if {$@italic} {lappend @str italic} # logvar @str ! $f.font2.preview.canvas itemconfigure ${self}TEXT -font $@str }
! def Dialog font_changesize {f mode} { ! #set f .$self ! #set @size [expr $@size - $y] switch $mode { up {set @size [expr $@size+1]} down {set @size [expr $@size-1]} } ! $f.font.size.entry delete 0 end ! $f.font.size.entry insert 0 $@size $self font_update $f }
! def Dialog font_style {f bold} { set @bold $bold $self font_update $f }
! def Dialog font_update_size {f} { ! set size [$f.font.size.entry get] if [regexp {^[0-9]+$} $size] {set @size $size} $self font_update $f }
############ .pdrc editor #Turns #rgb into 3 elem list of decimal vals. --- 7247,7279 ---- if {$@italic} {lappend @str italic} # logvar @str ! $f.preview.canvas itemconfigure ${self}TEXT -font $@str }
! def FontDialog font_changesize {f mode} { switch $mode { up {set @size [expr $@size+1]} down {set @size [expr $@size-1]} } ! $f.var.size.entry delete 0 end ! $f.var.size.entry insert 0 $@size $self font_update $f }
! def FontDialog font_style {f bold} { set @bold $bold $self font_update $f }
! def FontDialog font_update_size {f} { ! set size [$f.var.size.entry get] if [regexp {^[0-9]+$} $size] {set @size $size} $self font_update $f }
+ def FontDialog apply {} { + set ::look($@class:font) $@str + $@orig configure -font [lreplace $@str 1 1 -12] + } + ############ .pdrc editor #Turns #rgb into 3 elem list of decimal vals. *************** *** 7348,7351 **** --- 7361,7365 ---- bind .$self <Tab> "$self traversal %K %W forward" bind .$self <Control-Tab> "$self traversal %K %W back" + wm resizable .$self 0 0 }
*************** *** 7726,7729 **** --- 7740,7744 ---- color Comment frame3 color View selectframe + font View font subsection Client wire_color color Wire fg *************** *** 7779,7784 **** key Canvas {key_nav_left key_nav_left_shift} key Canvas key_nav_ioselect - section Client font - font View font section Client others toggle Canvas hairstate --- 7794,7797 ---- *************** *** 7859,7863 **** integer {set look($class:$name) $@$name} choice {set look($class:$name) $@$name} ! font {set look(View:font) $@str} } } --- 7872,7876 ---- integer {set look($class:$name) $@$name} choice {set look($class:$name) $@$name} ! #font {set look(View:font) $@str} } } *************** *** 7924,7928 **** } font { ! $self add_font $which_section } default { --- 7937,7943 ---- } font { ! set str [string tolower $class$name] ! set @$str $look($class:$name) ! $self add $which_section [list $str $type $class] } default { *************** *** 8152,8155 **** --- 8167,8181 ----
#---------------------------------------------------------------- + #class_new Splash {Thing} + + #def Splash init {} { + # toplevel .$self + # frame .$self.f + # canvas .$self.f.canvas + # image create photo .dd -format GIF -file desiredata.gif + # .$self.f.canvas create image 0 0 -image .dd + # pack .$self.f.canvas + # pack .$self.f + #}
class_new KeyboardDialog {Dialog} *************** *** 8223,8232 **** frame .$self.board.key.$i foreach key $row { ! if {$key==" "} {pack [label .$self.board.key.$i.shim$j -image icon_empty] -side left; incr j; continue} set ::keyboard_row_of($key) $i ! #pack [button .$self.$i.key$key -text "$key"] -side left ! if {[info exists ::keyboard_width_of($key)]} {set width $::keyboard_width_of($key)} {set width 3} ! if {[info exists ::keyboard_text_of($key)]} {set text $::keyboard_text_of($key)} {set text $key} ! pack [label .$self.board.key.$i.key$key -text " $text " -relief raise -border 4 -bg "#dddddd" -width $width] -side left } pack .$self.board.key.$i -fill x --- 8249,8266 ---- frame .$self.board.key.$i foreach key $row { ! if {$key==" "} { ! pack [label .$self.board.key.$i.shim$j -image icon_empty] -side left ! incr j ! continue ! } set ::keyboard_row_of($key) $i ! if {[info exists ::keyboard_width_of($key)]} { ! set width $::keyboard_width_of($key) ! } else {set width 3} ! if {[info exists ::keyboard_text_of($key)]} { ! set text $::keyboard_text_of($key) ! } else {set text $key} ! pack [label .$self.board.key.$i.key$key -text " $text " -relief raise -border 4 \ ! -bg "#dddddd" -width $width -font [$self look font]] -side left } pack .$self.board.key.$i -fill x *************** *** 8238,8249 **** frame .$self.board.misc.$i foreach key $row { ! if {$key==" "} {pack [label .$self.board.misc.$i.shim$j -image icon_empty] -side left; incr j; continue} set ::keyboard_row_of($key) $i ! if {[info exists ::keyboard_width_of($key)]} {set width $::keyboard_width_of($key)} {set width 3} ! if {[info exists ::keyboard_text_of($key)]} {set text $::keyboard_text_of($key)} {set text $key} ! pack [label .$self.board.misc.$i.key$key -text " $text " -relief raise -border 4 -bg "#dddddd" -width $width] -side left } pack .$self.board.misc.$i -fill x - incr i } --- 8272,8290 ---- frame .$self.board.misc.$i foreach key $row { ! if {$key==" "} { ! pack [label .$self.board.misc.$i.shim$j -image icon_empty] -side left ! incr j; continue ! } set ::keyboard_row_of($key) $i ! if {[info exists ::keyboard_width_of($key)]} { ! set width $::keyboard_width_of($key) ! } else {set width 3} ! if {[info exists ::keyboard_text_of($key)]} { ! set text $::keyboard_text_of($key) ! } else {set text $key} ! pack [label .$self.board.misc.$i.key$key -text " $text " -relief raise -border 4 \ ! -bg "#dddddd" -width $width -font [$self look font]] -side left } pack .$self.board.misc.$i -fill x incr i } *************** *** 8266,8270 **** .$self.board.$section.$i.key$k configure -bg "#ff0000" } ! ^KeyRelease|ButtonRelease$ {if {![dict exists $@fade $k]} {dict set @fade $k 255}; puts $@fade} } } --- 8307,8311 ---- .$self.board.$section.$i.key$k configure -bg "#ff0000" } ! ^KeyRelease|ButtonRelease$ {if {![dict exists $@fade $k]} {dict set @fade $k 255}} } }