#************************************************************
#
# annotate.tcl --
#
#    Show annotation list in pop-up window.
#
#  This isn't used anymore.
#
# Created: 12/17/98
# Author: Dan Gunter
#
#************************************************************

#############################################################
#
# AddAnnotation --
#
#      Add the list of fields and values to the annotation
#      list.
#
proc AddAnnotation { alist color } {
    global widget param

    if { $param(ShowAnnotation) == 0 } {
	ToggleAnnWindow
    }
    set txt $widget(anntxt)
    set alen [llength $alist]
    set n $param(_numann)
    set newtag ""
    # if we filled up the list, delete the last one
    if { $n == $param(maxannotations) } {
       set newtag [$txt tag names $n.0]
       $txt tag delete $newtag
       $txt delete $n.0 end
       incr n -1
    }
    set str ""
    set fpos {}
    for {set i 0} {$i < $alen} {incr i 2} {
	set fld [lindex $alist $i]
	set val [lindex $alist [expr $i + 1]]
        lappend fpos [string length $str]
        set str "$str $fld: $val,"
    }
    # turn off underline on (old) 1st element
    set old1tag [$txt tag names 1.0]
    $txt tag configure $old1tag -underline 0
    # chop off trailing comma
    set str [string range $str 0 [expr [string length $str]-2]]
    # place in listbox
    $txt insert 1.0 "$str\n"
    incr n
    if { $newtag == "" } {
        set newtag $n
    }
    $txt tag add $newtag 1.0 {1.0 lineend}
    $txt tag configure $newtag -foreground $color -underline 1 
    set param(_numann) $n
}

#############################################################
#
# ShowAnnotation --
#
#     Create the annotation list for showing annotations.
#
#proc ShowAnnotation { x y h } {
#    global param widget
#
#    if { [info exists widget(annwin)] } {
#	wm deiconify $widget(annwin)
#	return
#    }
#    set w [toplevel .annwin]
#    wm geometry $w "+$x+$y"
#    wm title $w "Annotation"
#    wm iconbitmap $w nlvicon
#    set scrlsz 15
#    frame $w.f -bg $param(color-winbg) \
#	-borderwidth 4 \
#	-relief raised
#    text $w.f.txt \
#        -wrap none \
#	-bg \#ffffff \
#	-fg \#000000 \
#	-height $h \
#        -yscrollcommand "$w.f.yscrl set" \
#	-xscrollcommand "$w.f.xscrl set"
#    button $w.dismiss \
#	-bg $param(color-ctlbg) \
#	-text "Dismiss" \
#	-command {ToggleAnnWindow}
#    scrollbar $w.f.yscrl -orient vert -command "$w.f.txt yview" -width $scrlsz
#    scrollbar $w.f.xscrl -orient horiz -command "$w.f.txt xview" -width $scrlsz
#    pack $w.f.yscrl -side right  -fill y
#    pack $w.dismiss -side bottom -fill x
#    pack $w.f.xscrl -side bottom -fill x
#    pack $w.f.txt -side left
#    pack $w.f -side top -fill both
#    set widget(annwin) $w
#    set widget(anntxt) $w.f.txt
#    set param(_numann) 0
#    return
#}

proc ShowAnnotation { x y h } {
    puts "ShowAnnotation"

    return
}


#############################################################
#
# HideAnnotation --
#
#     Make the annotation window into an icon.
#
proc HideAnnotation { } {
    global widget

    wm iconify $widget(annwin)
}

