Tk Library Source Code

Artifact [b356ca811f]
Login

Artifact b356ca811fa9587ee63f959eb29d99a5fa445ab9c3b9381c69521e00e87a6277:

Attachment "plotchart.diff" to ticket [68d110104c] added by emiliano 2024-10-18 00:33:48.
Index: modules/plotchart/plotchart.tcl
==================================================================
--- modules/plotchart/plotchart.tcl
+++ modules/plotchart/plotchart.tcl
@@ -1325,12 +1325,12 @@
    if { $stepsize != "noaxes" } {
       foreach {pxmin pymin pxmax pymax} [MarginsRectangle $w $args] {break}
    } else {
       set pxmin 0
       set pymin 0
-      #set pxmax [$w cget -width]
-      #set pymax [$w cget -height]
+      #set pxmax [winfo pixels $w [$w cget -width]]
+      #set pymax [winfo pixels $w [$w cget -height]]
       set pxmax [WidthCanvas $w]
       set pymax [HeightCanvas $w]
    }
 
    set scaling($w,coordSystem) 0

Index: modules/plotchart/plotdendrogram.tcl
==================================================================
--- modules/plotchart/plotdendrogram.tcl
+++ modules/plotchart/plotdendrogram.tcl
@@ -70,12 +70,12 @@
 
     lassign [TreeCountItems $treedata] countLabels countLevels
 
     set dir $scaling($w,direction)
 
-    set canvaswidth  [$w cget -width]
-    set canvasheight [$w cget -height]
+    set canvaswidth  [winfo pixels $w [$w cget -width]]
+    set canvasheight [winfo pixels $w [$w cget -height]]
 
     set width  [expr {$canvaswidth  - 10}]
     set height [expr {$canvasheight - $scaling($w,pymin)}]
 
     if { $dir in {"left-right" "right-left"} } {

Index: modules/plotchart/plotpriv.tcl
==================================================================
--- modules/plotchart/plotpriv.tcl
+++ modules/plotchart/plotpriv.tcl
@@ -33,14 +33,14 @@
         set width $scaling($ref,refwidth)
     } else {
         set width [winfo width $w]
 
         if { $width < 10 } {
-            set width [$w cget -width]
+            set width [winfo pixels $w [$w cget -width]]
         }
     }
-    incr width -[$w cget -borderwidth]
+    incr width -[winfo pixels $w [$w cget -borderwidth]]
 
     return $width
 }
 
 # HeightCanvas --
@@ -63,14 +63,14 @@
     if { [info exists scaling($ref,refheight)] && $useref } {
         set height $scaling($ref,refheight)
     } else {
         set height [winfo height $w]
         if { $height < 10 } {
-            set height [$w cget -height]
+            set height [winfo pixels $w [$w cget -height]]
         }
     }
-    incr height -[$w cget -borderwidth]
+    incr height -[winfo pixels $w [$w cget -borderwidth]]
     return $height
 }
 
 # SavePlot --
 #    Save the plot/chart to a PostScript file (using default options)
@@ -277,11 +277,11 @@
 
     set pxmin [expr {$char_width*$text_width}]
     if { $pxmin < $config($w,margin,left) } {
         set pxmin $config($w,margin,left)
     }
