[PD-cvs] pd/src desire.tk,1.1.2.600.2.341,1.1.2.600.2.342
chunlee
chunlee at users.sourceforge.net
Sat Aug 11 09:31:23 CEST 2007
Update of /cvsroot/pure-data/pd/src
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2494
Modified Files:
Tag: desiredata
desire.tk
Log Message:
variable width font should be better now
Index: desire.tk
===================================================================
RCS file: /cvsroot/pure-data/pd/src/Attic/desire.tk,v
retrieving revision 1.1.2.600.2.341
retrieving revision 1.1.2.600.2.342
diff -C2 -d -r1.1.2.600.2.341 -r1.1.2.600.2.342
*** desire.tk 11 Aug 2007 04:30:14 -0000 1.1.2.600.2.341
--- desire.tk 11 Aug 2007 07:31:19 -0000 1.1.2.600.2.342
***************
*** 2471,2475 ****
set @y1 [lindex $mess 3]
set @text [$self remove_braces [join [lrange $mess 4 end]]]
! set @longline 0
# @textoffset is for offseting the text item/widget, ie, ObjectBox vs NumBox
switch [$self class] {
--- 2471,2476 ----
set @y1 [lindex $mess 3]
set @text [$self remove_braces [join [lrange $mess 4 end]]]
! set @multi 0
! set @max_width 40
# @textoffset is for offseting the text item/widget, ie, ObjectBox vs NumBox
switch [$self class] {
***************
*** 2496,2505 ****
$self item TEXT text [l+ $@textoffset [$self xy]] \
-font [View_look $self font] -text $text \
! -fill [View_look $self fg] -anchor nw -width [expr $fw*40]
}
$self update_size
super
}
-
def TextBox edit {} {
if {$@edit} {return}; set @edit 1; $self changed edit
--- 2497,2505 ----
$self item TEXT text [l+ $@textoffset [$self xy]] \
-font [View_look $self font] -text $text \
! -fill [View_look $self fg] -anchor nw -width [expr $fw*$@max_width]
}
$self update_size
super
}
def TextBox edit {} {
if {$@edit} {return}; set @edit 1; $self changed edit
***************
*** 2534,2557 ****
set @tab_repeats 0
obj_hist histi= 0
- set @max_width 40
set @selected? 1
$c delete ${self}TEXT
set font_str [$self look font]
! set new_size [format %.0f [expr [lindex $font_str 1]*[$@canvas zoom]]]
set font_str [lreplace $font_str 1 1 $new_size]
foreach char [split $@text ""] {lappend l [scan $char %c]}
! set width [string length $@text]
! set height [expr int(ceil($width/$@max_width.0))]; #this don's work well with variable width font..
! set insertbg [$self look bg]; set fg [$self look fg]
if {[[$self class] <= AtomBox]} {set fg "red"; set insertbg [$self look bgedit]}
! if {$width > $@max_width} {set width $@max_width}
! text $t -width [expr $width+1] -height $height -relief flat -bg [$self look bgedit] -borderwidth 0 \
-highlightthickness 0 -font $font_str -fg $fg -insertbackground $insertbg -wrap word
- #text $t -width [expr $width+1] -height $height -relief flat -bg red -borderwidth 0 \
- # -highlightthickness 0 -font $font_str -fg $fg -insertbackground $insertbg -wrap word
-
$self new_bind
$@canvas focus= $self
! $self item text window [l+ $@textoffset [$self xy]] -window $t -anchor nw -tags "${self}text $self text"
$t insert 1.0 $@text
$t configure -pady 0 -padx 0
--- 2534,2560 ----
set @tab_repeats 0
obj_hist histi= 0
set @selected? 1
+ #set z [$@canvas zoom]
+ set z 1
+ if {[$c bbox ${self}TEXT] != ""} {
+ mset {ix1 iy1 ix2 iy2} [$c bbox ${self}TEXT]
+ } else {
+ set ix1 0; set iy1 0
+ set ix2 [font measure [$self look font] 0]
+ set iy2 [font metrics [$self look font] -linespace]
+ }
$c delete ${self}TEXT
set font_str [$self look font]
! set new_size [format %.0f [expr [lindex $font_str 1]*$z]]
set font_str [lreplace $font_str 1 1 $new_size]
foreach char [split $@text ""] {lappend l [scan $char %c]}
! mset {width height} [$self get_size [expr $ix2-$ix1] [expr $iy2-$iy1]]
! set insertbg [$self look fg]; set fg [$self look fg]
if {[[$self class] <= AtomBox]} {set fg "red"; set insertbg [$self look bgedit]}
! text $t -width $width -height $height -relief flat -bg [$self look bgedit] -borderwidth 0 \
-highlightthickness 0 -font $font_str -fg $fg -insertbackground $insertbg -wrap word
$self new_bind
$@canvas focus= $self
! $self item text window [l+ [lmap / $@textoffset $z] [$self xy]] -window $t -anchor nw -tags "${self}text $self text"
$t insert 1.0 $@text
$t configure -pady 0 -padx 0
***************
*** 2563,2571 ****
set c [$self cwidget]
set t $c.${self}text
! set width [$t count -chars 1.0 end]
! set height [$t count -displaylines 1.0 end]
$t configure -width [expr [min $width $@max_width]+1] -height $height -wrap word
}
def TextBox key_input {widget x y key iso shift} {
after 0 "$self after_key $widget"
--- 2566,2596 ----
set c [$self cwidget]
set t $c.${self}text
! #set z [$@canvas zoom]
! set z 1
! set pix_height [$t count -update -ypixels 1.0 end]
! set pix_width [$t count -update -xpixels "1.0" "1.0 lineend"]
! mset {width height} [$self get_size $pix_width $pix_height]
$t configure -width [expr [min $width $@max_width]+1] -height $height -wrap word
}
+ #talks pixel value and return char units
+ def TextBox get_size {w h} {
+ set c [$self cwidget]
+ set t $c.${self}text
+ set pix_height $h
+ set pix_width $w
+ set char_width [font measure [$self look font] 0]
+ set line_height [font metrics [$self look font] -linespace]
+ set round_chars [expr int(ceil($pix_width/$char_width))+2]
+ if {$round_chars < $@max_width && !$@multi} {
+ set round_lines 1
+ } else {
+ set @multi 1
+ set round_chars $@max_width
+ set round_lines [expr int(ceil($pix_height/$line_height))]
+ }
+ return [list $round_chars $round_lines]
+ }
+
def TextBox key_input {widget x y key iso shift} {
after 0 "$self after_key $widget"
***************
*** 2643,2653 ****
set w2 0; set h2 0
set xpad 2; set ypad 3
if {[winfo exists $t_widget]} {
set textwidth [expr [winfo reqwidth $t_widget]+$xpad]
! set height [winfo reqheight $t_widget]
} else {
mset {x1 y1 x2 y2} [[[$self canvas] widget] bbox ${self}TEXT]
! set textwidth [expr ($x2-$x1+2)/[$@canvas zoom]]
! set height [expr ($y2-$y1+2)/[$@canvas zoom]]
}
set iowidth [$self look iowidth]
--- 2668,2680 ----
set w2 0; set h2 0
set xpad 2; set ypad 3
+ #set z [$@canvas zoom]
+ set z 1
if {[winfo exists $t_widget]} {
set textwidth [expr [winfo reqwidth $t_widget]+$xpad]
! set height [expr [winfo reqheight $t_widget]+$ypad]
} else {
mset {x1 y1 x2 y2} [[[$self canvas] widget] bbox ${self}TEXT]
! set textwidth [expr $x2-$x1+$xpad]
! set height [expr $y2-$y1+$ypad]
}
set iowidth [$self look iowidth]
***************
*** 2655,2659 ****
set bottomwidth [expr {(2*$@noutlets-1)*$iowidth}]
set @xs [max [$self look minobjwidth] [max $bottomwidth [max $topwidth $textwidth]]]
! set @ys [expr {$ypad+$height}]
}
--- 2682,2686 ----
set bottomwidth [expr {(2*$@noutlets-1)*$iowidth}]
set @xs [max [$self look minobjwidth] [max $bottomwidth [max $topwidth $textwidth]]]
! set @ys $height
}
More information about the Pd-cvs
mailing list