
if ![winfo exists .obtclDemo] {
	set obW .obtclDemo
	toplevel .obtclDemo -width 600 -height 400

	source obtcl
	source ScrText.tcl
	source PanedW.tcl
	source Tabs.tcl
	source Layout.tcl
	source wrap

	StrictMotif

	Tab $obW.tab
	$obW.tab tab_background grey75
	pack $obW.tab -fill both -expand yes -in $obW.right
}

catch {destroy $obW.docs}

PanedWindow $obW.docs -fraction .25 -borderwidth 2

TkManText $obW.docs.tktext
#$obW.docs.tktext configure -foo bar

ScrolledText $obW.docs.titles \
	-scrollbars y -textrelief sunken -autoy true \
	-writable 0 -cursor arrow -spacing1 1 -spacing3 1 \
	-background grey80

ScrolledText $obW.docs.text \
	-useTextWidget $obW.docs.tktext \
	-textrelief sunken \
	-writable 0 \
	-background grey80

$obW.docs manage $obW.docs.titles $obW.docs.text
pack configure $obW.docs.titles $obW.docs.text -pady 1 -padx 0

$obW.tab manage [list "Docs" $obW.docs {-padx 5 -pady 3}]

update

source ${OBTCL_LIBRARY}/README
set idx "obTcl man page"
set list [concat [list $idx] [lsort [DOC_get_list]]]
set TkMan($idx) obTcl.tkman

set currDoc ""

proc MyGetDOC { name } {
	global TkMan OBTCL_LIBRARY
	if [info exists TkMan($name)] {
		return [exec cat ${OBTCL_LIBRARY}/$TkMan($name)]
	} else {
		return "\$t insert end {[GetDOC $name]}"
	}
}

proc getDoc { name tag } {
	global obW currDoc savedPos lastTag

	set savedPos($currDoc) [lindex [$obW.docs.text yview] 0]
	$obW.docs.text delete 0.0 end
	$obW.docs.tktext tkman_insert [MyGetDOC $name]
	if [info exists savedPos($name)] {
		$obW.docs.text yview moveto $savedPos($name)
	}
	set currDoc $name
	if [info exists lastTag] {
		$obW.docs.titles tag configure $lastTag -relief flat
	}
	$obW.docs.titles tag configure $tag -relief raised -borderwidth 1
	set lastTag $tag
}

set nl ""
set cnt 0

proc hot { tag } {
	global obW
	$obW.docs.titles tag configure $tag -foreground red
}
proc cool { tag } {
	global obW
	$obW.docs.titles tag configure $tag -foreground black
}

foreach i $list {
	$obW.docs.titles tag bind row$cnt <B1-ButtonRelease-1> \
		[list getDoc $i row$cnt]
	$obW.docs.titles tag bind row$cnt <B1-Motion><ButtonRelease-1> {break}
	$obW.docs.titles tag bind row$cnt <Enter> "hot row$cnt"
	$obW.docs.titles tag bind row$cnt <Leave> "cool row$cnt"
	$obW.docs.titles insert end "$nl" 
	$obW.docs.titles insert end " $i " row$cnt
	incr cnt
	set nl "\n"
}
