# Copyright 2022-2026 Paul Obermeier (obermeier@tcl3d.org)
#
# Test program for the poFti package.
# Read and display a FTI (File Type Icon) file.

package require Tk
package require poFti

set ftiFile [file join "Data" "spiralColored.fti"]
set imgSize 400

proc P { msg } {
    .info.t insert end $msg
    .info.t insert end "\n"
    puts $msg
}

frame .img
pack [canvas .img.c -width 400 -height 400]
frame .info
pack [text .info.t -width 60 -height 1]

puts "Reading file $ftiFile ..."
set iconObj [poFti Icon new]
$iconObj Read $ftiFile
$iconObj Draw .img.c -width $imgSize -height $imgSize

P "Number of items: [$iconObj GetNumItems]"

label .msg -text \
    [format "Using poFti %s on %s with %dbit Tcl %s and Tk %s" \
    [package version poFti] $::tcl_platform(os) \
    [expr $::tcl_platform(pointerSize) * 8] \
    [info patchlevel] $::tk_patchLevel]

grid .img  -row 0 -column 0
grid .info -row 1 -column 0
grid .msg  -row 2 -column 0

bind . <Escape> { exit }

if { [lindex $argv 0] eq "auto" } {
    update
    after 500
    exit
}
