Tk Library Source Code
Check-in [bba3c2b679]
Not logged in
Bounty program for improvements to Tcl and certain Tcl packages.

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment: * ../../examples/scrollutil/*.tcl: Made the demo-scripts fully scaling-aware.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256:bba3c2b6795042603b6a5bce3dabab96385f7c7d997489263fe00ccfaf491bb0
User & Date: csaba 2020-06-23 10:02:08
Context
2020-06-23
19:31
* ../../examples/scrollutil/*FrmDemo1.tcl: Worked around an accuracy * ../../examples/scrollutil/*FrmContent.tcl: problem related to the scaling on Cinnamon. check-in: 6be65a0ed6 user: csaba tags: trunk
10:02
* ../../examples/scrollutil/*.tcl: Made the demo-scripts fully scaling-aware. check-in: bba3c2b679 user: csaba tags: trunk
10:00
* doc/*.png Updated screenshots. check-in: 187fa91cd7 user: csaba tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to examples/scrollutil/BwScrollableFrmContent.tcl.

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



126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
...
231
232
233
234
235
236
237
238

239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
...
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
...
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
...
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
...
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
...
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
...
455
456
457
458
459
460
461

462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478

#
# A scrolled text widget with old-school mouse wheel support
#
set row 0
set l [ttk::label $cf.l$row -text \
       "Contents of the Tablelist distribution file \"CHANGES.txt\":"]
grid $l -row $row -column 0 -columnspan 3 -sticky w -padx 10 -pady {10 0}
incr row
set _sa [scrollutil::scrollarea $cf.sa$row]
set txt [text $_sa.txt -font TkFixedFont -width 73]
scrollutil::addMouseWheelSupport $txt
$_sa setwidget $txt
grid $_sa -row $row -column 0 -columnspan 3 -sticky w -padx 10 -pady {5 0}

#
# A scrolled listbox widget
#
incr row
set l [ttk::label $cf.l$row -text "Tablelist releases:"]
grid $l -row $row -column 0 -sticky w -padx {10 0} -pady {10 0}
incr row
set _sa [scrollutil::scrollarea $cf.sa$row]
set lb [listbox $_sa.lb -width 0]
$_sa setwidget $lb
grid $_sa -row $row -rowspan 6 -column 0 -sticky w -padx {10 0} -pady {5 0}

#
# A ttk::combobox widget
#
set l [ttk::label $cf.l$row -text "Release:"]
grid $l -row $row -column 1 -sticky w -padx {10 0} -pady {5 0}
set cb [ttk::combobox $cf.cb -state readonly -width 14]
grid $cb -row $row -column 2 -sticky w -padx {5 10} -pady {5 0}

#
# A ttk::spinbox widget
#
incr row
set l [ttk::label $cf.l$row -text "Changes:"]
grid $l -row $row -column 1 -sticky w -padx {10 0} -pady {10 0}
set sb [ttk::spinbox $cf.sb -from 0 -to 20 -state readonly -width 4]
grid $sb -row $row -column 2 -sticky w -padx {5 10} -pady {10 0}

#
# A ttk::entry widget
#
incr row
set l [ttk::label $cf.l$row -text "Comment:"]
grid $l -row $row -column 1 -sticky w -padx {10 0} -pady {10 0}
set e [ttk::entry $cf.e -width 32]
grid $e -row $row -column 2 -sticky w -padx {5 10} -pady {10 0}

#
# A ttk::separator widget
#
incr row
set sep [ttk::separator $cf.sep]
grid $sep -row $row -column 1 -columnspan 2 -sticky we -padx 10 -pady {10 0}

#
# A mentry widget of type "Date"
#
incr row
set l [ttk::label $cf.l$row -text "Date of first release:"]
grid $l -row $row -column 1 -sticky w -padx {10 0} -pady {10 0}
set me [mentry::dateMentry $cf.me Ymd -]
grid $me -row $row -column 2 -sticky w -padx {5 10} -pady {10 0}

incr row
grid rowconfigure $cf $row -weight 1

#
# A scrolled tablelist widget
#
incr row
set l [ttk::label $cf.l$row -text \
       "Tablelist release statistics, displayed in a tablelist widget:"]
grid $l -row $row -column 0 -columnspan 3 -sticky w -padx 10 -pady {10 0}
incr row
set _sa [scrollutil::scrollarea $cf.sa$row]
set tbl [tablelist::tablelist $_sa.tbl \
	 -columns {0 "Release" left  0 "Changes" right  0 "Comment" left} \
	 -height 16 -width 0 -showseparators yes -stripebackground #f0f0f0 \
	 -incrarrowtype down -labelcommand tablelist::sortByColumn]
if {[$tbl cget -selectborderwidth] == 0} {
    $tbl configure -spacing 1
}
$tbl columnconfigure 0 -name release -sortmode dictionary
$tbl columnconfigure 1 -name changes -sortmode integer
$tbl columnconfigure 2 -name comment
$_sa setwidget $tbl
grid $_sa -row $row -column 0 -columnspan 3 -sticky w -padx 10 -pady {5 0}










#
# A scrolled ttk::treeview widget
#
incr row
set l [ttk::label $cf.l$row -text \
       "Tablelist release statistics, displayed in a ttk::treeview widget:"]
grid $l -row $row -column 0 -columnspan 3 -sticky w -padx 10 -pady {10 0}
incr row
set _sa [scrollutil::scrollarea $cf.sa$row -borderwidth 0]



set tv [ttk::treeview $_sa.tv -columns {release changes comment} \
	-show headings -height 16 -selectmode browse]
if {$ttk::currentTheme eq "aqua" &&
    [package vcompare $::tk_patchLevel "8.6.10"] >= 0} {
    $_sa configure -borderwidth 1 ;# because in this case $tv has a flat relief
}
$tv heading release -text " Release" -anchor w
$tv heading changes -text "Changes " -anchor e
$tv heading comment -text " Comment" -anchor w
$tv column release -anchor w
$tv column changes -anchor e
$tv column comment -anchor w
$_sa setwidget $tv
grid $_sa -row $row -column 0 -columnspan 3 -sticky w -padx 10 -pady {5 10}

grid columnconfigure $cf 2 -weight 1

#
# Populate the widgets
#

................................................................................
    $tv column $colId -width [$tbl columnwidth $colId -total]
}

#
# Set the ScrollableFrame's width, height, and yscrollincrement
#
update idletasks
set height [expr {[winfo reqheight $cf.l0] + [winfo reqheight $cf.sa1] + 25}]

$sf configure -width [winfo reqwidth $cf] -height $height \
    -yscrollincrement [expr {[winfo reqheight $lb] / 10}]

pack $sa -expand yes -fill both -padx 10 -pady 10

#
# Create two ttk::button widgets within a frame outside the scrollarea
#
set bf [ttk::frame .bf]
set b1 [ttk::button $bf.b1 -text "Configure Tablelist Widget" \
        -command configTablelist]
set b2 [ttk::button $bf.b2 -text "Close" -command exit]
pack $b2 -side right -padx 10 -pady {0 10}
pack $b1 -side left -padx 10 -pady {0 10}

pack $bf -side bottom -fill x
pack $tf -side top -expand yes -fill both

#------------------------------------------------------------------------------

proc cancelEdit {w args} {
................................................................................
    foreach configSet [$tbl configure] {
	if {[llength $configSet] != 5} {
	    continue
	}

	set opt [lindex $configSet 0]
	set w [ttk::label $cf.l$row -text $opt]
	grid $w -row $row -column 0 -sticky w -padx {5 0} -pady {5 0}

	set w $cf.w$row
	switch -- $opt {
	    -activestyle -
	    -arrowstyle -
	    -incrarrowtype -
	    -labelrelief -
................................................................................
			winxpOlive winxpSilver yuyo}
		    }
		}

		$w configure -values $values
		$w set [$tbl cget $opt]
		bind $w <<ComboboxSelected>> [list applyValue %W $opt]
		grid $w -row $row -column 1 -sticky w -padx 5 -pady {5 0}

		#
		# Adapt the handling of the mouse wheel
		# events for the ttk::combobox widget
		#
		scrollutil::adaptWheelEventHandling $w
	    }
................................................................................
	    -showlabels -
	    -showseparators -
	    -tight {
		ttk::checkbutton $w -command [list applyBoolean $w $opt]
		global $w
		set $w [$tbl cget $opt]
		$w configure -text [expr {[set $w] ? "true": "false"}]
		grid $w -row $row -column 1 -sticky w -padx 5 -pady {5 0}
	    }

	    -borderwidth -
	    -height -
	    -highlightthickness -
	    -labelborderwidth -
	    -labelheight -
................................................................................
		$w set [$tbl cget $opt]
		$w configure -invalidcommand bell -validate key \
		    -validatecommand \
		    {expr {[string length %P] <= 3 && [regexp {^[0-9]*$} %S]}}
		foreach event {<Return> <KP_Enter> <FocusOut>} {
		    bind $w $event [list applyValue %W $opt]
		}
		grid $w -row $row -column 1 -sticky w -padx 5 -pady {5 0}

		#
		# Adapt the handling of the mouse wheel
		# events for the ttk::spinbox widget
		#
		scrollutil::adaptWheelEventHandling $w
	    }
................................................................................

	    default {
		ttk::entry $w -width 20
		$w insert 0 [$tbl cget $opt]
		foreach event {<Return> <KP_Enter> <FocusOut>} {
		    bind $w $event [list applyValue %W $opt]
		}
		grid $w -row $row -column 1 -sticky we -padx 5 -pady {5 0}
	    }
	}

	#
	# Make the keyboard navigation more user-friendly
	#
	bind $w <<TraverseIn>> [list $sf see %W]
................................................................................
    grid columnconfigure $cf 1   -weight 1

    #
    # Set the ScrollableFrame's width, height, and yscrollincrement
    #
    update idletasks
    set rowHeight [expr {[winfo reqheight $cf] / $row}]

    $sf configure -width [winfo reqwidth $cf] \
	-height [expr {10*$rowHeight + 5}] -yscrollincrement $rowHeight

    #
    # Create a ttk::button widget outside the scrollarea
    #
    set b [ttk::button $f.b -text "Close" -command [list destroy $top]]

    pack $b  -side bottom -pady {0 10}
    pack $sa -side top -expand yes -fill both -padx 10 -pady 10
    pack $f  -expand yes -fill both
}

#------------------------------------------------------------------------------

proc applyValue {w opt} {
    global tbl







|





|






|




|





|

|






|

|






|

|






|






|

|










|













|
>
>
>
>
>
>
>
>
>







|


>
>
>













|







 







|
>



|








|
|







 







|







 







|







 







|







 







|







 







|







 







>
|
|






|
|







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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
...
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
...
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
...
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
...
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
...
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
...
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
...
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492

#
# A scrolled text widget with old-school mouse wheel support
#
set row 0
set l [ttk::label $cf.l$row -text \
       "Contents of the Tablelist distribution file \"CHANGES.txt\":"]
grid $l -row $row -column 0 -columnspan 3 -sticky w -padx 7p -pady {7p 0}
incr row
set _sa [scrollutil::scrollarea $cf.sa$row]
set txt [text $_sa.txt -font TkFixedFont -width 73]
scrollutil::addMouseWheelSupport $txt
$_sa setwidget $txt
grid $_sa -row $row -column 0 -columnspan 3 -sticky w -padx 7p -pady {4p 0}

#
# A scrolled listbox widget
#
incr row
set l [ttk::label $cf.l$row -text "Tablelist releases:"]
grid $l -row $row -column 0 -sticky w -padx {7p 0} -pady {7p 0}
incr row
set _sa [scrollutil::scrollarea $cf.sa$row]
set lb [listbox $_sa.lb -width 0]
$_sa setwidget $lb
grid $_sa -row $row -rowspan 6 -column 0 -sticky w -padx {7p 0} -pady {4p 0}

#
# A ttk::combobox widget
#
set l [ttk::label $cf.l$row -text "Release:"]
grid $l -row $row -column 1 -sticky w -padx {7p 0} -pady {4p 0}
set cb [ttk::combobox $cf.cb -state readonly -width 14]
grid $cb -row $row -column 2 -sticky w -padx {4p 7p} -pady {4p 0}

#
# A ttk::spinbox widget
#
incr row
set l [ttk::label $cf.l$row -text "Changes:"]
grid $l -row $row -column 1 -sticky w -padx {7p 0} -pady {7p 0}
set sb [ttk::spinbox $cf.sb -from 0 -to 20 -state readonly -width 4]
grid $sb -row $row -column 2 -sticky w -padx {4p 7p} -pady {7p 0}

#
# A ttk::entry widget
#
incr row
set l [ttk::label $cf.l$row -text "Comment:"]
grid $l -row $row -column 1 -sticky w -padx {7p 0} -pady {7p 0}
set e [ttk::entry $cf.e -width 32]
grid $e -row $row -column 2 -sticky w -padx {4p 7p} -pady {7p 0}

#
# A ttk::separator widget
#
incr row
set sep [ttk::separator $cf.sep]
grid $sep -row $row -column 1 -columnspan 2 -sticky we -padx 7p -pady {7p 0}

#
# A mentry widget of type "Date"
#
incr row
set l [ttk::label $cf.l$row -text "Date of first release:"]
grid $l -row $row -column 1 -sticky w -padx {7p 0} -pady {7p 0}
set me [mentry::dateMentry $cf.me Ymd -]
grid $me -row $row -column 2 -sticky w -padx {4p 7p} -pady {7p 0}

incr row
grid rowconfigure $cf $row -weight 1

#
# A scrolled tablelist widget
#
incr row
set l [ttk::label $cf.l$row -text \
       "Tablelist release statistics, displayed in a tablelist widget:"]
grid $l -row $row -column 0 -columnspan 3 -sticky w -padx 7p -pady {7p 0}
incr row
set _sa [scrollutil::scrollarea $cf.sa$row]
set tbl [tablelist::tablelist $_sa.tbl \
	 -columns {0 "Release" left  0 "Changes" right  0 "Comment" left} \
	 -height 16 -width 0 -showseparators yes -stripebackground #f0f0f0 \
	 -incrarrowtype down -labelcommand tablelist::sortByColumn]
if {[$tbl cget -selectborderwidth] == 0} {
    $tbl configure -spacing 1
}
$tbl columnconfigure 0 -name release -sortmode dictionary
$tbl columnconfigure 1 -name changes -sortmode integer
$tbl columnconfigure 2 -name comment
$_sa setwidget $tbl
grid $_sa -row $row -column 0 -columnspan 3 -sticky w -padx 7p -pady {4p 0}

#
# On X11 configure the tablelist according to the display's
# DPI scaling level (redundant for Tablelist 6.10 and later)
#
if {[tk windowingsystem] eq "x11"} {
    array set arr {100 8x4  125 9x5  150 11x6  175 13x7  200 15x8}
    $tbl configure -arrowstyle flat$arr($scrollutil::scalingpct)
}

#
# A scrolled ttk::treeview widget
#
incr row
set l [ttk::label $cf.l$row -text \
       "Tablelist release statistics, displayed in a ttk::treeview widget:"]
grid $l -row $row -column 0 -columnspan 3 -sticky w -padx 7p -pady {7p 0}
incr row
set _sa [scrollutil::scrollarea $cf.sa$row -borderwidth 0]
set font [ttk::style lookup Treeview -font]
ttk::style configure Treeview -rowheight \
    [expr {[font metrics $font -linespace] + 3}]
set tv [ttk::treeview $_sa.tv -columns {release changes comment} \
	-show headings -height 16 -selectmode browse]
if {$ttk::currentTheme eq "aqua" &&
    [package vcompare $::tk_patchLevel "8.6.10"] >= 0} {
    $_sa configure -borderwidth 1 ;# because in this case $tv has a flat relief
}
$tv heading release -text " Release" -anchor w
$tv heading changes -text "Changes " -anchor e
$tv heading comment -text " Comment" -anchor w
$tv column release -anchor w
$tv column changes -anchor e
$tv column comment -anchor w
$_sa setwidget $tv
grid $_sa -row $row -column 0 -columnspan 3 -sticky w -padx 7p -pady {4p 7p}

grid columnconfigure $cf 2 -weight 1

#
# Populate the widgets
#

................................................................................
    $tv column $colId -width [$tbl columnwidth $colId -total]
}

#
# Set the ScrollableFrame's width, height, and yscrollincrement
#
update idletasks
set height [expr {[winfo reqheight $cf.l0] + [winfo pixels . 4p] + \
		  [winfo reqheight $cf.sa1] + 2*[winfo pixels . 7p]}]
$sf configure -width [winfo reqwidth $cf] -height $height \
    -yscrollincrement [expr {[winfo reqheight $lb] / 10}]

pack $sa -expand yes -fill both -padx 7p -pady 7p

#
# Create two ttk::button widgets within a frame outside the scrollarea
#
set bf [ttk::frame .bf]
set b1 [ttk::button $bf.b1 -text "Configure Tablelist Widget" \
        -command configTablelist]
set b2 [ttk::button $bf.b2 -text "Close" -command exit]
pack $b2 -side right -padx 7p -pady {0 7p}
pack $b1 -side left -padx 7p -pady {0 7p}

pack $bf -side bottom -fill x
pack $tf -side top -expand yes -fill both

#------------------------------------------------------------------------------

proc cancelEdit {w args} {
................................................................................
    foreach configSet [$tbl configure] {
	if {[llength $configSet] != 5} {
	    continue
	}

	set opt [lindex $configSet 0]
	set w [ttk::label $cf.l$row -text $opt]
	grid $w -row $row -column 0 -sticky w -padx {4p 0} -pady {4p 0}

	set w $cf.w$row
	switch -- $opt {
	    -activestyle -
	    -arrowstyle -
	    -incrarrowtype -
	    -labelrelief -
................................................................................
			winxpOlive winxpSilver yuyo}
		    }
		}

		$w configure -values $values
		$w set [$tbl cget $opt]
		bind $w <<ComboboxSelected>> [list applyValue %W $opt]
		grid $w -row $row -column 1 -sticky w -padx 4p -pady {4p 0}

		#
		# Adapt the handling of the mouse wheel
		# events for the ttk::combobox widget
		#
		scrollutil::adaptWheelEventHandling $w
	    }
................................................................................
	    -showlabels -
	    -showseparators -
	    -tight {
		ttk::checkbutton $w -command [list applyBoolean $w $opt]
		global $w
		set $w [$tbl cget $opt]
		$w configure -text [expr {[set $w] ? "true": "false"}]
		grid $w -row $row -column 1 -sticky w -padx 4p -pady {4p 0}
	    }

	    -borderwidth -
	    -height -
	    -highlightthickness -
	    -labelborderwidth -
	    -labelheight -
................................................................................
		$w set [$tbl cget $opt]
		$w configure -invalidcommand bell -validate key \
		    -validatecommand \
		    {expr {[string length %P] <= 3 && [regexp {^[0-9]*$} %S]}}
		foreach event {<Return> <KP_Enter> <FocusOut>} {
		    bind $w $event [list applyValue %W $opt]
		}
		grid $w -row $row -column 1 -sticky w -padx 4p -pady {4p 0}

		#
		# Adapt the handling of the mouse wheel
		# events for the ttk::spinbox widget
		#
		scrollutil::adaptWheelEventHandling $w
	    }
................................................................................

	    default {
		ttk::entry $w -width 20
		$w insert 0 [$tbl cget $opt]
		foreach event {<Return> <KP_Enter> <FocusOut>} {
		    bind $w $event [list applyValue %W $opt]
		}
		grid $w -row $row -column 1 -sticky we -padx 4p -pady {4p 0}
	    }
	}

	#
	# Make the keyboard navigation more user-friendly
	#
	bind $w <<TraverseIn>> [list $sf see %W]
................................................................................
    grid columnconfigure $cf 1   -weight 1

    #
    # Set the ScrollableFrame's width, height, and yscrollincrement
    #
    update idletasks
    set rowHeight [expr {[winfo reqheight $cf] / $row}]
    set height [expr {10*$rowHeight + [winfo pixels .top 4p]}]
    $sf configure -width [winfo reqwidth $cf] -height $height \
	-yscrollincrement $rowHeight

    #
    # Create a ttk::button widget outside the scrollarea
    #
    set b [ttk::button $f.b -text "Close" -command [list destroy $top]]

    pack $b  -side bottom -pady {0 7p}
    pack $sa -side top -expand yes -fill both -padx 7p -pady 7p
    pack $f  -expand yes -fill both
}

#------------------------------------------------------------------------------

proc applyValue {w opt} {
    global tbl

Changes to examples/scrollutil/BwScrollableFrmDemo1.tcl.

6
7
8
9
10
11
12

13
14
15
16
17
18
19
20
..
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
126
127
128
129
130
#
# Copyright (c) 2019-2020  Csaba Nemethi (E-mail: csaba.nemethi@t-online.de)
#==============================================================================

package require BWidget
Widget::theme yes
package require scrollutil_tile

source styleUtil.tcl

wm title . "European Capitals Quiz"

#
# Create a ScrollableFrame within a scrollarea
#
set f  [ttk::frame .f]
................................................................................
foreach country $countryList capital $capitalList {
    set capitalArr($country) $capital
}

set capitalList [lsort $capitalList]

if {[lsearch -exact {aqua vista xpnative} $ttk::currentTheme] >= 0} {
    set topPadY 2
} else {
    set topPadY 5
}
set padY [list $topPadY 0]

set row 0
foreach country $countryList {
    set w [ttk::label $cf.l$row -text $country]
    grid $w -row $row -column 0 -sticky w -padx {5 0} -pady $padY

    set w [ttk::combobox $cf.cb$row -state readonly -width 14 \
	   -values $capitalList]
    bind $w <<ComboboxSelected>> [list checkCapital %W $country]
    grid $w -row $row -column 1 -sticky w -padx {5 0} -pady $padY

    #
    # Make the keyboard navigation more user-friendly
    #
    bind $w <<TraverseIn>> [list $sf see %W]

    #
    # Adapt the handling of the mouse wheel events for the ttk::combobox widget
    #
    scrollutil::adaptWheelEventHandling $w

    set b [createToolbutton $cf.b$row -text "Resolve" \
	   -command [list setCapital $w $country]]
    grid $b -row $row -column 2 -sticky w -padx 5 -pady $padY

    #
    # Make the keyboard navigation more user-friendly
    #
    bind $b <<TraverseIn>> [list $sf see %W]

    incr row
................................................................................
}

#
# Set the ScrollableFrame's width, height, and yscrollincrement
#
update idletasks
set rowHeight [expr {[winfo reqheight $cf] / $row}]

$sf configure -width [winfo reqwidth $cf] \
    -height [expr {10*$rowHeight + $topPadY}] -yscrollincrement $rowHeight

#
# Create a ttk::button widget outside the scrollarea
#
set b [ttk::button $f.b -text "Close" -command exit]

pack $b  -side bottom -pady {0 10}
pack $sa -side top -expand yes -fill both -padx 10 -pady 10
pack $f  -expand yes -fill both

#------------------------------------------------------------------------------

proc checkCapital {w country} {
    $w selection clear
    global capitalArr







>
|







 







|

|






|




|













|







 







>
|
|






|
|







6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
..
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
126
127
128
129
130
131
132
#
# Copyright (c) 2019-2020  Csaba Nemethi (E-mail: csaba.nemethi@t-online.de)
#==============================================================================

package require BWidget
Widget::theme yes
package require scrollutil_tile
set dir [file dirname [info script]]
source [file join $dir styleUtil.tcl]

wm title . "European Capitals Quiz"

#
# Create a ScrollableFrame within a scrollarea
#
set f  [ttk::frame .f]
................................................................................
foreach country $countryList capital $capitalList {
    set capitalArr($country) $capital
}

set capitalList [lsort $capitalList]

if {[lsearch -exact {aqua vista xpnative} $ttk::currentTheme] >= 0} {
    set topPadY 1.5p
} else {
    set topPadY 4p
}
set padY [list $topPadY 0]

set row 0
foreach country $countryList {
    set w [ttk::label $cf.l$row -text $country]
    grid $w -row $row -column 0 -sticky w -padx {4p 0} -pady $padY

    set w [ttk::combobox $cf.cb$row -state readonly -width 14 \
	   -values $capitalList]
    bind $w <<ComboboxSelected>> [list checkCapital %W $country]
    grid $w -row $row -column 1 -sticky w -padx {4p 0} -pady $padY

    #
    # Make the keyboard navigation more user-friendly
    #
    bind $w <<TraverseIn>> [list $sf see %W]

    #
    # Adapt the handling of the mouse wheel events for the ttk::combobox widget
    #
    scrollutil::adaptWheelEventHandling $w

    set b [createToolbutton $cf.b$row -text "Resolve" \
	   -command [list setCapital $w $country]]
    grid $b -row $row -column 2 -sticky w -padx 4p -pady $padY

    #
    # Make the keyboard navigation more user-friendly
    #
    bind $b <<TraverseIn>> [list $sf see %W]

    incr row
................................................................................
}

#
# Set the ScrollableFrame's width, height, and yscrollincrement
#
update idletasks
set rowHeight [expr {[winfo reqheight $cf] / $row}]
set height [expr {10*$rowHeight + [winfo pixels . $topPadY]}]
$sf configure -width [winfo reqwidth $cf] -height $height \
    -yscrollincrement $rowHeight

#
# Create a ttk::button widget outside the scrollarea
#
set b [ttk::button $f.b -text "Close" -command exit]

pack $b  -side bottom -pady {0 7pt}
pack $sa -side top -expand yes -fill both -padx 7pt -pady 7pt
pack $f  -expand yes -fill both

#------------------------------------------------------------------------------

proc checkCapital {w country} {
    $w selection clear
    global capitalArr

Changes to examples/scrollutil/BwScrollableFrmDemo2.tcl.

10
11
12
13
14
15
16

17
18
19
20
21
22
23
24
..
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
package require Tk 8.5.9			;# for ttk::spinbox
package require BWidget
Widget::theme yes
package require mentry_tile 3.2			;# for mouse wheel support
package require tablelist_tile 6.5		;# for -(x|y)mousewheelwindow
						;# and scrollutil::scrollarea
package require scrollutil_tile

source styleUtil.tcl

wm title . "Scrollutil Demo"

#
# Create a ScrollableFrame within a scrollarea
#
set tf [ttk::frame .tf]
................................................................................
    $sf:cmd configure -background #ececec
}

#
# Get the content frame and populate it
#
set cf [$sf getframe]
source BwScrollableFrmContent.tcl

#
# Make the keyboard navigation more user-friendly
#
foreach w [list $cb $sb $e $me] {
    bind $w <<TraverseIn>> [list $sf see %W]
}







>
|







 







|







10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
..
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package require Tk 8.5.9			;# for ttk::spinbox
package require BWidget
Widget::theme yes
package require mentry_tile 3.2			;# for mouse wheel support
package require tablelist_tile 6.5		;# for -(x|y)mousewheelwindow
						;# and scrollutil::scrollarea
package require scrollutil_tile
set dir [file dirname [info script]]
source [file join $dir styleUtil.tcl]

wm title . "Scrollutil Demo"

#
# Create a ScrollableFrame within a scrollarea
#
set tf [ttk::frame .tf]
................................................................................
    $sf:cmd configure -background #ececec
}

#
# Get the content frame and populate it
#
set cf [$sf getframe]
source [file join $dir BwScrollableFrmContent.tcl]

#
# Make the keyboard navigation more user-friendly
#
foreach w [list $cb $sb $e $me] {
    bind $w <<TraverseIn>> [list $sf see %W]
}

Changes to examples/scrollutil/ScrolledFrmContent.tcl.

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



126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
...
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242

243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
...
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
...
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
...
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
...
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
...
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
...
456
457
458
459
460
461
462

463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479

#
# A scrolled text widget with old-school mouse wheel support
#
set row 0
set l [ttk::label $cf.l$row -text \
       "Contents of the Tablelist distribution file \"CHANGES.txt\":"]
grid $l -row $row -column 0 -columnspan 3 -sticky w -padx 10 -pady {10 0}
incr row
set sa [scrollutil::scrollarea $cf.sa$row]
set txt [text $sa.txt -font TkFixedFont -width 73]
scrollutil::addMouseWheelSupport $txt
$sa setwidget $txt
grid $sa -row $row -column 0 -columnspan 3 -sticky w -padx 10 -pady {5 0}

#
# A scrolled listbox widget
#
incr row
set l [ttk::label $cf.l$row -text "Tablelist releases:"]
grid $l -row $row -column 0 -sticky w -padx {10 0} -pady {10 0}
incr row
set sa [scrollutil::scrollarea $cf.sa$row]
set lb [listbox $sa.lb -width 0]
$sa setwidget $lb
grid $sa -row $row -rowspan 6 -column 0 -sticky w -padx {10 0} -pady {5 0}

#
# A ttk::combobox widget
#
set l [ttk::label $cf.l$row -text "Release:"]
grid $l -row $row -column 1 -sticky w -padx {10 0} -pady {5 0}
set cb [ttk::combobox $cf.cb -state readonly -width 14]
grid $cb -row $row -column 2 -sticky w -padx {5 10} -pady {5 0}

#
# A ttk::spinbox widget
#
incr row
set l [ttk::label $cf.l$row -text "Changes:"]
grid $l -row $row -column 1 -sticky w -padx {10 0} -pady {10 0}
set sb [ttk::spinbox $cf.sb -from 0 -to 20 -state readonly -width 4]
grid $sb -row $row -column 2 -sticky w -padx {5 10} -pady {10 0}

#
# A ttk::entry widget
#
incr row
set l [ttk::label $cf.l$row -text "Comment:"]
grid $l -row $row -column 1 -sticky w -padx {10 0} -pady {10 0}
set e [ttk::entry $cf.e -width 32]
grid $e -row $row -column 2 -sticky w -padx {5 10} -pady {10 0}

#
# A ttk::separator widget
#
incr row
set sep [ttk::separator $cf.sep]
grid $sep -row $row -column 1 -columnspan 2 -sticky we -padx 10 -pady {10 0}

#
# A mentry widget of type "Date"
#
incr row
set l [ttk::label $cf.l$row -text "Date of first release:"]
grid $l -row $row -column 1 -sticky w -padx {10 0} -pady {10 0}
set me [mentry::dateMentry $cf.me Ymd -]
grid $me -row $row -column 2 -sticky w -padx {5 10} -pady {10 0}

incr row
grid rowconfigure $cf $row -weight 1

#
# A scrolled tablelist widget
#
incr row
set l [ttk::label $cf.l$row -text \
       "Tablelist release statistics, displayed in a tablelist widget:"]
grid $l -row $row -column 0 -columnspan 3 -sticky w -padx 10 -pady {10 0}
incr row
set sa [scrollutil::scrollarea $cf.sa$row]
set tbl [tablelist::tablelist $sa.tbl \
	 -columns {0 "Release" left  0 "Changes" right  0 "Comment" left} \
	 -height 16 -width 0 -showseparators yes -stripebackground #f0f0f0 \
	 -incrarrowtype down -labelcommand tablelist::sortByColumn]
if {[$tbl cget -selectborderwidth] == 0} {
    $tbl configure -spacing 1
}
$tbl columnconfigure 0 -name release -sortmode dictionary
$tbl columnconfigure 1 -name changes -sortmode integer
$tbl columnconfigure 2 -name comment
$sa setwidget $tbl
grid $sa -row $row -column 0 -columnspan 3 -sticky w -padx 10 -pady {5 0}










#
# A scrolled ttk::treeview widget
#
incr row
set l [ttk::label $cf.l$row -text \
       "Tablelist release statistics, displayed in a ttk::treeview widget:"]
grid $l -row $row -column 0 -columnspan 3 -sticky w -padx 10 -pady {10 0}
incr row
set sa [scrollutil::scrollarea $cf.sa$row -borderwidth 0]



set tv [ttk::treeview $sa.tv -columns {release changes comment} \
	-show headings -height 16 -selectmode browse]
if {$ttk::currentTheme eq "aqua" &&
    [package vcompare $::tk_patchLevel "8.6.10"] >= 0} {
    $sa configure -borderwidth 1  ;# because in this case $tv has a flat relief
}
$tv heading release -text " Release" -anchor w
$tv heading changes -text "Changes " -anchor e
$tv heading comment -text " Comment" -anchor w
$tv column release -anchor w
$tv column changes -anchor e
$tv column comment -anchor w
$sa setwidget $tv
grid $sa -row $row -column 0 -columnspan 3 -sticky w -padx 10 -pady {5 10}

grid columnconfigure $cf 2 -weight 1

#
# Populate the widgets
#

................................................................................
#
# Make the columns of the treeview as wide as those of the tablelist
#
foreach colId [$tv cget -columns] {
    $tv column $colId -width [$tbl columnwidth $colId -total]
}

pack $sf -expand yes -fill both -padx 10 -pady 10

#
# Set the scrolledframe's width, height, and yscrollincrement
#
update idletasks
set vsb [$sf component vertsb]
set width  [expr {[winfo reqwidth $cf] + [winfo reqwidth $vsb] + 2}]
set height [expr {[winfo reqheight $cf.l0] + [winfo reqheight $cf.sa1] + 27}]

$sf configure -width $width -height $height
$canvas configure -yscrollincrement [expr {[winfo reqheight $lb] / 10}]
after 200 [list $sf configure -hscrollmode dynamic]

#
# Create two ttk::button widgets within a frame outside the scrolledframe
#
set bf [ttk::frame .bf]
set b1 [ttk::button $bf.b1 -text "Configure Tablelist Widget" \
        -command configTablelist]
set b2 [ttk::button $bf.b2 -text "Close" -command exit]
pack $b2 -side right -padx 10 -pady {0 10}
pack $b1 -side left -padx 10 -pady {0 10}

pack $bf -side bottom -fill x
pack $tf -side top -expand yes -fill both

#------------------------------------------------------------------------------

proc cancelEdit {w args} {
................................................................................
    foreach configSet [$tbl configure] {
	if {[llength $configSet] != 5} {
	    continue
	}

	set opt [lindex $configSet 0]
	set w [ttk::label $cf.l$row -text $opt]
	grid $w -row $row -column 0 -sticky w -padx {5 0} -pady {5 0}

	set w $cf.w$row
	switch -- $opt {
	    -activestyle -
	    -arrowstyle -
	    -incrarrowtype -
	    -labelrelief -
................................................................................
			winxpOlive winxpSilver yuyo}
		    }
		}

		$w configure -values $values
		$w set [$tbl cget $opt]
		bind $w <<ComboboxSelected>> [list applyValue %W $opt]
		grid $w -row $row -column 1 -sticky w -padx 5 -pady {5 0}

		#
		# Adapt the handling of the mouse wheel
		# events for the ttk::combobox widget
		#
		scrollutil::adaptWheelEventHandling $w
	    }
................................................................................
	    -showlabels -
	    -showseparators -
	    -tight {
		ttk::checkbutton $w -command [list applyBoolean $w $opt]
		global $w
		set $w [$tbl cget $opt]
		$w configure -text [expr {[set $w] ? "true": "false"}]
		grid $w -row $row -column 1 -sticky w -padx 5 -pady {5 0}
	    }

	    -borderwidth -
	    -height -
	    -highlightthickness -
	    -labelborderwidth -
	    -labelheight -
................................................................................
		$w set [$tbl cget $opt]
		$w configure -invalidcommand bell -validate key \
		    -validatecommand \
		    {expr {[string length %P] <= 3 && [regexp {^[0-9]*$} %S]}}
		foreach event {<Return> <KP_Enter> <FocusOut>} {
		    bind $w $event [list applyValue %W $opt]
		}
		grid $w -row $row -column 1 -sticky w -padx 5 -pady {5 0}

		#
		# Adapt the handling of the mouse wheel
		# events for the ttk::spinbox widget
		#
		scrollutil::adaptWheelEventHandling $w
	    }
................................................................................

	    default {
		ttk::entry $w -width 20
		$w insert 0 [$tbl cget $opt]
		foreach event {<Return> <KP_Enter> <FocusOut>} {
		    bind $w $event [list applyValue %W $opt]
		}
		grid $w -row $row -column 1 -sticky we -padx 5 -pady {5 0}
	    }
	}

	incr row
    }

    grid rowconfigure    $cf all -uniform AllRows
................................................................................
    #
    # Set the scrolledframe's width, height, and yscrollincrement
    #
    update idletasks
    set vsb [$sf component vertsb]
    set width [expr {[winfo reqwidth $cf] + [winfo reqwidth $vsb] + 2}]
    set rowHeight [expr {[winfo reqheight $cf] / $row}]

    $sf configure -width $width -height [expr {10*$rowHeight + 7}]
    $canvas configure -yscrollincrement $rowHeight

    #
    # Create a ttk::button widget outside the scrolledframe
    #
    set b [ttk::button $f.b -text "Close" -command [list destroy $top]]

    pack $b  -side bottom -pady {0 10}
    pack $sf -side top -expand yes -fill both -padx 10 -pady 10
    pack $f  -expand yes -fill both
}

#------------------------------------------------------------------------------

proc applyValue {w opt} {
    global tbl







|





|






|




|





|

|






|

|






|

|






|






|

|










|













|
>
>
>
>
>
>
>
>
>







|


>
>
>













|







 







|







|
>











|
|







 







|







 







|







 







|







 







|







 







|







 







>
|







|
|







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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
...
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
...
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
...
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
...
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
...
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
...
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
...
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493

#
# A scrolled text widget with old-school mouse wheel support
#
set row 0
set l [ttk::label $cf.l$row -text \
       "Contents of the Tablelist distribution file \"CHANGES.txt\":"]
grid $l -row $row -column 0 -columnspan 3 -sticky w -padx 7p -pady {7p 0}
incr row
set sa [scrollutil::scrollarea $cf.sa$row]
set txt [text $sa.txt -font TkFixedFont -width 73]
scrollutil::addMouseWheelSupport $txt
$sa setwidget $txt
grid $sa -row $row -column 0 -columnspan 3 -sticky w -padx 7p -pady {4p 0}

#
# A scrolled listbox widget
#
incr row
set l [ttk::label $cf.l$row -text "Tablelist releases:"]
grid $l -row $row -column 0 -sticky w -padx {7p 0} -pady {7p 0}
incr row
set sa [scrollutil::scrollarea $cf.sa$row]
set lb [listbox $sa.lb -width 0]
$sa setwidget $lb
grid $sa -row $row -rowspan 6 -column 0 -sticky w -padx {7p 0} -pady {4p 0}

#
# A ttk::combobox widget
#
set l [ttk::label $cf.l$row -text "Release:"]
grid $l -row $row -column 1 -sticky w -padx {7p 0} -pady {4p 0}
set cb [ttk::combobox $cf.cb -state readonly -width 14]
grid $cb -row $row -column 2 -sticky w -padx {4p 7p} -pady {4p 0}

#
# A ttk::spinbox widget
#
incr row
set l [ttk::label $cf.l$row -text "Changes:"]
grid $l -row $row -column 1 -sticky w -padx {7p 0} -pady {7p 0}
set sb [ttk::spinbox $cf.sb -from 0 -to 20 -state readonly -width 4]
grid $sb -row $row -column 2 -sticky w -padx {4p 7p} -pady {7p 0}

#
# A ttk::entry widget
#
incr row
set l [ttk::label $cf.l$row -text "Comment:"]
grid $l -row $row -column 1 -sticky w -padx {7p 0} -pady {7p 0}
set e [ttk::entry $cf.e -width 32]
grid $e -row $row -column 2 -sticky w -padx {4p 7p} -pady {7p 0}

#
# A ttk::separator widget
#
incr row
set sep [ttk::separator $cf.sep]
grid $sep -row $row -column 1 -columnspan 2 -sticky we -padx 7p -pady {7p 0}

#
# A mentry widget of type "Date"
#
incr row
set l [ttk::label $cf.l$row -text "Date of first release:"]
grid $l -row $row -column 1 -sticky w -padx {7p 0} -pady {7p 0}
set me [mentry::dateMentry $cf.me Ymd -]
grid $me -row $row -column 2 -sticky w -padx {4p 7p} -pady {7p 0}

incr row
grid rowconfigure $cf $row -weight 1

#
# A scrolled tablelist widget
#
incr row
set l [ttk::label $cf.l$row -text \
       "Tablelist release statistics, displayed in a tablelist widget:"]
grid $l -row $row -column 0 -columnspan 3 -sticky w -padx 7p -pady {7p 0}
incr row
set sa [scrollutil::scrollarea $cf.sa$row]
set tbl [tablelist::tablelist $sa.tbl \
	 -columns {0 "Release" left  0 "Changes" right  0 "Comment" left} \
	 -height 16 -width 0 -showseparators yes -stripebackground #f0f0f0 \
	 -incrarrowtype down -labelcommand tablelist::sortByColumn]
if {[$tbl cget -selectborderwidth] == 0} {
    $tbl configure -spacing 1
}
$tbl columnconfigure 0 -name release -sortmode dictionary
$tbl columnconfigure 1 -name changes -sortmode integer
$tbl columnconfigure 2 -name comment
$sa setwidget $tbl
grid $sa -row $row -column 0 -columnspan 3 -sticky w -padx 7p -pady {4p 0}

#
# On X11 configure the tablelist according to the display's
# DPI scaling level (redundant for Tablelist 6.10 and later)
#
if {[tk windowingsystem] eq "x11"} {
    array set arr {100 8x4  125 9x5  150 11x6  175 13x7  200 15x8}
    $tbl configure -arrowstyle flat$arr($scrollutil::scalingpct)
}

#
# A scrolled ttk::treeview widget
#
incr row
set l [ttk::label $cf.l$row -text \
       "Tablelist release statistics, displayed in a ttk::treeview widget:"]
grid $l -row $row -column 0 -columnspan 3 -sticky w -padx 7p -pady {7p 0}
incr row
set sa [scrollutil::scrollarea $cf.sa$row -borderwidth 0]
set font [ttk::style lookup Treeview -font]
ttk::style configure Treeview -rowheight \
    [expr {[font metrics $font -linespace] + 3}]
set tv [ttk::treeview $sa.tv -columns {release changes comment} \
	-show headings -height 16 -selectmode browse]
if {$ttk::currentTheme eq "aqua" &&
    [package vcompare $::tk_patchLevel "8.6.10"] >= 0} {
    $sa configure -borderwidth 1  ;# because in this case $tv has a flat relief
}
$tv heading release -text " Release" -anchor w
$tv heading changes -text "Changes " -anchor e
$tv heading comment -text " Comment" -anchor w
$tv column release -anchor w
$tv column changes -anchor e
$tv column comment -anchor w
$sa setwidget $tv
grid $sa -row $row -column 0 -columnspan 3 -sticky w -padx 7p -pady {4p 7p}

grid columnconfigure $cf 2 -weight 1

#
# Populate the widgets
#

................................................................................
#
# Make the columns of the treeview as wide as those of the tablelist
#
foreach colId [$tv cget -columns] {
    $tv column $colId -width [$tbl columnwidth $colId -total]
}

pack $sf -expand yes -fill both -padx 7p -pady 7p

#
# Set the scrolledframe's width, height, and yscrollincrement
#
update idletasks
set vsb [$sf component vertsb]
set width  [expr {[winfo reqwidth $cf] + [winfo reqwidth $vsb] + 2}]
set height [expr {[winfo reqheight $cf.l0] + [winfo pixels . 4p] + \
		  [winfo reqheight $cf.sa1] + 2*[winfo pixels . 7p] + 2}]
$sf configure -width $width -height $height
$canvas configure -yscrollincrement [expr {[winfo reqheight $lb] / 10}]
after 200 [list $sf configure -hscrollmode dynamic]

#
# Create two ttk::button widgets within a frame outside the scrolledframe
#
set bf [ttk::frame .bf]
set b1 [ttk::button $bf.b1 -text "Configure Tablelist Widget" \
        -command configTablelist]
set b2 [ttk::button $bf.b2 -text "Close" -command exit]
pack $b2 -side right -padx 7p -pady {0 7p}
pack $b1 -side left -padx 7p -pady {0 7p}

pack $bf -side bottom -fill x
pack $tf -side top -expand yes -fill both

#------------------------------------------------------------------------------

proc cancelEdit {w args} {
................................................................................
    foreach configSet [$tbl configure] {
	if {[llength $configSet] != 5} {
	    continue
	}

	set opt [lindex $configSet 0]
	set w [ttk::label $cf.l$row -text $opt]
	grid $w -row $row -column 0 -sticky w -padx {4p 0} -pady {4p 0}

	set w $cf.w$row
	switch -- $opt {
	    -activestyle -
	    -arrowstyle -
	    -incrarrowtype -
	    -labelrelief -
................................................................................
			winxpOlive winxpSilver yuyo}
		    }
		}

		$w configure -values $values
		$w set [$tbl cget $opt]
		bind $w <<ComboboxSelected>> [list applyValue %W $opt]
		grid $w -row $row -column 1 -sticky w -padx 4p -pady {4p 0}

		#
		# Adapt the handling of the mouse wheel
		# events for the ttk::combobox widget
		#
		scrollutil::adaptWheelEventHandling $w
	    }
................................................................................
	    -showlabels -
	    -showseparators -
	    -tight {
		ttk::checkbutton $w -command [list applyBoolean $w $opt]
		global $w
		set $w [$tbl cget $opt]
		$w configure -text [expr {[set $w] ? "true": "false"}]
		grid $w -row $row -column 1 -sticky w -padx 4p -pady {4p 0}
	    }

	    -borderwidth -
	    -height -
	    -highlightthickness -
	    -labelborderwidth -
	    -labelheight -
................................................................................
		$w set [$tbl cget $opt]
		$w configure -invalidcommand bell -validate key \
		    -validatecommand \
		    {expr {[string length %P] <= 3 && [regexp {^[0-9]*$} %S]}}
		foreach event {<Return> <KP_Enter> <FocusOut>} {
		    bind $w $event [list applyValue %W $opt]
		}
		grid $w -row $row -column 1 -sticky w -padx 4p -pady {4p 0}

		#
		# Adapt the handling of the mouse wheel
		# events for the ttk::spinbox widget
		#
		scrollutil::adaptWheelEventHandling $w
	    }
................................................................................

	    default {
		ttk::entry $w -width 20
		$w insert 0 [$tbl cget $opt]
		foreach event {<Return> <KP_Enter> <FocusOut>} {
		    bind $w $event [list applyValue %W $opt]
		}
		grid $w -row $row -column 1 -sticky we -padx 4p -pady {4p 0}
	    }
	}

	incr row
    }

    grid rowconfigure    $cf all -uniform AllRows
................................................................................
    #
    # Set the scrolledframe's width, height, and yscrollincrement
    #
    update idletasks
    set vsb [$sf component vertsb]
    set width [expr {[winfo reqwidth $cf] + [winfo reqwidth $vsb] + 2}]
    set rowHeight [expr {[winfo reqheight $cf] / $row}]
    set height [expr {10*$rowHeight + [winfo pixels .top 4p] + 2}]
    $sf configure -width $width -height $height
    $canvas configure -yscrollincrement $rowHeight

    #
    # Create a ttk::button widget outside the scrolledframe
    #
    set b [ttk::button $f.b -text "Close" -command [list destroy $top]]

    pack $b  -side bottom -pady {0 7p}
    pack $sf -side top -expand yes -fill both -padx 7p -pady 7p
    pack $f  -expand yes -fill both
}

#------------------------------------------------------------------------------

proc applyValue {w opt} {
    global tbl

Changes to examples/scrollutil/ScrolledFrmDemo1.tcl.

7
8
9
10
11
12
13

14
15
16
17
18
19
20
21
22
23
..
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
# Copyright (c) 2019-2020  Csaba Nemethi (E-mail: csaba.nemethi@t-online.de)
#==============================================================================

if {[catch {package require iwidgets} result1] != 0 &&
    [catch {package require Iwidgets} result2] != 0} {
    error "$result1; $result2"
}

source scrolledwidgetPatch.itk			;# adds ttk::scrollbar widgets
package require scrollutil_tile
source styleUtil.tcl

wm title . "European Capitals Quiz"

set bg [ttk::style lookup TFrame -background]
if {$ttk::currentTheme eq "aqua" &&
    [package vcompare $tk_patchLevel "8.6.10"] < 0} {
    set bg #ececec				;# workaround for a tile bug
................................................................................
foreach country $countryList capital $capitalList {
    set capitalArr($country) $capital
}

set capitalList [lsort $capitalList]

if {[lsearch -exact {aqua vista xpnative} $ttk::currentTheme] >= 0} {
    set topPadY 2
} else {
    set topPadY 5
}
set padY [list $topPadY 0]

set row 0
foreach country $countryList {
    set w [ttk::label $cf.l$row -text $country]
    grid $w -row $row -column 0 -sticky w -padx {5 0} -pady $padY

    set w [ttk::combobox $cf.cb$row -state readonly -width 14 \
	   -values $capitalList]
    bind $w <<ComboboxSelected>> [list checkCapital %W $country]
    grid $w -row $row -column 1 -sticky w -padx {5 0} -pady $padY

    #
    # Adapt the handling of the mouse wheel events for the ttk::combobox widget
    #
    scrollutil::adaptWheelEventHandling $w

    set b [createToolbutton $cf.b$row -text "Resolve" \
	   -command [list setCapital $w $country]]
    grid $b -row $row -column 2 -sticky w -padx 5 -pady $padY

    incr row
}

#
# Set the scrolledframe's width, height, and yscrollincrement
#
update idletasks
set vsb [$sf component vertsb]
set width [expr {[winfo reqwidth $cf] + [winfo reqwidth $vsb] + 2}]
set rowHeight [expr {[winfo reqheight $cf] / $row}]

$sf configure -width $width -height [expr {10*$rowHeight + $topPadY + 2}]
$canvas configure -yscrollincrement $rowHeight
after 100 [list $sf configure -hscrollmode dynamic]

#
# Create a ttk::button widget outside the scrolledframe
#
set b [ttk::button $f.b -text "Close" -command exit]

pack $b  -side bottom -pady {0 10}
pack $sf -side top -expand yes -fill both -padx 10 -pady 10
pack $f  -expand yes -fill both

#------------------------------------------------------------------------------

proc checkCapital {w country} {
    $w selection clear
    global capitalArr







>
|

|







 







|

|






|




|








|











>
|








|
|







7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
..
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
126
127
# Copyright (c) 2019-2020  Csaba Nemethi (E-mail: csaba.nemethi@t-online.de)
#==============================================================================

if {[catch {package require iwidgets} result1] != 0 &&
    [catch {package require Iwidgets} result2] != 0} {
    error "$result1; $result2"
}
set dir [file dirname [info script]]
source [file join $dir scrolledwidgetPatch.itk]	;# adds ttk::scrollbar widgets
package require scrollutil_tile
source [file join $dir styleUtil.tcl]

wm title . "European Capitals Quiz"

set bg [ttk::style lookup TFrame -background]
if {$ttk::currentTheme eq "aqua" &&
    [package vcompare $tk_patchLevel "8.6.10"] < 0} {
    set bg #ececec				;# workaround for a tile bug
................................................................................
foreach country $countryList capital $capitalList {
    set capitalArr($country) $capital
}

set capitalList [lsort $capitalList]

if {[lsearch -exact {aqua vista xpnative} $ttk::currentTheme] >= 0} {
    set topPadY 1.5p
} else {
    set topPadY 4p
}
set padY [list $topPadY 0]

set row 0
foreach country $countryList {
    set w [ttk::label $cf.l$row -text $country]
    grid $w -row $row -column 0 -sticky w -padx {4p 0} -pady $padY

    set w [ttk::combobox $cf.cb$row -state readonly -width 14 \
	   -values $capitalList]
    bind $w <<ComboboxSelected>> [list checkCapital %W $country]
    grid $w -row $row -column 1 -sticky w -padx {4p 0} -pady $padY

    #
    # Adapt the handling of the mouse wheel events for the ttk::combobox widget
    #
    scrollutil::adaptWheelEventHandling $w

    set b [createToolbutton $cf.b$row -text "Resolve" \
	   -command [list setCapital $w $country]]
    grid $b -row $row -column 2 -sticky w -padx 4p -pady $padY

    incr row
}

#
# Set the scrolledframe's width, height, and yscrollincrement
#
update idletasks
set vsb [$sf component vertsb]
set width [expr {[winfo reqwidth $cf] + [winfo reqwidth $vsb] + 2}]
set rowHeight [expr {[winfo reqheight $cf] / $row}]
set height [expr {10*$rowHeight + [winfo pixels . $topPadY] + 2}]
$sf configure -width $width -height $height
$canvas configure -yscrollincrement $rowHeight
after 100 [list $sf configure -hscrollmode dynamic]

#
# Create a ttk::button widget outside the scrolledframe
#
set b [ttk::button $f.b -text "Close" -command exit]

pack $b  -side bottom -pady {0 7p}
pack $sf -side top -expand yes -fill both -padx 7p -pady 7p
pack $f  -expand yes -fill both

#------------------------------------------------------------------------------

proc checkCapital {w country} {
    $w selection clear
    global capitalArr

Changes to examples/scrollutil/ScrolledFrmDemo2.tcl.

8
9
10
11
12
13
14

15
16
17
18
19
20
21
22
23
24
25
26
27
..
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#==============================================================================

package require Tk 8.5.9			;# for ttk::spinbox
if {[catch {package require iwidgets} result1] != 0 &&
    [catch {package require Iwidgets} result2] != 0} {
    error "$result1; $result2"
}

source scrolledwidgetPatch.itk			;# adds ttk::scrollbar widgets
package require mentry_tile 3.2			;# for mouse wheel support
package require tablelist_tile 6.5		;# for -(x|y)mousewheelwindow
						;# and scrollutil::scrollarea
package require scrollutil_tile
source styleUtil.tcl

wm title . "Scrollutil Demo"

set bg [ttk::style lookup TFrame -background]
if {$ttk::currentTheme eq "aqua" &&
    [package vcompare $tk_patchLevel "8.6.10"] < 0} {
    set bg #ececec				;# workaround for a tile bug
................................................................................
$canvas configure -background $bg

#
# Get the content frame and populate it
#
set cf [$sf childsite]
$cf configure -background $bg
source ScrolledFrmContent.tcl

#
# Additional stuff related to the mouse wheel events:
#

#
# Create mouse wheel event bindings for the binding tag "all"







>
|




|







 







|







8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
..
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#==============================================================================

package require Tk 8.5.9			;# for ttk::spinbox
if {[catch {package require iwidgets} result1] != 0 &&
    [catch {package require Iwidgets} result2] != 0} {
    error "$result1; $result2"
}
set dir [file dirname [info script]]
source [file join $dir scrolledwidgetPatch.itk]	;# adds ttk::scrollbar widgets
package require mentry_tile 3.2			;# for mouse wheel support
package require tablelist_tile 6.5		;# for -(x|y)mousewheelwindow
						;# and scrollutil::scrollarea
package require scrollutil_tile
source [file join $dir styleUtil.tcl]

wm title . "Scrollutil Demo"

set bg [ttk::style lookup TFrame -background]
if {$ttk::currentTheme eq "aqua" &&
    [package vcompare $tk_patchLevel "8.6.10"] < 0} {
    set bg #ececec				;# workaround for a tile bug
................................................................................
$canvas configure -background $bg

#
# Get the content frame and populate it
#
set cf [$sf childsite]
$cf configure -background $bg
source [file join $dir ScrolledFrmContent.tcl]

#
# Additional stuff related to the mouse wheel events:
#

#
# Create mouse wheel event bindings for the binding tag "all"

Changes to examples/scrollutil/ScrolledTablelist1.tcl.

5
6
7
8
9
10
11

12
13
14
15
16
17
18
19
..
78
79
80
81
82
83
84
85
86
# tablelist widget.
#
# Copyright (c) 2019-2020  Csaba Nemethi (E-mail: csaba.nemethi@t-online.de)
#==============================================================================

package require Tk 8.5
package require tablelist_tile 6.3

source styleUtil.tcl

wm title . "Scrolled Tablelist"

#
# Create the tablelist and the scrollbars as children
# of a frame having -borderwidth 1 and -relief sunken
#
................................................................................
#
set b [ttk::button $f.b -text "Close" -command exit]
pack $b -side bottom -pady {0 10}

#
# Manage the frame
#
pack $frm -expand yes -fill both -padx 10 -pady 10
pack $f   -expand yes -fill both







>
|







 







|

5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
..
79
80
81
82
83
84
85
86
87
# tablelist widget.
#
# Copyright (c) 2019-2020  Csaba Nemethi (E-mail: csaba.nemethi@t-online.de)
#==============================================================================

package require Tk 8.5
package require tablelist_tile 6.3
set dir [file dirname [info script]]
source [file join $dir styleUtil.tcl]

wm title . "Scrolled Tablelist"

#
# Create the tablelist and the scrollbars as children
# of a frame having -borderwidth 1 and -relief sunken
#
................................................................................
#
set b [ttk::button $f.b -text "Close" -command exit]
pack $b -side bottom -pady {0 10}

#
# Manage the frame
#
pack $frm -expand yes -fill both -padx 7p -pady 7p
pack $f   -expand yes -fill both

Changes to examples/scrollutil/ScrolledTablelist2.tcl.

6
7
8
9
10
11
12

13
14
15
16
17
18
19
20
#
# Copyright (c) 2019-2020  Csaba Nemethi (E-mail: csaba.nemethi@t-online.de)
#==============================================================================

package require Tk 8.5
package require tablelist_tile 6.5
package require scrollutil_tile

source styleUtil.tcl

wm title . "Scrolled Tablelist"

#
# Create the tablelist within a scrollarea
#
set f  [ttk::frame .f]







>
|







6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#
# Copyright (c) 2019-2020  Csaba Nemethi (E-mail: csaba.nemethi@t-online.de)
#==============================================================================

package require Tk 8.5
package require tablelist_tile 6.5
package require scrollutil_tile
set dir [file dirname [info script]]
source [file join $dir styleUtil.tcl]

wm title . "Scrolled Tablelist"

#
# Create the tablelist within a scrollarea
#
set f  [ttk::frame .f]

Changes to examples/scrollutil/ScrolledText.tcl.

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
..
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# Demonstrates the use of the scrollutil::scrollarea widget in connection with
# a text widget.
#
# Copyright (c) 2020  Csaba Nemethi (E-mail: csaba.nemethi@t-online.de)
#==============================================================================

package require scrollutil_tile

source styleUtil.tcl

wm title . "Scrolled Text"

#
# Create a text widget within a scrollarea
#
set f  [ttk::frame .f]
set sa [scrollutil::scrollarea $f.sa -lockinterval 10]
set txt [text $sa.txt -font TkFixedFont -width 49 -height 12 \
	 -spacing1 2 -spacing3 2 -wrap none]
$sa setwidget $txt

#
# Populate the text widget and set the background color of line #25 to red
#
for {set i 1} {$i <= 30} {incr i} {
    set j [expr {2*$i}]
................................................................................
$txt tag configure bgRed -background red
$txt tag add bgRed 25.0 25.end

#
# Create a ttk::button widget outside the scrollarea
#
set b [ttk::button $f.b -text "Close" -command exit]
pack $b -side bottom -pady {0 10}

#
# Manage the scrollarea
#
pack $sa -expand yes -fill both -padx 10 -pady 10
pack $f  -expand yes -fill both

#
# Adjust the vertical view in the text window
# so that line #25 becomes the bottom line
#
tkwait visibility $txt
after 100 [list $txt yview 14.0]







>
|









|







 







|




|








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
..
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# Demonstrates the use of the scrollutil::scrollarea widget in connection with
# a text widget.
#
# Copyright (c) 2020  Csaba Nemethi (E-mail: csaba.nemethi@t-online.de)
#==============================================================================

package require scrollutil_tile
set dir [file dirname [info script]]
source [file join $dir styleUtil.tcl]

wm title . "Scrolled Text"

#
# Create a text widget within a scrollarea
#
set f  [ttk::frame .f]
set sa [scrollutil::scrollarea $f.sa -lockinterval 10]
set txt [text $sa.txt -font TkFixedFont -width 49 -height 12 \
	 -spacing1 1.5p -spacing3 1.5p -wrap none]
$sa setwidget $txt

#
# Populate the text widget and set the background color of line #25 to red
#
for {set i 1} {$i <= 30} {incr i} {
    set j [expr {2*$i}]
................................................................................
$txt tag configure bgRed -background red
$txt tag add bgRed 25.0 25.end

#
# Create a ttk::button widget outside the scrollarea
#
set b [ttk::button $f.b -text "Close" -command exit]
pack $b -side bottom -pady {0 7p}

#
# Manage the scrollarea
#
pack $sa -expand yes -fill both -padx 7p -pady 7p
pack $f  -expand yes -fill both

#
# Adjust the vertical view in the text window
# so that line #25 becomes the bottom line
#
tkwait visibility $txt
after 100 [list $txt yview 14.0]

Changes to examples/scrollutil/SuScrollableFrmContent.tcl.

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



126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
...
231
232
233
234
235
236
237
238

239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
...
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
...
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
...
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
...
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
...
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
...
446
447
448
449
450
451
452

453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469

#
# A scrolled text widget with old-school mouse wheel support
#
set row 0
set l [ttk::label $cf.l$row -text \
       "Contents of the Tablelist distribution file \"CHANGES.txt\":"]
grid $l -row $row -column 0 -columnspan 3 -sticky w -padx 10 -pady {10 0}
incr row
set _sa [scrollutil::scrollarea $cf.sa$row]
set txt [text $_sa.txt -font TkFixedFont -width 73]
scrollutil::addMouseWheelSupport $txt
$_sa setwidget $txt
grid $_sa -row $row -column 0 -columnspan 3 -sticky w -padx 10 -pady {5 0}

#
# A scrolled listbox widget
#
incr row
set l [ttk::label $cf.l$row -text "Tablelist releases:"]
grid $l -row $row -column 0 -sticky w -padx {10 0} -pady {10 0}
incr row
set _sa [scrollutil::scrollarea $cf.sa$row]
set lb [listbox $_sa.lb -width 0]
$_sa setwidget $lb
grid $_sa -row $row -rowspan 6 -column 0 -sticky w -padx {10 0} -pady {5 0}

#
# A ttk::combobox widget
#
set l [ttk::label $cf.l$row -text "Release:"]
grid $l -row $row -column 1 -sticky w -padx {10 0} -pady {5 0}
set cb [ttk::combobox $cf.cb -state readonly -width 14]
grid $cb -row $row -column 2 -sticky w -padx {5 10} -pady {5 0}

#
# A ttk::spinbox widget
#
incr row
set l [ttk::label $cf.l$row -text "Changes:"]
grid $l -row $row -column 1 -sticky w -padx {10 0} -pady {10 0}
set sb [ttk::spinbox $cf.sb -from 0 -to 20 -state readonly -width 4]
grid $sb -row $row -column 2 -sticky w -padx {5 10} -pady {10 0}

#
# A ttk::entry widget
#
incr row
set l [ttk::label $cf.l$row -text "Comment:"]
grid $l -row $row -column 1 -sticky w -padx {10 0} -pady {10 0}
set e [ttk::entry $cf.e -width 32]
grid $e -row $row -column 2 -sticky w -padx {5 10} -pady {10 0}

#
# A ttk::separator widget
#
incr row
set sep [ttk::separator $cf.sep]
grid $sep -row $row -column 1 -columnspan 2 -sticky we -padx 10 -pady {10 0}

#
# A mentry widget of type "Date"
#
incr row
set l [ttk::label $cf.l$row -text "Date of first release:"]
grid $l -row $row -column 1 -sticky w -padx {10 0} -pady {10 0}
set me [mentry::dateMentry $cf.me Ymd -]
grid $me -row $row -column 2 -sticky w -padx {5 10} -pady {10 0}

incr row
grid rowconfigure $cf $row -weight 1

#
# A scrolled tablelist widget
#
incr row
set l [ttk::label $cf.l$row -text \
       "Tablelist release statistics, displayed in a tablelist widget:"]
grid $l -row $row -column 0 -columnspan 3 -sticky w -padx 10 -pady {10 0}
incr row
set _sa [scrollutil::scrollarea $cf.sa$row]
set tbl [tablelist::tablelist $_sa.tbl \
	 -columns {0 "Release" left  0 "Changes" right  0 "Comment" left} \
	 -height 16 -width 0 -showseparators yes -stripebackground #f0f0f0 \
	 -incrarrowtype down -labelcommand tablelist::sortByColumn]
if {[$tbl cget -selectborderwidth] == 0} {
    $tbl configure -spacing 1
}
$tbl columnconfigure 0 -name release -sortmode dictionary
$tbl columnconfigure 1 -name changes -sortmode integer
$tbl columnconfigure 2 -name comment
$_sa setwidget $tbl
grid $_sa -row $row -column 0 -columnspan 3 -sticky w -padx 10 -pady {5 0}










#
# A scrolled ttk::treeview widget
#
incr row
set l [ttk::label $cf.l$row -text \
       "Tablelist release statistics, displayed in a ttk::treeview widget:"]
grid $l -row $row -column 0 -columnspan 3 -sticky w -padx 10 -pady {10 0}
incr row
set _sa [scrollutil::scrollarea $cf.sa$row -borderwidth 0]



set tv [ttk::treeview $_sa.tv -columns {release changes comment} \
	-show headings -height 16 -selectmode browse]
if {$ttk::currentTheme eq "aqua" &&
    [package vcompare $::tk_patchLevel "8.6.10"] >= 0} {
    $_sa configure -borderwidth 1 ;# because in this case $tv has a flat relief
}
$tv heading release -text " Release" -anchor w
$tv heading changes -text "Changes " -anchor e
$tv heading comment -text " Comment" -anchor w
$tv column release -anchor w
$tv column changes -anchor e
$tv column comment -anchor w
$_sa setwidget $tv
grid $_sa -row $row -column 0 -columnspan 3 -sticky w -padx 10 -pady {5 10}

grid columnconfigure $cf 2 -weight 1

#
# Populate the widgets
#

................................................................................
    $tv column $colId -width [$tbl columnwidth $colId -total]
}

#
# Set the scrollableframe's width, height, and yscrollincrement
#
update idletasks
set height [expr {[winfo reqheight $cf.l0] + [winfo reqheight $cf.sa1] + 25}]

$sf configure -width [winfo reqwidth $cf] -height $height \
    -yscrollincrement [expr {[winfo reqheight $lb] / 10}]

pack $sa -expand yes -fill both -padx 10 -pady 10

#
# Create two ttk::button widgets within a frame outside the scrollarea
#
set bf [ttk::frame .bf]
set b1 [ttk::button $bf.b1 -text "Configure Tablelist Widget" \
        -command configTablelist]
set b2 [ttk::button $bf.b2 -text "Close" -command exit]
pack $b2 -side right -padx 10 -pady {0 10}
pack $b1 -side left -padx 10 -pady {0 10}

pack $bf -side bottom -fill x
pack $tf -side top -expand yes -fill both

#------------------------------------------------------------------------------

proc cancelEdit {w args} {
................................................................................
    foreach configSet [$tbl configure] {
	if {[llength $configSet] != 5} {
	    continue
	}

	set opt [lindex $configSet 0]
	set w [ttk::label $cf.l$row -text $opt]
	grid $w -row $row -column 0 -sticky w -padx {5 0} -pady {5 0}

	set w $cf.w$row
	switch -- $opt {
	    -activestyle -
	    -arrowstyle -
	    -incrarrowtype -
	    -labelrelief -
................................................................................
			winxpOlive winxpSilver yuyo}
		    }
		}

		$w configure -values $values
		$w set [$tbl cget $opt]
		bind $w <<ComboboxSelected>> [list applyValue %W $opt]
		grid $w -row $row -column 1 -sticky w -padx 5 -pady {5 0}

		#
		# Adapt the handling of the mouse wheel
		# events for the ttk::combobox widget
		#
		scrollutil::adaptWheelEventHandling $w
	    }
................................................................................
	    -showlabels -
	    -showseparators -
	    -tight {
		ttk::checkbutton $w -command [list applyBoolean $w $opt]
		global $w
		set $w [$tbl cget $opt]
		$w configure -text [expr {[set $w] ? "true": "false"}]
		grid $w -row $row -column 1 -sticky w -padx 5 -pady {5 0}
	    }

	    -borderwidth -
	    -height -
	    -highlightthickness -
	    -labelborderwidth -
	    -labelheight -
................................................................................
		$w set [$tbl cget $opt]
		$w configure -invalidcommand bell -validate key \
		    -validatecommand \
		    {expr {[string length %P] <= 3 && [regexp {^[0-9]*$} %S]}}
		foreach event {<Return> <KP_Enter> <FocusOut>} {
		    bind $w $event [list applyValue %W $opt]
		}
		grid $w -row $row -column 1 -sticky w -padx 5 -pady {5 0}

		#
		# Adapt the handling of the mouse wheel
		# events for the ttk::spinbox widget
		#
		scrollutil::adaptWheelEventHandling $w
	    }
................................................................................

	    default {
		ttk::entry $w -width 20
		$w insert 0 [$tbl cget $opt]
		foreach event {<Return> <KP_Enter> <FocusOut>} {
		    bind $w $event [list applyValue %W $opt]
		}
		grid $w -row $row -column 1 -sticky we -padx 5 -pady {5 0}
	    }
	}

	#
	# Make the keyboard navigation more user-friendly
	#
	bind $w <<TraverseIn>> [list $sf see %W]
................................................................................
    grid columnconfigure $cf 1   -weight 1

    #
    # Set the scrollableframe's width, height, and yscrollincrement
    #
    update idletasks
    set rowHeight [expr {[winfo reqheight $cf] / $row}]

    $sf configure -width [winfo reqwidth $cf] \
	-height [expr {10*$rowHeight + 5}] -yscrollincrement $rowHeight

    #
    # Create a ttk::button widget outside the scrollarea
    #
    set b [ttk::button $f.b -text "Close" -command [list destroy $top]]

    pack $b  -side bottom -pady {0 10}
    pack $sa -side top -expand yes -fill both -padx 10 -pady 10
    pack $f  -expand yes -fill both
}

#------------------------------------------------------------------------------

proc applyValue {w opt} {
    global tbl







|





|






|




|





|

|






|

|






|

|






|






|

|










|













|
>
>
>
>
>
>
>
>
>







|


>
>
>













|







 







|
>



|








|
|







 







|







 







|







 







|







 







|







 







|







 







>
|
|






|
|







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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
...
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
...
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
...
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
...
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
...
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
...
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
...
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483

#
# A scrolled text widget with old-school mouse wheel support
#
set row 0
set l [ttk::label $cf.l$row -text \
       "Contents of the Tablelist distribution file \"CHANGES.txt\":"]
grid $l -row $row -column 0 -columnspan 3 -sticky w -padx 7p -pady {7p 0}
incr row
set _sa [scrollutil::scrollarea $cf.sa$row]
set txt [text $_sa.txt -font TkFixedFont -width 73]
scrollutil::addMouseWheelSupport $txt
$_sa setwidget $txt
grid $_sa -row $row -column 0 -columnspan 3 -sticky w -padx 7p -pady {4p 0}

#
# A scrolled listbox widget
#
incr row
set l [ttk::label $cf.l$row -text "Tablelist releases:"]
grid $l -row $row -column 0 -sticky w -padx {7p 0} -pady {7p 0}
incr row
set _sa [scrollutil::scrollarea $cf.sa$row]
set lb [listbox $_sa.lb -width 0]
$_sa setwidget $lb
grid $_sa -row $row -rowspan 6 -column 0 -sticky w -padx {7p 0} -pady {4p 0}

#
# A ttk::combobox widget
#
set l [ttk::label $cf.l$row -text "Release:"]
grid $l -row $row -column 1 -sticky w -padx {7p 0} -pady {4p 0}
set cb [ttk::combobox $cf.cb -state readonly -width 14]
grid $cb -row $row -column 2 -sticky w -padx {4p 7p} -pady {4p 0}

#
# A ttk::spinbox widget
#
incr row
set l [ttk::label $cf.l$row -text "Changes:"]
grid $l -row $row -column 1 -sticky w -padx {7p 0} -pady {7p 0}
set sb [ttk::spinbox $cf.sb -from 0 -to 20 -state readonly -width 4]
grid $sb -row $row -column 2 -sticky w -padx {4p 7p} -pady {7p 0}

#
# A ttk::entry widget
#
incr row
set l [ttk::label $cf.l$row -text "Comment:"]
grid $l -row $row -column 1 -sticky w -padx {7p 0} -pady {7p 0}
set e [ttk::entry $cf.e -width 32]
grid $e -row $row -column 2 -sticky w -padx {4p 7p} -pady {7p 0}

#
# A ttk::separator widget
#
incr row
set sep [ttk::separator $cf.sep]
grid $sep -row $row -column 1 -columnspan 2 -sticky we -padx 7p -pady {7p 0}

#
# A mentry widget of type "Date"
#
incr row
set l [ttk::label $cf.l$row -text "Date of first release:"]
grid $l -row $row -column 1 -sticky w -padx {7p 0} -pady {7p 0}
set me [mentry::dateMentry $cf.me Ymd -]
grid $me -row $row -column 2 -sticky w -padx {4p 7p} -pady {7p 0}

incr row
grid rowconfigure $cf $row -weight 1

#
# A scrolled tablelist widget
#
incr row
set l [ttk::label $cf.l$row -text \
       "Tablelist release statistics, displayed in a tablelist widget:"]
grid $l -row $row -column 0 -columnspan 3 -sticky w -padx 7p -pady {7p 0}
incr row
set _sa [scrollutil::scrollarea $cf.sa$row]
set tbl [tablelist::tablelist $_sa.tbl \
	 -columns {0 "Release" left  0 "Changes" right  0 "Comment" left} \
	 -height 16 -width 0 -showseparators yes -stripebackground #f0f0f0 \
	 -incrarrowtype down -labelcommand tablelist::sortByColumn]
if {[$tbl cget -selectborderwidth] == 0} {
    $tbl configure -spacing 1
}
$tbl columnconfigure 0 -name release -sortmode dictionary
$tbl columnconfigure 1 -name changes -sortmode integer
$tbl columnconfigure 2 -name comment
$_sa setwidget $tbl
grid $_sa -row $row -column 0 -columnspan 3 -sticky w -padx 7p -pady {4p 0}

#
# On X11 configure the tablelist according to the display's
# DPI scaling level (redundant for Tablelist 6.10 and later)
#
if {[tk windowingsystem] eq "x11"} {
    array set arr {100 8x4  125 9x5  150 11x6  175 13x7  200 15x8}
    $tbl configure -arrowstyle flat$arr($scrollutil::scalingpct)
}

#
# A scrolled ttk::treeview widget
#
incr row
set l [ttk::label $cf.l$row -text \
       "Tablelist release statistics, displayed in a ttk::treeview widget:"]
grid $l -row $row -column 0 -columnspan 3 -sticky w -padx 7p -pady {7p 0}
incr row
set _sa [scrollutil::scrollarea $cf.sa$row -borderwidth 0]
set font [ttk::style lookup Treeview -font]
ttk::style configure Treeview -rowheight \
    [expr {[font metrics $font -linespace] + 3}]
set tv [ttk::treeview $_sa.tv -columns {release changes comment} \
	-show headings -height 16 -selectmode browse]
if {$ttk::currentTheme eq "aqua" &&
    [package vcompare $::tk_patchLevel "8.6.10"] >= 0} {
    $_sa configure -borderwidth 1 ;# because in this case $tv has a flat relief
}
$tv heading release -text " Release" -anchor w
$tv heading changes -text "Changes " -anchor e
$tv heading comment -text " Comment" -anchor w
$tv column release -anchor w
$tv column changes -anchor e
$tv column comment -anchor w
$_sa setwidget $tv
grid $_sa -row $row -column 0 -columnspan 3 -sticky w -padx 7p -pady {4p 7p}

grid columnconfigure $cf 2 -weight 1

#
# Populate the widgets
#

................................................................................
    $tv column $colId -width [$tbl columnwidth $colId -total]
}

#
# Set the scrollableframe's width, height, and yscrollincrement
#
update idletasks
set height [expr {[winfo reqheight $cf.l0] + [winfo pixels . 4p] + \
		  [winfo reqheight $cf.sa1] + 2*[winfo pixels . 7p]}]
$sf configure -width [winfo reqwidth $cf] -height $height \
    -yscrollincrement [expr {[winfo reqheight $lb] / 10}]

pack $sa -expand yes -fill both -padx 7p -pady 7p

#
# Create two ttk::button widgets within a frame outside the scrollarea
#
set bf [ttk::frame .bf]
set b1 [ttk::button $bf.b1 -text "Configure Tablelist Widget" \
        -command configTablelist]
set b2 [ttk::button $bf.b2 -text "Close" -command exit]
pack $b2 -side right -padx 7p -pady {0 7p}
pack $b1 -side left -padx 7p -pady {0 7p}

pack $bf -side bottom -fill x
pack $tf -side top -expand yes -fill both

#------------------------------------------------------------------------------

proc cancelEdit {w args} {
................................................................................
    foreach configSet [$tbl configure] {
	if {[llength $configSet] != 5} {
	    continue
	}

	set opt [lindex $configSet 0]
	set w [ttk::label $cf.l$row -text $opt]
	grid $w -row $row -column 0 -sticky w -padx {4p 0} -pady {4p 0}

	set w $cf.w$row
	switch -- $opt {
	    -activestyle -
	    -arrowstyle -
	    -incrarrowtype -
	    -labelrelief -
................................................................................
			winxpOlive winxpSilver yuyo}
		    }
		}

		$w configure -values $values
		$w set [$tbl cget $opt]
		bind $w <<ComboboxSelected>> [list applyValue %W $opt]
		grid $w -row $row -column 1 -sticky w -padx 4p -pady {4p 0}

		#
		# Adapt the handling of the mouse wheel
		# events for the ttk::combobox widget
		#
		scrollutil::adaptWheelEventHandling $w
	    }
................................................................................
	    -showlabels -
	    -showseparators -
	    -tight {
		ttk::checkbutton $w -command [list applyBoolean $w $opt]
		global $w
		set $w [$tbl cget $opt]
		$w configure -text [expr {[set $w] ? "true": "false"}]
		grid $w -row $row -column 1 -sticky w -padx 4p -pady {4p 0}
	    }

	    -borderwidth -
	    -height -
	    -highlightthickness -
	    -labelborderwidth -
	    -labelheight -
................................................................................
		$w set [$tbl cget $opt]
		$w configure -invalidcommand bell -validate key \
		    -validatecommand \
		    {expr {[string length %P] <= 3 && [regexp {^[0-9]*$} %S]}}
		foreach event {<Return> <KP_Enter> <FocusOut>} {
		    bind $w $event [list applyValue %W $opt]
		}
		grid $w -row $row -column 1 -sticky w -padx 4p -pady {4p 0}

		#
		# Adapt the handling of the mouse wheel
		# events for the ttk::spinbox widget
		#
		scrollutil::adaptWheelEventHandling $w
	    }
................................................................................

	    default {
		ttk::entry $w -width 20
		$w insert 0 [$tbl cget $opt]
		foreach event {<Return> <KP_Enter> <FocusOut>} {
		    bind $w $event [list applyValue %W $opt]
		}
		grid $w -row $row -column 1 -sticky we -padx 4p -pady {4p 0}
	    }
	}

	#
	# Make the keyboard navigation more user-friendly
	#
	bind $w <<TraverseIn>> [list $sf see %W]
................................................................................
    grid columnconfigure $cf 1   -weight 1

    #
    # Set the scrollableframe's width, height, and yscrollincrement
    #
    update idletasks
    set rowHeight [expr {[winfo reqheight $cf] / $row}]
    set height [expr {10*$rowHeight + [winfo pixels .top 4p]}]
    $sf configure -width [winfo reqwidth $cf] -height $height \
	-yscrollincrement $rowHeight

    #
    # Create a ttk::button widget outside the scrollarea
    #
    set b [ttk::button $f.b -text "Close" -command [list destroy $top]]

    pack $b  -side bottom -pady {0 7p}
    pack $sa -side top -expand yes -fill both -padx 7p -pady 7p
    pack $f  -expand yes -fill both
}

#------------------------------------------------------------------------------

proc applyValue {w opt} {
    global tbl

Changes to examples/scrollutil/SuScrollableFrmDemo1.tcl.

4
5
6
7
8
9
10

11
12
13
14
15
16
17
18
..
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
# Demonstrates the use of the Scrollutil package in connection with the
# scrollutil::scrollableframe widget.
#
# Copyright (c) 2019-2020  Csaba Nemethi (E-mail: csaba.nemethi@t-online.de)
#==============================================================================

package require scrollutil_tile

source styleUtil.tcl

wm title . "European Capitals Quiz"

#
# Create a scrollableframe within a scrollarea
#
set f  [ttk::frame .f]
................................................................................
foreach country $countryList capital $capitalList {
    set capitalArr($country) $capital
}

set capitalList [lsort $capitalList]

if {[lsearch -exact {aqua vista xpnative} $ttk::currentTheme] >= 0} {
    set topPadY 2
} else {
    set topPadY 5
}
set padY [list $topPadY 0]

set row 0
foreach country $countryList {
    set w [ttk::label $cf.l$row -text $country]
    grid $w -row $row -column 0 -sticky w -padx {5 0} -pady $padY

    set w [ttk::combobox $cf.cb$row -state readonly -width 14 \
	   -values $capitalList]
    bind $w <<ComboboxSelected>> [list checkCapital %W $country]
    grid $w -row $row -column 1 -sticky w -padx {5 0} -pady $padY

    #
    # Make the keyboard navigation more user-friendly
    #
    bind $w <<TraverseIn>> [list $sf see %W]

    #
    # Adapt the handling of the mouse wheel events for the ttk::combobox widget
    #
    scrollutil::adaptWheelEventHandling $w

    set b [createToolbutton $cf.b$row -text "Resolve" \
	   -command [list setCapital $w $country]]
    grid $b -row $row -column 2 -sticky w -padx 5 -pady $padY

    #
    # Make the keyboard navigation more user-friendly
    #
    bind $b <<TraverseIn>> [list $sf see %W]

    incr row
................................................................................
}

#
# Set the scrollableframe's width, height, and yscrollincrement
#
update idletasks
set rowHeight [expr {[winfo reqheight $cf] / $row}]

$sf configure -width [winfo reqwidth $cf] \
    -height [expr {10*$rowHeight + $topPadY}] -yscrollincrement $rowHeight

#
# Create a ttk::button widget outside the scrollarea
#
set b [ttk::button $f.b -text "Close" -command exit]

pack $b  -side bottom -pady {0 10}
pack $sa -side top -expand yes -fill both -padx 10 -pady 10
pack $f  -expand yes -fill both

#------------------------------------------------------------------------------

proc checkCapital {w country} {
    $w selection clear
    global capitalArr







>
|







 







|

|






|




|













|







 







>
|
|






|
|







4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
..
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
# Demonstrates the use of the Scrollutil package in connection with the
# scrollutil::scrollableframe widget.
#
# Copyright (c) 2019-2020  Csaba Nemethi (E-mail: csaba.nemethi@t-online.de)
#==============================================================================

package require scrollutil_tile
set dir [file dirname [info script]]
source [file join $dir styleUtil.tcl]

wm title . "European Capitals Quiz"

#
# Create a scrollableframe within a scrollarea
#
set f  [ttk::frame .f]
................................................................................
foreach country $countryList capital $capitalList {
    set capitalArr($country) $capital
}

set capitalList [lsort $capitalList]

if {[lsearch -exact {aqua vista xpnative} $ttk::currentTheme] >= 0} {
    set topPadY 1.5p
} else {
    set topPadY 4p
}
set padY [list $topPadY 0]

set row 0
foreach country $countryList {
    set w [ttk::label $cf.l$row -text $country]
    grid $w -row $row -column 0 -sticky w -padx {4p 0} -pady $padY

    set w [ttk::combobox $cf.cb$row -state readonly -width 14 \
	   -values $capitalList]
    bind $w <<ComboboxSelected>> [list checkCapital %W $country]
    grid $w -row $row -column 1 -sticky w -padx {4p 0} -pady $padY

    #
    # Make the keyboard navigation more user-friendly
    #
    bind $w <<TraverseIn>> [list $sf see %W]

    #
    # Adapt the handling of the mouse wheel events for the ttk::combobox widget
    #
    scrollutil::adaptWheelEventHandling $w

    set b [createToolbutton $cf.b$row -text "Resolve" \
	   -command [list setCapital $w $country]]
    grid $b -row $row -column 2 -sticky w -padx 4p -pady $padY

    #
    # Make the keyboard navigation more user-friendly
    #
    bind $b <<TraverseIn>> [list $sf see %W]

    incr row
................................................................................
}

#
# Set the scrollableframe's width, height, and yscrollincrement
#
update idletasks
set rowHeight [expr {[winfo reqheight $cf] / $row}]
set height [expr {10*$rowHeight + [winfo pixels . $topPadY]}]
$sf configure -width [winfo reqwidth $cf] -height $height \
    -yscrollincrement $rowHeight

#
# Create a ttk::button widget outside the scrollarea
#
set b [ttk::button $f.b -text "Close" -command exit]

pack $b  -side bottom -pady {0 7p}
pack $sa -side top -expand yes -fill both -padx 7p -pady 7p
pack $f  -expand yes -fill both

#------------------------------------------------------------------------------

proc checkCapital {w country} {
    $w selection clear
    global capitalArr

Changes to examples/scrollutil/SuScrollableFrmDemo2.tcl.

8
9
10
11
12
13
14

15
16
17
18
19
20
21
22
..
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#==============================================================================

package require Tk 8.5.9			;# for ttk::spinbox
package require mentry_tile 3.2			;# for mouse wheel support
package require tablelist_tile 6.5		;# for -(x|y)mousewheelwindow
						;# and scrollutil::scrollarea
package require scrollutil_tile

source styleUtil.tcl

wm title . "Scrollutil Demo"

#
# Create a scrollableframe within a scrollarea
#
set tf [ttk::frame .tf]
................................................................................
set sf [scrollutil::scrollableframe $sa.sf]
$sa setwidget $sf

#
# Get the content frame and populate it
#
set cf [$sf contentframe]
source SuScrollableFrmContent.tcl

#
# Make the keyboard navigation more user-friendly
#
foreach w [list $cb $sb $e $me] {
    bind $w <<TraverseIn>> [list $sf see %W]
}







>
|







 







|







8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
..
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#==============================================================================

package require Tk 8.5.9			;# for ttk::spinbox
package require mentry_tile 3.2			;# for mouse wheel support
package require tablelist_tile 6.5		;# for -(x|y)mousewheelwindow
						;# and scrollutil::scrollarea
package require scrollutil_tile
set dir [file dirname [info script]]
source [file join $dir styleUtil.tcl]

wm title . "Scrollutil Demo"

#
# Create a scrollableframe within a scrollarea
#
set tf [ttk::frame .tf]
................................................................................
set sf [scrollutil::scrollableframe $sa.sf]
$sa setwidget $sf

#
# Get the content frame and populate it
#
set cf [$sf contentframe]
source [file join $dir SuScrollableFrmContent.tcl]

#
# Make the keyboard navigation more user-friendly
#
foreach w [list $cb $sb $e $me] {
    bind $w <<TraverseIn>> [list $sf see %W]
}

Changes to examples/scrollutil/SyncListboxes.tcl.

4
5
6
7
8
9
10

11
12
13
14
15
16
17
18
..
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
# Demonstrates the use of the scrollutil::scrollsync widget in connection with
# two listbox widgets.
#
# Copyright (c) 2019-2020  Csaba Nemethi (E-mail: csaba.nemethi@t-online.de)
#==============================================================================

package require scrollutil_tile

source styleUtil.tcl

wm title . "European Countries"

#
# Create two ttk::label widgets within a ttk::frame
#
set f  [ttk::frame .f]
................................................................................

set itemCount [$lb1 size]
for {set idx 1} {$idx < $itemCount} {incr idx 2} {
    $lb1 itemconfigure $idx -background #f0f0f0
    $lb2 itemconfigure $idx -background #f0f0f0
}

grid $lb1 $lb2 -sticky news -padx {0 2}
grid rowconfigure    $ss 0 -weight 1
grid columnconfigure $ss 0 -weight 1
grid columnconfigure $ss 1 -weight 1

#
# Create a ttk::button widget
#
set b [ttk::button $f.b -text "Close" -command exit]

pack $b  -side bottom -pady {0 10}
pack $tf -side top -fill x -pady {10 0}    ;# for -padx see the proc updatePadx
pack $sa -side top -expand yes -fill both -padx 10 -pady {2 10}
pack $f  -expand yes -fill both

#
# Sets the -padx pack option for $w, depending on
# the mapped state of the vertical scrollbar $vsb.
#
proc updatePadx {w vsb vsbMapped} {
    set sa [winfo parent $vsb]
    set l [expr {10 + [$sa cget -borderwidth]}]
    set r $l
    if {$vsbMapped} {
	incr r [winfo width $vsb]
    }

    pack configure $w -padx [list $l $r]
}

updatePadx $tf $sa.vsb 0
bind $sa.vsb <Map>   [list updatePadx $tf %W 1]	 ;# $tf doesn't contain % chars
bind $sa.vsb <Unmap> [list updatePadx $tf %W 0]	 ;# $tf doesn't contain % chars







>
|







 







|









|
|
|








|











4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
..
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
# Demonstrates the use of the scrollutil::scrollsync widget in connection with
# two listbox widgets.
#
# Copyright (c) 2019-2020  Csaba Nemethi (E-mail: csaba.nemethi@t-online.de)
#==============================================================================

package require scrollutil_tile
set dir [file dirname [info script]]
source [file join $dir styleUtil.tcl]

wm title . "European Countries"

#
# Create two ttk::label widgets within a ttk::frame
#
set f  [ttk::frame .f]
................................................................................

set itemCount [$lb1 size]
for {set idx 1} {$idx < $itemCount} {incr idx 2} {
    $lb1 itemconfigure $idx -background #f0f0f0
    $lb2 itemconfigure $idx -background #f0f0f0
}

grid $lb1 $lb2 -sticky news -padx {0 1.5p}
grid rowconfigure    $ss 0 -weight 1
grid columnconfigure $ss 0 -weight 1
grid columnconfigure $ss 1 -weight 1

#
# Create a ttk::button widget
#
set b [ttk::button $f.b -text "Close" -command exit]

pack $b  -side bottom -pady {0 7p}
pack $tf -side top -fill x -pady {7p 0}    ;# for -padx see the proc updatePadx
pack $sa -side top -expand yes -fill both -padx 7p -pady {1.5p 7p}
pack $f  -expand yes -fill both

#
# Sets the -padx pack option for $w, depending on
# the mapped state of the vertical scrollbar $vsb.
#
proc updatePadx {w vsb vsbMapped} {
    set sa [winfo parent $vsb]
    set l [expr {[winfo pixels . 7p] + [$sa cget -borderwidth]}]
    set r $l
    if {$vsbMapped} {
	incr r [winfo width $vsb]
    }

    pack configure $w -padx [list $l $r]
}

updatePadx $tf $sa.vsb 0
bind $sa.vsb <Map>   [list updatePadx $tf %W 1]	 ;# $tf doesn't contain % chars
bind $sa.vsb <Unmap> [list updatePadx $tf %W 0]	 ;# $tf doesn't contain % chars

Changes to examples/scrollutil/SyncTablelists.tcl.

5
6
7
8
9
10
11

12
13
14
15
16
17
18
19
..
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
# three tablelist widgets.
#
# Copyright (c) 2019-2020  Csaba Nemethi (E-mail: csaba.nemethi@t-online.de)
#==============================================================================

package require tablelist_tile
package require scrollutil_tile

source styleUtil.tcl

wm title . "Synchronized Tablelists"

#
# Create three ttk::label widgets within a ttk::frame
#
set f  [ttk::frame .f]
................................................................................

    for {set i 0} {$i < 100} {incr i} {
	$tbl insert end [list "cell $i,0" "cell $i,1"]
    }
}
$ss setwidgets [list $tbl1 $tbl2 $tbl3]

grid $tbl1 $tbl2 $tbl3 -sticky news -padx {0 2}
grid rowconfigure    $ss 0 -weight 1
grid columnconfigure $ss 0 -weight 1
grid columnconfigure $ss 1 -weight 1
grid columnconfigure $ss 2 -weight 1

#
# Create a ttk::button widget
#
set b [ttk::button $f.b -text "Close" -command exit]

pack $b  -side bottom -pady {0 10}
pack $tf -side top -fill x -pady {10 0}    ;# for -padx see the proc updatePadx
pack $sa -side top -expand yes -fill both -padx 10 -pady {2 10}
pack $f  -expand yes -fill both

#
# Sets the -padx pack option for $w, depending on
# the mapped state of the vertical scrollbar $vsb.
#
proc updatePadx {w vsb vsbMapped} {
    set sa [winfo parent $vsb]
    set l [expr {10 + [$sa cget -borderwidth]}]
    set r $l
    if {$vsbMapped} {
	incr r [winfo width $vsb]
    }

    pack configure $w -padx [list $l $r]
}

updatePadx $tf $sa.vsb 0
bind $sa.vsb <Map>   [list updatePadx $tf %W 1]	 ;# $tf doesn't contain % chars
bind $sa.vsb <Unmap> [list updatePadx $tf %W 0]	 ;# $tf doesn't contain % chars







>
|







 







|










|
|
|








|











5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
..
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
# three tablelist widgets.
#
# Copyright (c) 2019-2020  Csaba Nemethi (E-mail: csaba.nemethi@t-online.de)
#==============================================================================

package require tablelist_tile
package require scrollutil_tile
set dir [file dirname [info script]]
source [file join $dir styleUtil.tcl]

wm title . "Synchronized Tablelists"

#
# Create three ttk::label widgets within a ttk::frame
#
set f  [ttk::frame .f]
................................................................................

    for {set i 0} {$i < 100} {incr i} {
	$tbl insert end [list "cell $i,0" "cell $i,1"]
    }
}
$ss setwidgets [list $tbl1 $tbl2 $tbl3]

grid $tbl1 $tbl2 $tbl3 -sticky news -padx {0 1.5p}
grid rowconfigure    $ss 0 -weight 1
grid columnconfigure $ss 0 -weight 1
grid columnconfigure $ss 1 -weight 1
grid columnconfigure $ss 2 -weight 1

#
# Create a ttk::button widget
#
set b [ttk::button $f.b -text "Close" -command exit]

pack $b  -side bottom -pady {0 7p}
pack $tf -side top -fill x -pady {7p 0}    ;# for -padx see the proc updatePadx
pack $sa -side top -expand yes -fill both -padx 7p -pady {1.5p 7p}
pack $f  -expand yes -fill both

#
# Sets the -padx pack option for $w, depending on
# the mapped state of the vertical scrollbar $vsb.
#
proc updatePadx {w vsb vsbMapped} {
    set sa [winfo parent $vsb]
    set l [expr {[winfo pixels . 7p] + [$sa cget -borderwidth]}]
    set r $l
    if {$vsbMapped} {
	incr r [winfo width $vsb]
    }

    pack configure $w -padx [list $l $r]
}

updatePadx $tf $sa.vsb 0
bind $sa.vsb <Map>   [list updatePadx $tf %W 1]	 ;# $tf doesn't contain % chars
bind $sa.vsb <Unmap> [list updatePadx $tf %W 0]	 ;# $tf doesn't contain % chars