[go: up one dir, main page]

File: cbtest.tcl

package info (click to toggle)
tile 0.8.2-2.1
  • links: PTS
  • area: main
  • in suites: lenny, squeeze
  • size: 3,152 kB
  • ctags: 3,093
  • sloc: ansic: 18,144; tcl: 4,607; makefile: 398; sh: 71
file content (125 lines) | stat: -rw-r--r-- 4,113 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
##
# combobox test program:
#
# side-by-side-by-side comparison of Tile, BWidget, and Brian Oakley's combobox
#

#
# Autocomplete: maybe need custom match procedure? (string match -nocase)
#
# Things to check:
# 	Focus indicator
#	Blinking insert cursor (none on readonly combobox)
#	Listbox scrollbar arrow lines up with popdown arrow
#	Mouse cursor (I-beam vs. normal) over various elements.
#	Normal mouse cursor in readonly combobox
#	Location of popdown menu when close to screen edge
#	Focus returns to combobox on Unpost (Cancel and Select)
#	ButtonRelease outside of popdown - Cancel? Select? Leave posted?
#	Keyboard traversal (incl. Shift+Tab).
#	-state disabled: 
#	+ grayed out
#	+ do not take focus on click
#	+ do not post listbox
#	Click in editable combobox -- should set icursor, don't select
#	Keyboard traversal into combobox -- should select
#	Traversal out of combobox (both <Tab> and <Shift-Tab>) 
#	Change value (using other combobox) -- repost listbox --
#	  make sure proper entry is highlighted.
#

lappend auto_path . ; package require tile
package require BWidget
package require combobox

source [file join [file dirname [info script]] testutils.tcl]

set values \
    [list abc def ghi jkl mno pqrs tuv wxyz yabba dabba scooby doobie doo]

set t [ttk::frame .t]

grid	[ttk::label $t.l1 -text "Tile"] \
	[ttk::label $t.l2 -text "BWidget"] \
	[ttk::label $t.l3 -text "Oakley"] \
	-row 1 -sticky news;

ttk::combobox $t.rcb1 -width 30 -textvariable V -values $values -state readonly
ComboBox $t.rcb2 -width 30 -textvariable V -values $values -editable false
combobox::combobox $t.rcb3 -textvariable V -width 30 -listvar values -editable false

ttk::combobox $t.ecb1 -width 30 -textvariable V -values $values
ComboBox $t.ecb2 -width 30 -textvariable V -values $values -editable true ;#-autocomplete true
combobox::combobox $t.ecb3 -textvariable V -width 30 -listvar values -editable true

grid $t.rcb1 $t.rcb2 $t.rcb3 -sticky news -pady 4 -padx 4 -row 2
grid $t.ecb1 $t.ecb2 $t.ecb3 -sticky news -pady 4 -padx 4 -row 3
grid columnconfigure $t 0 -uniform c -weight 1
grid columnconfigure $t 1 -uniform c -weight 1

# Active element monitor:
#
bind $t.rcb1 <Motion> { set ::element [%W identify %x %y] }
bind $t.ecb1 <Motion> { set ::element [%W identify %x %y] }

# Focus monitor:
#
proc focusMonitor {} { set ::focusWidget [focus] ; after 200 focusMonitor }
focusMonitor

# Grab monitor:
#
proc grabMonitor {} {
    global grabWidget
    set grabWidget [grab current]
    if {$grabWidget ne ""} {
	lappend grabWidget [grab status $grabWidget]
    }
    after 200 grabMonitor
}
grabMonitor


set mon [ttk::frame $t.mon]
ttk::label $mon.el -text "Element:" -anchor e
ttk::label $mon.e -textvariable ::element -anchor w
ttk::label $mon.fl -text "Focus:" -anchor e
ttk::label $mon.f -textvariable ::focusWidget -anchor w
ttk::label $mon.gl -text "Grab:" -anchor e
ttk::label $mon.g -textvariable ::grabWidget -anchor w
grid $mon.el $mon.e -row 0 -sticky news
grid $mon.fl $mon.f -row 1 -sticky news
grid $mon.gl $mon.g -row 2 -sticky news

grid columnconfigure $mon 1 -weight 1

grid $t.mon -row 0 -columnspan 2 -sticky nwe

grid rowconfigure $t 4 -weight 1
grid [ttk::frame $t.cmd] -row 5 -sticky nwes -columnspan 3
pack [ttk::button $t.cmd.close -text "Close" -command [list destroy .]] \
	-side right -padx 4 -pady 4

###

pack $t -expand true -fill both
focus $t.ecb1

if {[tk windowingsystem] eq "aqua"} { set Meta Command } { set Meta Alt }

bind all <$Meta-Key-d> { %W configure -state disabled }	;# "&disable"
bind all <$Meta-Key-e> { %W configure -state normal }	;# "&enable"
bind all <$Meta-Key-w> { %W configure -state readonly }	;# "&write-protect"

bind all <$Meta-Key-q> { destroy . }
bind all <$Meta-Key-b> { error "BGerror - testing" }

bind all <Control-ButtonPress-1> { focus -force %W }

bind all <FocusIn>	{ puts "+F: %W" }
bind all <FocusOut>	{ puts "-f: %W" }
bind all <ButtonPress>	{ puts "+B: %W" }
bind all <ButtonRelease>	{ puts "-b: %W" }
bind all <KeyPress-m>	{ puts "---- mark ----" }

# In case of a stuck grab: <Control-Button-1> to set focus; <Alt-q> to quit