home *** CD-ROM | disk | FTP | other *** search
/ Practical Programming in Tcl & Tk (4th Edition) / TCLBOOK4.BIN / pc / exsource / 27_6.tcl < prev    next >
Text File  |  2003-04-16  |  519b  |  27 lines

  1. #
  2. # Example 27-6
  3. # PaneDrag adjusts the percentage.
  4. #
  5.  
  6. proc PaneDrag {master D} {
  7.     upvar #0 Pane$master pane
  8.     if [info exists pane(lastD)] {
  9.         set delta [expr double($pane(lastD) - $D) \
  10.                                     / $pane(size)]
  11.         set pane(-percent) [expr $pane(-percent) - $delta]
  12.         if {$pane(-percent) < 0.0} {
  13.             set pane(-percent) 0.0
  14.         } elseif {$pane(-percent) > 1.0} {
  15.             set pane(-percent) 1.0
  16.         }
  17.         PaneGeometry $master
  18.     }
  19.     set pane(lastD) $D
  20. }
  21. proc PaneStop {master} {
  22.     upvar #0 Pane$master pane
  23.     catch {unset pane(lastD)}
  24. }
  25.  
  26.  
  27.