home *** CD-ROM | disk | FTP | other *** search
- # CVS $Id: destroy.tcl,v 1.3 1995/02/03 16:54:31 zibi Exp $
- #
- # Test destroy and destroy dialog
- #
-
- source tools.tcl
-
- proc destroyDlogCB {cbs} {
- set target [keylget cbs widget]
-
- VtDestroyDialog $target
- }
-
- #
- # Makes a form dialog and calls the routine buildInside
- #
- proc mkDlogTst {buildInside cbs} {
- set parent [keylget cbs widget]
-
- set dlog [VtFormDialog $parent.dlog -title $buildInside -modeless \
- -verticalSpacing 10]
-
- $buildInside $dlog
-
- VtShowDialog $dlog
- }
-
- #
- # Just create a button who's callback just destroys itself
- #
- proc destroyDlog {parent} {
- VtPushButton $parent.destroy -label "Destroy Dialog"\
- -callback destroyDlogCB
- }
-
-
- #
- # This next test creates three victims and destroys them
- # one by one
- #
- proc destroyCB {parent vList cbs} {
- foreach but $vList {
- VtDestroy $but
- sleep 1
- }
- VtDestroyDialog $parent
- }
-
- proc destroyAny {parent} {
- set rc [VtRowColumn $parent.rc]
-
- set victimList {"Victim 1" "Victim 2" "Victim 3"}
- foreach but $victimList {
- lappend vObjList [VtPushButton $rc.$but -label $but]
- }
-
- VtPushButton $parent.destroy -label "Destroy em"\
- -callback "destroyCB $parent {$vObjList}" \
- -below $rc
- }
-
-
-
- #
- # This routine will call Create/Destroy many, many times
- #
- proc memLeakReps {parent label cbs} {
- for {set i 0} {$i < 50} {incr i} {
- set boo [VtPushButton $parent.boo$i -label "boo $i"\
- -shortHelpString "boo" -shortHelpCallback "QuitCB"\
- -callback "QuitCB"]
- VtDestroy $boo
- VtSetValues $label -label $i
-
- }
- }
-
- proc memLeak {parent} {
- set label [VtLabel $parent.leak -label "Number of Reps :"]
-
- set num [VtLabel $parent.num -label "0" -leftSide $label -alignTop $label]
-
- VtPushButton $parent.start -label Start \
- -leftSide FORM \
- -callback "memLeakReps $parent $num"
-
- VtPushButton $parent.close -label Close -callback "CloseDialogCB"
- }
-
- set ap [VtOpen destroy]
-
- set dlog [VtFormDialog $ap.form]
-
- set rc [VtRowColumn $dlog.rc]
-
- MakeCenteredButton $rc.destAny "VtDestroy" "mkDlogTst destroyAny"
- MakeCenteredButton $rc.destDlog "VtDestroyDialog" "mkDlogTst destroyDlog"
- MakeCenteredButton $rc.leaky "Mem Leak" "mkDlogTst memLeak"
- MakeCenteredButton $rc.exit "Exit" "QuitCB"
-
- VtShowDialog $dlog
-
- VtMainLoop
-