set scriptDir [file normalize [file join [file dirname [info script]] ".."]]
set auto_path [linsert $auto_path 0 $scriptDir]

package require Tk
package require poFti

set w 200
set h 200
set count 0
set row 0
set col 0

# Canvas to draw the icon into and create a photo image
# for display.
canvas .c -width $w -height $h -background "#C9C9C9" \
          -borderwidth 0 -highlightthickness 0
pack .c

frame .fr
pack .fr -expand true -fill both

# Call each poFti::generic* procedure and create a photo
# image for that icon.
foreach cmd [lsort -dictionary [info commands poFti::generic*]] {
    set iconObj [poFti Icon new]
    $iconObj ReadFromString [$cmd]
    $iconObj Draw .c
    set phImg [$iconObj AsPhoto .c]

    label .fr.i_$count -image $phImg
    label .fr.l_$count -text $cmd
    grid .fr.i_$count -row $row -column $col
    grid .fr.l_$count -row [expr {$row+1}] -column $col
    incr count
    incr col
    if { $col >= 5 } {
        incr row 2
        set col 0
    }
    .c delete "FtiIcon"
}
destroy .c

wm title . "Generic FTI icons"
bind . <Escape> exit
