Tk Library Source Code

Artifact [9c1062d733]
Login

Artifact 9c1062d733d9b1f4e8ffd78ff6b9635666a2d7c2:

Attachment "progressbar.tcl.v1.6.patch" to ticket [681119ffff] added by funkhouser 2003-02-26 08:18:01.
Index: progressbar.tcl
===================================================================
RCS file: /cvsroot/tcllib/bwidget/progressbar.tcl,v
retrieving revision 1.6
diff -c -r1.6 progressbar.tcl
*** progressbar.tcl	29 Dec 2001 02:05:34 -0000	1.6
--- progressbar.tcl	26 Feb 2003 01:07:21 -0000
***************
*** 27,32 ****
--- 27,33 ----
          {-bg          Synonym    -background}
          {-fg          Synonym    -foreground}
          {-bd          Synonym    -borderwidth}
+         {-showText    Boolean    0          0}
      }
  
      Widget::addmap ProgressBar "" :cmd {-background {} -width {} -height {}}
***************
*** 133,138 ****
--- 134,142 ----
      }
      unset _widget($path,var)
      unset _widget($path,dir)
+     if {[info exists _widget($path,progText)]} {
+         unset _widget($path,progText)
+     }
      Widget::destroy $path
      rename $path {}
  }
***************
*** 180,186 ****
  		} else {
  		    $path.bar coords rect 0 [expr {$h+1}] $w [expr {$h*($max-$val)}]
  		}
! 	    }
      }
      if {![Widget::cget $path -idle]} {
          update
--- 184,209 ----
  		} else {
  		    $path.bar coords rect 0 [expr {$h+1}] $w [expr {$h*($max-$val)}]
  		}
!         }
!         #
!         # If the showText flag is set to true, we want to display the 
!         # percentage text.
!         #
!         if {[Widget::cget $path -showText]} {
!             set percentage [expr double($val) / $max * 100]
!             set text [format "%d%%" [expr int($percentage)]]
! 
!             if {![info exists _widget($path,progText)]} {
!                 set _widget($path,progText) [$path.bar create text 0 0 \
!                                              -text $text \
!                                              -font {system 12} \
!                                              -justify center ]
!             } else {
!                 $path.bar itemconfig $_widget($path,progText) -text $text
!             }
!             $path.bar coord $_widget($path,progText) [expr $w/2] [expr $h/2]
!             $path.bar raise $_widget($path,progText)
!         }
      }
      if {![Widget::cget $path -idle]} {
          update