# dblists.tcl -- Ray R. Larson (mar 92)
# Create a "listbox" style display box using the list passed as arg
# The second arg is a set of arguments for use in creating the message
# to be displayed in the message box area of the window.

proc mkListList {{tuple} {msgArgs {-text "Postgres Output List"}}} {
    set w [format ".%s_LIST" "attr"]
    catch {destroy $w}
    toplevel $w
    dpos $w
# have to list the possible lists (yuck)
    global PGUSERATTRLIST
    global PGSYSATTRLIST
    global PGATTRLIST
    set list [set $tuple]

    # Create three frames in the main window. The top frame will hold the
    # message and the bottom one will hold the <next> & <quit> buttons.
    # The middle frame holds the labels and data elements of the
    # instances of the retrieved tuples from the tuplearray. Arrange them
    # one above the other, with any extra vertical space split between
    # them.

    frame $w.top -relief raised -border 1
    frame $w.mid -relief raised -border 1
    frame $w.bot -relief raised -border 1

    pack append $w $w.top {top fill expand} $w.mid {top fill expand} $w.bot {bottom fill}

    # Create the message widget and arrange for it to be centered in the
    # top frame.

    eval message $w.top.msg -justify center \
	    -font -*-times-medium-r-normal--*-180* -aspect 300 $msgArgs
    pack append $w.top $w.top.msg {top expand fillx filly} 

    #
    # Create a scrolling listbox in the middle frame
    #
    pack append $w.mid \
	[scrollbar $w.mid.scroll -relief sunken \
	    -command "$w.mid.list yview"] {right expand filly frame w} \
	[listbox $w.mid.list -geometry 40x24 -yscroll "$w.mid.scroll set" -relief sunken] \
	     {left expand filly }

    #
    # Load the tuples into the listbox
    #
       foreach i $list {
          $w.mid.list insert end $i
       }



    bind $w.mid.list <Double-1> "set currselection \[selection get\] "

    #
    # Create the quit button in the bottom frame.
    #
    button $w.bot.ok -text Quit -command "destroy $w" -pady 5
    pack append $w.bot $w.bot.ok {bottom fill}

}


