home *** CD-ROM | disk | FTP | other *** search
/ PC World 2005 June / PCWorld_2005-06_cd.bin / software / vyzkuste / firewally / firewally.exe / framework-2.3.exe / scrolledcanvas < prev    next >
Text File  |  2003-09-01  |  1KB  |  46 lines

  1. # ----------------------------------------------------------------------
  2. #  DEMO: scrolledcanvas in [incr Widgets]
  3. # ----------------------------------------------------------------------
  4. package require Iwidgets 4.0
  5.  
  6. option add *textBackground seashell
  7. . configure -background white
  8.  
  9. iwidgets::scrolledcanvas .canv -labeltext "Scrolledcanvas" \
  10.     -vscrollmode dynamic -hscrollmode dynamic -autoresize yes
  11.  
  12. pack .canv -expand yes -fill both -padx 4 -pady 4
  13. .canv xview moveto 0
  14. .canv yview moveto 0
  15.  
  16.  
  17. button .zoomin -text "Zoom In" -command {
  18.     .canv scale all 0 0 2 2
  19.     .canv configure -scrollregion [.canv bbox all]
  20. }
  21. pack .zoomin -side left -expand yes -padx 4 -pady 4
  22.  
  23. button .zoomout -text "Zoom Out" -command {
  24.     .canv scale all 0 0 0.5 0.5
  25.     .canv xview moveto 0
  26.     .canv yview moveto 0
  27.     .canv configure -scrollregion [.canv bbox all]
  28. }
  29. pack .zoomout -side left -expand yes -padx 4 -pady 4
  30.  
  31.  
  32. bind [.canv component canvas] <ButtonPress-1> {add_rectangle %W %x %y}
  33. bind [.canv component canvas] <B1-Motion> {add_rectangle %W %x %y}
  34.  
  35. proc add_rectangle {win x y} {
  36.     set x [$win canvasx $x]
  37.     set y [$win canvasy $y]
  38.  
  39.     $win create rectangle \
  40.         [expr $x-4] [expr $y-4] \
  41.         [expr $x+4] [expr $y+4] \
  42.         -outline "" -fill red
  43.  
  44.     $win configure -scrollregion [$win bbox all]
  45. }
  46.