1 |
578 |
markom |
#
|
2 |
|
|
# Tests for [incr Tk] widgets based on itk::Toplevel
|
3 |
|
|
# ----------------------------------------------------------------------
|
4 |
|
|
# AUTHOR: Michael J. McLennan
|
5 |
|
|
# Bell Labs Innovations for Lucent Technologies
|
6 |
|
|
# mmclennan@lucent.com
|
7 |
|
|
# http://www.tcltk.com/itcl
|
8 |
|
|
#
|
9 |
|
|
# RCS: $Id: toplevel.test,v 1.1.1.1 2002-01-16 10:24:48 markom Exp $
|
10 |
|
|
# ----------------------------------------------------------------------
|
11 |
|
|
# Copyright (c) 1993-1998 Lucent Technologies, Inc.
|
12 |
|
|
# ======================================================================
|
13 |
|
|
# See the file "license.terms" for information on usage and
|
14 |
|
|
# redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
15 |
|
|
|
16 |
|
|
if {[string compare test [info procs test]] == 1} then {source defs}
|
17 |
|
|
|
18 |
|
|
# ----------------------------------------------------------------------
|
19 |
|
|
# Toplevel mega-widget
|
20 |
|
|
# ----------------------------------------------------------------------
|
21 |
|
|
test toplevel-1.1 {define a toplevel mega-widget class} {
|
22 |
|
|
option add *TestToplevel.background linen
|
23 |
|
|
option add *TestToplevel.cursor ""
|
24 |
|
|
option add *TestToplevel.foreground navy
|
25 |
|
|
option add *TestToplevel.highlight white
|
26 |
|
|
option add *TestToplevel.normal ivory
|
27 |
|
|
option add *TestToplevel.text ""
|
28 |
|
|
|
29 |
|
|
itcl::class TestToplevel {
|
30 |
|
|
inherit itk::Toplevel
|
31 |
|
|
constructor {args} {
|
32 |
|
|
itk_component add test1 {
|
33 |
|
|
label $itk_interior.t1
|
34 |
|
|
} {
|
35 |
|
|
keep -background -foreground -cursor
|
36 |
|
|
keep -text
|
37 |
|
|
}
|
38 |
|
|
pack $itk_component(test1) -side left -padx 2
|
39 |
|
|
eval itk_initialize $args
|
40 |
|
|
}
|
41 |
|
|
public method do {cmd} {
|
42 |
|
|
eval $cmd
|
43 |
|
|
}
|
44 |
|
|
|
45 |
|
|
private variable status ""
|
46 |
|
|
itk_option define -background background Background {} {
|
47 |
|
|
lappend status "background: $itk_option(-background)"
|
48 |
|
|
}
|
49 |
|
|
}
|
50 |
|
|
TestToplevel .#auto
|
51 |
|
|
} {.testToplevel0}
|
52 |
|
|
|
53 |
|
|
test toplevel-1.2 {check the list of configuration options} {
|
54 |
|
|
.testToplevel0 configure
|
55 |
|
|
} {{-background background Background linen linen} {-clientdata clientData ClientData {} {}} {-cursor cursor Cursor {} {}} {-foreground foreground Foreground navy navy} {-takefocus takeFocus TakeFocus 0 0} {-text text Text {} {}} {-title title Title {} {}}}
|
56 |
|
|
|
57 |
|
|
test toplevel-1.3 {check the list components} {
|
58 |
|
|
lsort [.testToplevel0 component]
|
59 |
|
|
} {hull test1}
|
60 |
|
|
|
61 |
|
|
test toplevel-1.4 {check the propagation of configuration options} {
|
62 |
|
|
.testToplevel0 configure -background red
|
63 |
|
|
list [.testToplevel0 component hull cget -background] \
|
64 |
|
|
[.testToplevel0 component test1 cget -background] \
|
65 |
|
|
[.testToplevel0 do {set status}]
|
66 |
|
|
} {red red {{background: linen} {background: red}}}
|
67 |
|
|
|
68 |
|
|
test toplevel-1.5 {mega-widgets show up on the object list} {
|
69 |
|
|
itcl::find objects .testToplevel*
|
70 |
|
|
} {.testToplevel0}
|
71 |
|
|
|
72 |
|
|
test toplevel-1.6 {when a mega-widget is destroyed, its object is deleted} {
|
73 |
|
|
destroy .testToplevel0
|
74 |
|
|
itcl::find objects .testToplevel*
|
75 |
|
|
} {}
|
76 |
|
|
|
77 |
|
|
# ----------------------------------------------------------------------
|
78 |
|
|
# Clean up
|
79 |
|
|
# ----------------------------------------------------------------------
|
80 |
|
|
itcl::delete class TestToplevel
|