# browsedoclist.tcl -- for S2K browser
#   Ray R. Larson (mar 92)
#
proc browsedoclist {{win .docs} {ranklist "none"} {messag "Browse Results"}} {

if {[string compare "$ranklist" "none"] == 0} \
   {error "browsedoclist requires ranked list of {rank oid title}"} {}

global WINCOUNT
incr WINCOUNT
set w "$win$WINCOUNT"

catch {destroy $w}

toplevel $w -relief {raised}
wm geometry $w +404+178
wm maxsize $w 1100 850
wm minsize $w 10 10
#wm positionfrom $w program
wm title $w "Browse Documents"

global BIGFONT

frame $w.fm13 -borderwidth {2}  -geometry {20x20}  -relief {raised}

frame $w.fm13.fm14

entry $w.fm13.fm14.ent -relief {raised}  -width {45}
#bind.entry $w.fm13.fm14.ent

label $w.fm13.fm14.lab -relief {raised}  -text {Filter by: }

pack append $w.fm13.fm14 \
              $w.fm13.fm14.lab {left  expand fillx} \
              $w.fm13.fm14.ent {left  expand fillx}

pack append $w.fm13 \
              $w.fm13.fm14 {top expand fillx }

frame $w.fm7 -borderwidth {2}  -geometry {20x20}

button $w.fm7.butt12  -text {Help} \
                -command "createHelpListBox Doc_List_Help doclist.help"


button $w.fm7.butt11   -command "destroy $w"\
       -text {Cancel Browse}

button $w.fm7.butt10   -command {findsimilar}\
       -text {Find Similar}

button $w.fm7.butt8   -command {viewdoc [selection.get]} \
       -text {View Document}

pack append $w.fm7  \
            $w.fm7.butt8 {left pady 10 expand fillx filly}  \
            $w.fm7.butt10 {left expand fillx filly} \
            $w.fm7.butt12 {left expand fillx filly} \
            $w.fm7.butt11 {left expand fillx filly} 

frame $w.fm5 -borderwidth {2}  -geometry {20x20}  -relief {raised}

frame $w.fm5.fm6

scrollbar $w.fm5.fm6.scr  -relief {raised}


scrollbar $w.fm5.fm6.scry -command "$w.fm5.fm6.list yview"  -relief {raised}
scrollbar $w.fm5.fm6.scrx -command "$w.fm5.fm6.list xview"  -relief {raised} -orient horizontal

listbox $w.fm5.fm6.list -geometry {75x24}  -relief {sunken}  -yscroll "$w.fm5.fm6.scry set" -xscroll "$w.fm5.fm6.scrx set"

bind $w.fm5.fm6.list <Double-Button-1>  {viewdoc [selection.get]}

pack $w.fm5.fm6.scry -side right -fill y
pack $w.fm5.fm6.scrx -side bottom -fill x
pack $w.fm5.fm6.list -expand yes -fill y

pack append $w.fm5  $w.fm5.fm6 {top frame center}

frame $w.fm3 -borderwidth {2}  -geometry {20x20}  -relief {raised}

message $w.fm3.mess4 -aspect {645}  \
    -font $BIGFONT \
    -justify {center}  -padx {0}  -pady {2}  -relief {raised} \
    -text "$messag"

pack append $w.fm3 \
            $w.fm3.mess4 {left frame center padx 100 expand fill}

pack append $w \
            $w.fm3 {top frame center expand fillx} \
            $w.fm5 {top frame center} \
            $w.fm7 {top frame center expand fillx}  \
            $w.fm13 {left frame center expand fillx}

$w config -cursor watch
update


# run the retrieve command to get the names from Postgres
#

set len [ llength $ranklist ]
for {set tmp [llength $ranklist]} {$tmp + 1} {incr tmp -1} {
     set fldval [join [concat [lrange [lindex $ranklist $tmp] 2 end]]]
     $w.fm5.fm6.list insert end "$fldval"
}

$w config -cursor top_left_arrow


#end browsedoclist
}



