  # ==========================
  #
  # images demo
  #
  # ==========================

  # -----------
  # parameters
  # -----------
  set count 60
  set check 1   ;# 0 for radio
  # -----------
  # get package
  # -----------
  package require Tk 8.4
  lappend auto_path [file join [pwd] ..]
  package require Hugelist 1.3
  namespace import ::hugelist::hugelist
  # -----------
  # set current dir
  # -----------
  cd [file dirname [info script]]
  # -----------
  # create items
  # -----------
  for {set i 1} {$i <= $count} {incr i} { lappend ::listvar item-$i }
  # -----------
  # create widget 
  # -----------
  frame .f1
  wm title . "images demo"
  hugelist .f1.hl -values $listvar -height 12 -width 24 \
                  -selectmode extended \
                  -foreground sienna \
                  -background beige \
                  -selectforeground sienna \
                  -selectbackground beige \
                  -selectmode single \
                  -xscrollcommand [list .f1.hs set] \
                  -yscrollcommand [list .f1.vs set] 
  scrollbar .f1.vs -command [list .f1.hl yview]
  scrollbar .f1.hs -command [list .f1.hl xview] -orient horizontal
  pack .f1 -expand 1 -fill both
  grid .f1.hl -row 0 -column 0 -sticky nsew 
  grid .f1.vs -row 0 -column 1 -sticky nse
  grid .f1.hs -row 1 -column 0 -sticky ews
  grid columnconfigure .f1 0 -weight 1
  grid rowconfigure .f1 0 -weight 1
  focus -force .f1.hl
  if {$check} \
  {
    # check marking
    image create photo check-on -file check-on.gif
    image create photo check-off -file check-off.gif
    .f1.hl itemconfig 0 end -image check-off
    bind .f1.hl <<ListboxSelect>> { select %W }
    proc select {w} \
    { 
      set index [$w curselection]
      $w selection clear $index
      switch [$w itemcget $index -image] \
      {
        check-on    { $w itemconfig $index -image check-off -fg sienna }
        check-off   { $w itemconfig $index -image check-on  -fg navy   }
      }
    }
  } \
  else \
  {
    # radio selecting
    image create photo radio-on -file radio-on.gif
    image create photo radio-off -file radio-off.gif
    set ::selected 0
    .f1.hl itemconfig 0 -image radio-on -fg navy 
    .f1.hl itemconfig 1 end -image radio-off
    bind .f1.hl <<ListboxSelect>> { select %W }
    proc select {w} \
    { 
      set index [$w curselection]
      $w selection clear $index
      if {[$w itemcget $index -image] == "radio-off"} \
      {
        $w itemconfig $::selected -image radio-off -fg sienna
        $w itemconfig $index      -image radio-on  -fg navy
        set ::selected $index
      }
    }
  }
