[go: up one dir, main page]

File: sbtest.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 (79 lines) | stat: -rw-r--r-- 1,967 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
#
# side-by-side interactive test of Tk vs. Tile scrollbars.
#

lappend auto_path .

package require Tk
package require tile

proc sbstub {sb cmd number {units units}} {
    # puts [info level 0]
    sbstub.$cmd $sb $number $units
}
proc sbstub.moveto {sb number _} {
    $sb set $number [expr {$number + 0.5}]
    # puts "[$sb get]"
}
proc sbstub.scroll {sb number units} {
    if {$units eq "pages"} {
    	set delta 0.2
    } else {
	set delta 0.05
    }
    set current [$sb get]
    set new0 [expr {[lindex $current 0] + $delta*$number}] 
    set new1 [expr {[lindex $current 1] + $delta*$number}]
    $sb set $new0 $new1 ;
    # puts "$current - $new0 $new1 - [$sb get]"
}

wm geometry . 400x200

pack [scrollbar .hsb -orient horizontal -command [list sbstub .hsb]] \
    -side top -expand false -fill x
pack [tscrollbar .thsb -orient horizontal -command [list sbstub .thsb]]  \
    -side top -expand false -fill x
pack [scrollbar .vsb -orient vertical -command [list sbstub .vsb]] \
    -side left -expand false -fill y
pack [tscrollbar .tvsb -orient vertical -command [list sbstub .tvsb]] \
    -side left -expand false -fill y

pack [set c [frame .client]] -expand true -fill both

grid \
	[label $c.li -text "Element:" -anchor w] \
	[entry $c.i -textvariable ::identified] \
	-sticky ew

grid \
	[label $c.lf -text "Fraction:" -anchor w] \
	[entry $c.f -textvariable ::fraction] \
	-sticky ew

grid \
	[label $c.lr -text "Range:" -anchor w] \
	[entry $c.r -textvariable ::range] \
	-sticky ew

grid columnconfigure $c 1 -weight 1

bind Test <ButtonPress-1>  { sbdebug %W %x %y }
bind Test <B1-Motion>      { sbdebug %W %x %y }
bind Test <B2-Motion>      { sbdebug %W %x %y }

proc sbdebug {W x y} {
    set ::identified [$W identify $x $y] 
    set ::fraction [$W fraction $x $y]
    set ::range [$W get]
}

foreach w {.vsb .hsb .tvsb .thsb} {
    bindtags $w [linsert [bindtags $w] 0 Test]
}

.vsb set 0 0.5
.hsb set 0 0.5
.tvsb set 0 0.5
.thsb set 0 0.5