#!./nistk -f
#
# Copyright (C) 1994 Matthew R. Wette -- All rights reserved.
#
# Permission to use, copy, modify, and distribute this software and its
# documentation for any purpose and without fee is hereby granted, provided
# that the above copyright notice appears in all copies.  Matthew R. Wette
# makes no representations about the suitability of this software for any
# purpose.  It is provided "as is" without express or implied warranty.
#
# nttable -
#
# history -
#	18Feb94	M.Wette: created.
#
# version -
#	$Id$

set t_font -Adobe-courier-bold-r-normal--*-140*

proc nis_listbox {w t} {
  global t_width t_header t_font
  message $w.msg -text "$t_header($t)" \
	-anchor w -aspect 1000 -justify left -font $t_font
  frame $w.frame -borderwidth 10
  pack $w.msg -side top -expand yes -fill x
  pack $w.frame -side top -expand yes -fill both

  scrollbar $w.frame.scroll -relief sunken -command "$w.frame.list yview"
  listbox $w.frame.list -yscroll "$w.frame.scroll set" \
	-relief sunken -setgrid 1 -font $t_font -geometry $t_width($t)x20
  pack $w.frame.scroll -side right -fill y
  pack $w.frame.list -side left -expand yes -fill both
}

###############################################################################

if {$argc==0} {
  set table auto_proj
} else {
  set table [lindex $argv 0]
}

source $nis_library/$table.tcl

set list [nis_cat $table.$nis_cwd]
set list [lsort -command t_sort_proc($table) $list]

frame .l1
nis_listbox .l1 $table
pack .l1

#.l1.frame.list insert end $t_header($table)
foreach {item} $list {
  #.l1.frame.list insert end [lindex [t_entry_proc($table) $item] 0]
  .l1.frame.list insert end [t_entry_proc($table) $item]
}

# --- last line of table ---
