This file is indexed.

/usr/share/tcltk/tcl8.5/Tix8.4.3/SWidget.tcl is in tix 8.4.3-5.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
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
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
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
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
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
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
# -*- mode: TCL; fill-column: 75; tab-width: 8; coding: iso-latin-1-unix -*-
#
#	$Id: SWidget.tcl,v 1.5 2002/01/24 09:13:58 idiscovery Exp $
#
# SWidget.tcl --
#
# 	tixScrolledWidget: virtual base class. Do not instantiate
#	This is the core class for all scrolled widgets.
#
# Copyright (c) 1993-1999 Ioi Kim Lam.
# Copyright (c) 2000-2001 Tix Project Group.
#
# See the file "license.terms" for information on usage and redistribution
# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
#


tixWidgetClass tixScrolledWidget {
    -virtual true
    -classname TixScrolledWidget
    -superclass tixPrimitive
    -method {
    }
    -flag {
	-scrollbar -scrollbarspace
    }
    -configspec {
	{-scrollbar scrollbar Scrollbar both}
	{-scrollbarspace scrollbarSpace ScrollbarSpace {both}}
        {-sizebox sizeBox SizeBox 0}
    }
}

proc tixScrolledWidget:InitWidgetRec {w} {
    upvar #0 $w data

    tixChainMethod $w InitWidgetRec

    set data(x,first)   0
    set data(x,last)    0

    set data(y,first)   0
    set data(y,last)    0

    set data(lastSpec) ""
    set data(lastMW)   ""
    set data(lastMH)   ""
    set data(lastScbW) ""
    set data(lastScbH) ""

    set data(repack)	0
    set data(counter)   0

    set data(vsbPadY)   0
    set data(hsbPadX)   0
}

proc tixScrolledWidget:SetBindings {w} {
    upvar #0 $w data

    tixChainMethod $w SetBindings

    tixManageGeometry $data(pw:client) "tixScrolledWidget:ClientGeomProc $w"
    bind $data(pw:client) <Configure> \
	[list tixScrolledWidget:ClientGeomProc $w "" $data(pw:client)]

    tixManageGeometry $data(w:hsb) "tixScrolledWidget:ClientGeomProc $w"
    bind $data(w:hsb) <Configure> \
	[list tixScrolledWidget:ClientGeomProc $w "" $data(w:hsb)]

    tixManageGeometry $data(w:vsb) "tixScrolledWidget:ClientGeomProc $w"
    bind $data(w:vsb) <Configure> \
	[list tixScrolledWidget:ClientGeomProc $w "" $data(w:vsb)]

    bind $w <Configure> "tixScrolledWidget:MasterGeomProc $w"

    tixWidgetDoWhenIdle tixScrolledWidget:Repack $w
    set data(repack) 1
}

proc tixScrolledWidget:config-scrollbar {w value} {
    upvar #0 $w data
    global tcl_platform

    if {[lindex $value 0] == "auto"} {
	foreach xspec [lrange $value 1 end] {
	    case $xspec {
		{+x -x +y -y} {}
		default {
		    error "bad -scrollbar value \"$value\""
		}
	    }
	}
    } else {
	case $value in {
	    {none x y both} {}
	    default {
		error "bad -scrollbar value \"$value\""
	    }
	}
    }

    if {$data(-sizebox) && $tcl_platform(platform) == "windows"} {
        set data(-scrollbar) both
    }

    if {$data(repack) == 0} {
	set data(repack) 1
	tixWidgetDoWhenIdle tixScrolledWidget:Repack $w
    }
}	

proc tixScrolledWidget:config-scrollbarspace {w value} {
    upvar #0 $w data
  
    if {$data(repack) == 0} {
	set data(repack) 1
	tixWidgetDoWhenIdle tixScrolledWidget:Repack $w
    }
}	

proc tixScrolledWidget:config-sizebox {w value} {
  error "unimplemented"
}


#----------------------------------------------------------------------
#
#		 Scrollbar calculations
#
#----------------------------------------------------------------------
proc tixScrolledWidget:ClientGeomProc {w type client} {
    upvar #0 $w data

    if {$data(repack) == 0} {
	set data(repack) 1
	tixWidgetDoWhenIdle tixScrolledWidget:Repack $w
    }
}

