gui/implementation/ScrollableBox.tcl


@implementation ScrollableBox {
  - init {} {
      $super init
      $super hideBorder

      $frame configure -relief sunken -bd 1

      set canvas [canvas $frame.canvas -width 1 -height 1 -relief flat -bd 1]
      set xscroll [scrollbar $frame.xscroll -orient horizontal \
        -command "$frame.canvas xview"]
      set yscroll [scrollbar $frame.yscroll -orient vertical \
        -command "$frame.canvas yview"]
      $frame.canvas configure -xscrollcommand "$xscroll set" \
        -yscrollcommand "$yscroll set"

      grid rowconfigure $frame 0 -weight 1
      grid columnconfigure $frame 0 -weight 1
      grid $frame.canvas $yscroll -sticky snew -padx 0 -pady 0
      grid $xscroll -sticky snew -padx 0 -pady 0

      set i [$frame.canvas create window 0 0 \
        -window [frame $frame.canvas.frame] \
        -anchor nw]
      bind $frame.canvas <Configure> {
        %W configure -scrollregion [list 0 0 \
          [winfo reqwidth %W.frame] [winfo reqheight %W.frame]]
      }
      bind $frame.canvas.frame <Configure> {
        [winfo parent %W] configure -scrollregion [list 0 0 \
          [winfo reqwidth %W] [winfo reqheight %W]]
      }
      eval bind $frame.canvas [@removeBindingsOnDestroyEvent]
      set innerFrame $frame.canvas.frame
    }

  - frame {} {
      return $innerFrame
    }
}