#!/bin/sh
# ----------------------------------------------------------------------
#  DEMO: spinner in [incr Widgets]
# ----------------------------------------------------------------------
#\
exec itkwish "$0" ${1+"$@"}
package require Iwidgets 3.0

# itkwish interprets the rest...
# ----------------------------------------------------------------------
option add *textBackground seashell

proc spinMonth {win step} {
    set months {
        January February March April
        May June July August September
        October November December
    }

    set index [expr [lsearch $months [$win get]] + $step]

    if {$index < 0} {set index 11}
    if {$index > 11} {set index 0}

    $win delete 0 end
    $win insert 0 [lindex $months $index]
}

iwidgets::spinner .sm -labeltext "Month:" -width 10 -fixed 10 \
    -decrement {spinMonth .sm -1} -increment {spinMonth .sm 1}

pack .sm
.sm insert 0 "January"