proc tixScrolledWidget:MasterGeomProc {w} {
    upvar #0 $w data

    if {$data(repack) == 0} {
	set data(repack) 1
	tixWidgetDoWhenIdle tixScrolledWidget:Repack $w
    }
}

proc tixScrolledWidget:Configure {w} {
    if {![winfo exists $w]} {
	return
    }

    upvar #0 $w data

    if {$data(repack) == 0} {
	set data(repack) 1
	tixWidgetDoWhenIdle tixScrolledWidget:Repack $w
    }
}

proc tixScrolledWidget:ScrollCmd {w scrollbar axis first last} {
    upvar #0 $w data

    $scrollbar set $first $last
}

# Show or hide the scrollbars as required.
#
# spec: 00 = need none
# spec: 01 = need y
# spec: 10 = need x
# spec: 11 = need xy
#
proc tixScrolledWidget:Repack {w} {
    tixCallMethod $w RepackHook
}

proc tixScrolledWidget:RepackHook {w} {
    upvar #0 $w data
    global tcl_platform

    if {![winfo exists $w]} {
	# This was generated by the <Destroy> event
	#
	return
    }

    set client $data(pw:client)

    # Calculate the size of the master
    #
    set mreqw [winfo reqwidth  $w]
    set mreqh [winfo reqheight $w]
    set creqw [winfo reqwidth  $client]
    set creqh [winfo reqheight $client]

    set scbW [winfo reqwidth  $w.vsb]
    set scbH [winfo reqheight $w.hsb]

    case $data(-scrollbarspace) {
	"x" {
	    incr creqh $scbH
	}
	"y" {
	    incr creqw $scbW
	}
	"both" {
	    incr creqw $scbW
	    incr creqh $scbH
	}
    }

    if {$data(-width) != 0} {
	set creqw $data(-width)
    }
    if {$data(-height) != 0} {
	set creqh $data(-height)
    }

    if {$mreqw != $creqw || $mreqh != $creqh } {
	if {![info exists data(counter)]} {
	    set data(counter) 0
	}
	if {$data(counter) < 50} {
	    incr data(counter)
	    tixGeometryRequest $w $creqw $creqh
	    tixWidgetDoWhenIdle tixScrolledWidget:Repack $w
	    set data(repack) 1
	    return
	}
    }

    set data(counter) 0
    set mw [winfo width  $w]
    set mh [winfo height $w]

    set cw [expr $mw - $scbW]
    set ch [expr $mh - $scbH]

    set scbx [expr $mw - $scbW]
    set scby [expr $mh - $scbH]

    # Check the validity of the sizes: if window was not mapped then
    # sizes will be below 1x1
    if {$cw < 1} {
	set cw 1
    }
    if {$ch < 1} {
	set ch 1
    }
    if {$scbx < 1} {
	set scbx 1
    }
    if {$scby < 1} {
	set scby 1
    }

    if {[lindex $data(-scrollbar) 0] == "auto"} {
	# Find out how we are going to pack the scrollbars
	#
	set spec [tixScrolledWidget:CheckScrollbars $w $scbW $scbH]

	foreach xspec [lrange $data(-scrollbar) 1 end] {
	    case $xspec {
		+x {
		    set spec [expr $spec | 10]
		}
		-x {
		    set spec [expr $spec & 01]
		}
		+y {
		    set spec [expr $spec | 01]
		}
		-y {
		    set spec [expr $spec & 10]
		}
	    }
	}
	if {$spec == 0} {
	    set spec 00
	}
	if {$spec == 1} {
	    set spec 01
	}
    } else {
	case $data(-scrollbar) in {
	    none {
		set spec 00
	    }
	    x {
		set spec 10
	    }
	    y {
		set spec 01
	    }
	    both {
		set spec 11
	    }
	}
    }


    if {$data(lastSpec)==$spec && $data(lastMW)==$mw && $data(lastMH)==$mh} {
	if {$data(lastScbW) == $scbW && $data(lastScbH) == $scbH} {
	    tixCallMethod $w PlaceWindow
	    set data(repack) 0
	    return
	}
    }

    set vsbH [expr $mh - $data(vsbPadY)]
    set hsbW [expr $mw - $data(hsbPadX)]

    if {$vsbH < 1} {
	set vsbH 1
    }
    if {$hsbW < 1} {
	set hsbW 1
    }

    case $spec in {
	"00" {
	    tixMoveResizeWindow $client 0 0 $mw $mh

	    tixMapWindow $client
    	    tixUnmapWindow $data(w:hsb)
	    tixUnmapWindow $data(w:vsb)
	}
	"01" {
	    tixMoveResizeWindow $client 0 0 $cw $mh
	    tixMoveResizeWindow $data(w:vsb) $scbx $data(vsbPadY) $scbW $vsbH

	    tixMapWindow $client
	    tixUnmapWindow $data(w:hsb)
	    tixMapWindow $data(w:vsb)
	}
	"10" {
	    tixMoveResizeWindow $client 0 0 $mw $ch
	    tixMoveResizeWindow $data(w:hsb) $data(hsbPadX) $scby $hsbW $scbH 

	    tixMapWindow $client
	    tixMapWindow $data(w:hsb)
	    tixUnmapWindow $data(w:vsb)
	}
	"11" {
	    set vsbH [expr $ch - $data(vsbPadY)]
	    set hsbW [expr $cw - $data(hsbPadX)]
	    if {$vsbH < 1} {
		set vsbH 1
	    }
	    if {$hsbW < 1} {
		set hsbW 1
	    }

	    tixMoveResizeWindow $client 0 0 $cw $ch
	    tixMoveResizeWindow $data(w:vsb) $scbx $data(vsbPadY) $scbW $vsbH
	    tixMoveResizeWindow $data(w:hsb) $data(hsbPadX) $scby $hsbW $scbH 
	    if {$data(-sizebox) && $tcl_platform(platform) == "windows"} {
	        tixMoveResizeWindow $data(w:sizebox) $scbx $scby $scbW $scbH
	    }

	    tixMapWindow $client
	    tixMapWindow $data(w:hsb)
	    tixMapWindow $data(w:vsb)
	    if {$data(-sizebox) && $tcl_platform(platform) == "windows"} {
	        tixMapWindow $data(w:sizebox)
	    }
	}
    }

    set data(lastSpec) $spec
    set data(lastMW)   $mw
    set data(lastMH)   $mh
    set data(lastScbW) $scbW
    set data(lastScbH) $scbH

    tixCallMethod $w PlaceWindow
    set data(repack) 0
}

