# gui/implementation/DynamicListBox.tcl

    @implementation DynamicListBox : Box {
      - init {} {
          $super init
          grid rowconfigure $frame 0 -weight 1
          grid columnconfigure $frame 1 -weight 1
          set column 0
          foreach f {actions listbox} {
            grid [frame $frame.$f] \
              -row 0 -column $column -sticky snew
            incr column
          }
          #- actions frame
          foreach action {add delete load} {
            pack [set ${action}Button [button $frame.actions.button$action \
              -text $action -command "$self $action"]] \
              -padx 4 -pady 2 -anchor n -fill x
            bind $frame.actions.button$action <Return> { %W invoke }
            eval bind $frame.actions.button$action [@removeBindingsOnDestroyEvent]
          }
          $loadButton configure -text "load from file" -command "$self loadFromFile"
          focus $addButton

          #- listbox
          set listbox [[ListBox newWithPath: $frame.listbox.listbox] show]

          set addEntry [entry $path.entry -width 15]
          bind $addEntry <Return> \
            "place forget $addEntry ; \
            focus $addButton ; \
            $self add: \[%W get\]"
          eval bind $addEntry [@removeBindingsOnDestroyEvent]
        }
      - add {} {
          $addEntry delete 0 end
          place $addEntry -relx 0.0 -rely 0.0 -relwidth 1 \
            -y -[winfo reqheight $addEntry] -in [$listbox path]
          focus -force $addEntry
        }
      - delete {} {
          $listbox removeIndex: [$listbox indexOfSelection]
        }
      - insert {} {
          $self add
        }
      - remove {} {
          $self delete
        }
      - loadFromFile {} {
          $listbox loadFromFile: [tk_getOpenFile]
        }
      - forwardInvocation: msg {
          if [$listbox respondsTo: [@selector $msg]] {
            return [eval $listbox $msg]
          } else {
            return [eval $super $msg]
          }
        }
      - dealloc {} {
          $listbox dealloc
          catch {destroy $toplevel $path}
          return [$super dealloc]
        }
    }