-    set pymin [expr {int($char_height*$notext) + [$w cget -borderwidth]}]
+    set pymin [expr {int($char_height*$notext) + [winfo pixels $w [$w cget -borderwidth]]}]
     if { $pymin < $config($w,margin,top) } {
         set pymin $config($w,margin,top)
     }
     if { $config($w,leftaxis,usesubtext) || $config($w,rightaxis,usesubtext) } {
         set char_height1 [font metrics $config($w,leftaxis,subtextfont) -linespace]
@@ -295,30 +295,30 @@
 
     array set options $argv
     if {[info exists options(-box)]} {
         foreach {offx offy width height} $options(-box) {break}
         if { $offy == 0 } {
-            set offy [$w cget -borderwidth]
+            set offy [winfo pixels $w [$w cget -borderwidth]]
         }
         set scaling($w,reference) $w
         set scaling($w,refx)      $offx
         set scaling($w,refy)      $offy
         set scaling($w,refwidth)  [expr {$offx + $width}]
         set scaling($w,refheight) [expr {$offy + $height}]
     } elseif {[info exists options(-axesbox)]} {
         foreach {offx offy width height} [DetermineFromAxesBox $options(-axesbox) $pxmin $pymin $margin_right $margin_bottom] {break}
         if { $offy == 0 } {
-            set offy [$w cget -borderwidth]
+            set offy [winfo pixels $w [$w cget -borderwidth]]
         }
         set ref_plot [lindex $options(-axesbox) 0]
         set pos      [string first _ $ref_plot]
         set ref      [string range $ref_plot [expr {$pos+1}] end]
         set scaling($w,reference) $scaling($ref,reference) ;# A chain of references is possible!
     } else {
         set scaling($w,reference) $w
         set offx   0
-        set offy   [$w cget -borderwidth]
+        set offy   [winfo pixels $w [$w cget -borderwidth]]
         set width  [WidthCanvas $w]
         set height [HeightCanvas $w]
         set scaling($w,refx)      0
         set scaling($w,refy)      0
         set scaling($w,refwidth)  $width
@@ -388,11 +388,11 @@
     variable config
     variable scaling
 
     set scaling($w,reference) $w
     set scaling($w,refx)      0
-    set scaling($w,refy)      [$w cget -borderwidth]
+    set scaling($w,refy)      [winfo pixels $w [$w cget -borderwidth]]
     set scaling($w,refwidth)  [WidthCanvas $w]
     set scaling($w,refheight) [HeightCanvas $w]
 
     set char_width  $config(font,char_width)
     set char_height $config(font,char_height)
@@ -457,12 +457,12 @@
 
    set pxmin 80
    set pymin 30
    set pxmax [expr {[WidthCanvas $w]  - 80}]
    set pymax [expr {[HeightCanvas $w] - 30}]
-   #set pxmax [expr {[$w cget -width]  - 80}]
-   #set pymax [expr {[$w cget -height] - 30}]
+   #set pxmax [expr {[winfo pixels $w [$w cget -width]]  - 80}]
+   #set pymax [expr {[winfo pixels $w [$w cget -height]] - 30}]
 
    # width (dx) and height (dy) of plot region in pixels:
    if {[info exists options(-units)]} {
        # refUnitX, refUnitY - size of one world coordinate unit in the piechart,
        #      given as canvas coords (can also be m,c,i,p units)
@@ -515,18 +515,18 @@
         # that may be placed outside the box
         # Note: also ignores -units setting
         lassign $options(-box) pxmin pymin width height
         if {$height >= $width} {
             # place vertically in the middle of the -box
-            if { $pxmin == 0 } {set pxmin [$w cget -borderwidth]}
+            if { $pxmin == 0 } {set pxmin [winfo pixels $w [$w cget -borderwidth]]}
             set pymin [expr {$pymin + ($height-$width)/2.0}]
-            if { $pymin == 0 } {set pymin [$w cget -borderwidth]}
+            if { $pymin == 0 } {set pymin [winfo pixels $w [$w cget -borderwidth]]}
         } else {
             # place horizontally in the middle of the -box
-            if { $pymin == 0 } {set pymin [$w cget -borderwidth]}
+            if { $pymin == 0 } {set pymin [winfo pixels $w [$w cget -borderwidth]]}
             set pxmin [expr {$pxmin + ($width-$height)/2.0}]
-            if { $pxmin == 0 } {set pxmin [$w cget -borderwidth]}
+            if { $pxmin == 0 } {set pxmin [winfo pixels $w [$w cget -borderwidth]]}
         }
         # only take the smallest dimension to keep the pie a circle:
         if {$width < $height} {set height $width}
         if {$height < $width} {set width $height}
         set pxmax [expr {$pxmin + $width}]
@@ -536,11 +536,11 @@
         set scaling($w,refy)      $pymin
         set scaling($w,refwidth)  [expr {$pxmin + $width}]
         set scaling($w,refheight) [expr {$pymin + $height}]
    } else {
         set scaling($w,refx)      0
-        set scaling($w,refy)      [$w cget -borderwidth]
+        set scaling($w,refy)      [winfo pixels $w [$w cget -borderwidth]]
         set scaling($w,refwidth)  [WidthCanvas $w]
         set scaling($w,refheight) [HeightCanvas $w]
    }
 
    return [list $pxmin $pymin $pxmax $pymax]
@@ -556,11 +556,11 @@
 proc ::Plotchart::Margins3DPlot { w } {
    variable scaling
 
    set scaling($w,reference) $w
    set scaling($w,refx)      0
-   set scaling($w,refy)      [$w cget -borderwidth]
+   set scaling($w,refy)      [winfo pixels $w [$w cget -borderwidth]]
    set scaling($w,refwidth)  [WidthCanvas $w]
    set scaling($w,refheight) [HeightCanvas $w]
 
    set yfract 0.33
    set zfract 0.50
@@ -575,16 +575,16 @@
       set scaling($w,zfract) $zfract
    }
 
    set yzwidth  [expr {(-120+[WidthCanvas $w])/(1.0+$yfract)}]
    set yzheight [expr {(-60+[HeightCanvas $w])/(1.0+$zfract)}]
-   #set yzwidth  [expr {(-120+[$w cget -width])/(1.0+$yfract)}]
-   #set yzheight [expr {(-60+[$w cget -height])/(1.0+$zfract)}]
+   #set yzwidth  [expr {(-120+[winfo pixels $w [$w cget -width]])/(1.0+$yfract)}]
+   #set yzheight [expr {(-60+[winfo pixels $w [$w cget -height]])/(1.0+$zfract)}]
 
    set pxmin    [expr {60+$yfract*$yzwidth}]
    set pxmax    [expr {[WidthCanvas $w] - 60}]
-   #set pxmax    [expr {[$w cget -width] - 60}]
+   #set pxmax    [expr {[winfo pixels $w [$w cget -width]] - 60}]
    set pymin    30
    set pymax    [expr {30+$yzheight}]
 
    return [list $pxmin $pymin $pxmax $pymax]
 }
@@ -974,11 +974,11 @@
 
     set ref    $scaling($w,reference)
     set offx   $scaling($ref,refx)
     set offy   $scaling($ref,refy)
     set width  [WidthCanvas $w]
-    #set width  [$w cget -width]
+    #set width  [winfo pixels $w [$w cget -width]]
     set pymin  $scaling($w,pymin)
 
     switch -- $position {
         "left" {
             set tx [expr {$offx + 3}]
@@ -993,11 +993,11 @@
             set anchor n
         }
     }
 
     $w delete "title_$anchor && $ref"
-    set obj [$w create text $tx [expr {$offy + 3 + [$w cget -borderwidth]}] -text $title \
+    set obj [$w create text $tx [expr {$offy + 3 + [winfo pixels $w [$w cget -borderwidth]]}] -text $title \
                 -tags [list title title_$anchor $ref] -font $config($w,title,font) \
                 -fill $config($w,title,textcolor) -anchor $anchor]
 
     set titlecolour $config($w,title,background)
     if { $titlecolour == "" } {
@@ -1035,11 +1035,11 @@
     if { $offy == {} } {
         set $scaling($ref,refy)
     }
 
     $w delete "subtitle && $ref"
-    set obj [$w create text $tx [expr {$offy + 3 + [$w cget -borderwidth]}] -text $title \
+    set obj [$w create text $tx [expr {$offy + 3 + [winfo pixels $w [$w cget -borderwidth]]}] -text $title \
                 -tags [list subtitle $ref] -font $config($w,subtitle,font) \
                 -fill $config($w,subtitle,textcolor) -anchor n]
 
     set titlecolour $config($w,subtitle,background)
     if { $titlecolour == "" } {