proc tixScrolledWidget:PlaceWindow {w} {
    # virtual base function
}

#
# Helper function
#
proc tixScrolledWidget:NeedScrollbar {w axis} {
    upvar #0 $w data

    if {$data($axis,first) > 0.0} {
	return 1
    }

    if {$data($axis,last) < 1.0} {
	return 1
    }
    
    return 0
}

# Return whether H and V needs scrollbars in a list of two booleans
#
#
proc tixScrolledWidget:CheckScrollbars {w scbW scbH} {
    upvar #0 $w data

    set mW [winfo width  $w]
    set mH [winfo height $w]

    set info [tixCallMethod $w GeometryInfo $mW $mH]

    if {$info != ""} {
	set xSpec [lindex $info 0]
	set ySpec [lindex $info 1]

	set data(x,first)   [lindex $xSpec 0]
	set data(x,last)    [lindex $xSpec 1]

	set data(y,first)   [lindex $ySpec 0]
	set data(y,last)    [lindex $ySpec 1]
    }

    set needX [tixScrolledWidget:NeedScrollbar $w x]
    set needY [tixScrolledWidget:NeedScrollbar $w y]

    if {[winfo ismapped $w]==0} {
	return "$needX$needY"
    }

    if {$needX && $needY} {
	return 11
    }

    if {$needX == 0 && $needY == 0} {
	return 00
    }

    if {$needX} {
	set mH [expr $mH - $scbH]
    }
    if {$needY} {
	set mW [expr $mW - $scbW]
    }

    set info [tixCallMethod $w GeometryInfo $mW $mH]
    if {$info != ""} {
	set xSpec [lindex $info 0]
	set ySpec [lindex $info 1]

	set data(x,first)   [lindex $xSpec 0]
	set data(x,last)    [lindex $xSpec 1]

	set data(y,first)   [lindex $ySpec 0]
	set data(y,last)    [lindex $ySpec 1]
    }

    set needX [tixScrolledWidget:NeedScrollbar $w x]
    set needY [tixScrolledWidget:NeedScrollbar $w y]

    return "$needX$needY"
}