#
# signal.test
#
# Tests for the Tk signal handling.
#---------------------------------------------------------------------------
# Copyright 1993-1999 Karl Lehenbauer and Mark Diekhans.
#
# Permission to use, copy, modify, and distribute this software and its
# documentation for any purpose and without fee is hereby granted, provided
# that the above copyright notice appear in all copies.  Karl Lehenbauer and
# Mark Diekhans make no representations about the suitability of this
# software for any purpose.  It is provided "as is" without express or
# implied warranty.
#------------------------------------------------------------------------------
# $Id: signal.test,v 1.1.1.1 1999/06/28 20:35:36 damon Exp $
#------------------------------------------------------------------------------
#

# FIX: need to automate and make part of make tktest.

foreach i [winfo children .] {
    destroy $i
}

#
# Alarm signal handler.
#
proc SignalAlarmHandler {signal} {
    signal default $signal
    puts "Got $signal"

    toplevel .signalHand
    label .signalHand.label -borderwidth 6 -relief sunken \
         -text "Received $signal"
    button .signalHand.dismiss  -text "Dismiss" \
        -command {destroy .signalHand}

    pack configure .signalHand.label .signalHand.dismiss -fill x
    grab .signalHand
}

#
# Callback to start timer.
#
proc SignalTimerCB {} {
    signal trap SIGALRM {SignalAlarmHandler %S}
    alarm 1
}

#
# Main program.  Setup form with button to start signal handler.
#

set title {Extended Tk Signal Handler Test}

frame .signalTest

label .signalTest.title -borderwidth 6 -relief sunken -text $title

button .signalTest.alarm -text "Alarm in 1 second" -command SignalTimerCB
button .signalTest.exit  -text "Exit" -command exit

pack configure .signalTest .signalTest.title \
        .signalTest.alarm .signalTest.exit \
        -fill x


