/usr/share/astk/BWidget-1.7.0/scrollframe.tcl is in code-aster-gui 1.8.4-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 | # ----------------------------------------------------------------------------
# scrollframe.tcl
# This file is part of Unifix BWidget Toolkit
# $Id: scrollframe.tcl 606 2004-04-05 07:06:06Z mcourtoi $
# ----------------------------------------------------------------------------
# Index of commands:
# - ScrollableFrame::create
# - ScrollableFrame::configure
# - ScrollableFrame::cget
# - ScrollableFrame::getframe
# - ScrollableFrame::see
# - ScrollableFrame::xview
# - ScrollableFrame::yview
# - ScrollableFrame::_resize
# ----------------------------------------------------------------------------
namespace eval ScrollableFrame {
Widget::define ScrollableFrame scrollframe
Widget::declare ScrollableFrame {
{-background TkResource "" 0 frame}
{-width Int 0 0 {}}
{-height Int 0 0 {}}
{-areawidth Int 0 0 {}}
{-areaheight Int 0 0 {}}
{-constrainedwidth Boolean 0 0}
{-constrainedheight Boolean 0 0}
{-xscrollcommand TkResource "" 0 canvas}
{-yscrollcommand TkResource "" 0 canvas}
{-xscrollincrement TkResource "" 0 canvas}
{-yscrollincrement TkResource "" 0 canvas}
{-bg Synonym -background}
}
Widget::addmap ScrollableFrame "" :cmd {
-background {} -width {} -height {}
-xscrollcommand {} -yscrollcommand {}
-xscrollincrement {} -yscrollincrement {}
}
Widget::addmap ScrollableFrame "" .frame {-background {}}
variable _widget
bind BwScrollableFrame <Configure> [list ScrollableFrame::_resize %W]
bind BwScrollableFrame <Destroy> [list Widget::destroy %W]
}
# ----------------------------------------------------------------------------
# Command ScrollableFrame::create
# ----------------------------------------------------------------------------
proc ScrollableFrame::create { path args } {
Widget::init ScrollableFrame $path $args
set canvas [eval [list canvas $path] [Widget::subcget $path :cmd] \
-highlightthickness 0 -borderwidth 0 -relief flat]
set frame [eval [list frame $path.frame] [Widget::subcget $path .frame] \
-highlightthickness 0 -borderwidth 0 -relief flat]
$canvas create window 0 0 -anchor nw -window $frame -tags win \
-width [Widget::cget $path -areawidth] \
-height [Widget::cget $path -areaheight]
bind $frame <Configure> \
[list ScrollableFrame::_frameConfigure $canvas $frame %w %h]
bindtags $path [list $path BwScrollableFrame [winfo toplevel $path] all]
return [Widget::create ScrollableFrame $path]
}
# ----------------------------------------------------------------------------
# Command ScrollableFrame::configure
# ----------------------------------------------------------------------------
proc ScrollableFrame::configure { path args } {
set res [Widget::configure $path $args]
set upd 0
set modcw [Widget::hasChanged $path -constrainedwidth cw]
set modw [Widget::hasChanged $path -areawidth w]
if { $modcw || (!$cw && $modw) } {
if { $cw } {
set w [winfo width $path]
}
set upd 1
}
set modch [Widget::hasChanged $path -constrainedheight ch]
set modh [Widget::hasChanged $path -areaheight h]
if { $modch || (!$ch && $modh) } {
if { $ch } {
set h [winfo height $path]
}
set upd 1
}
if { $upd } {
$path:cmd itemconfigure win -width $w -height $h
}
return $res
}
# ----------------------------------------------------------------------------
# Command ScrollableFrame::cget
# ----------------------------------------------------------------------------
proc ScrollableFrame::cget { path option } {
return [Widget::cget $path $option]
}
# ----------------------------------------------------------------------------
# Command ScrollableFrame::getframe
# ----------------------------------------------------------------------------
proc ScrollableFrame::getframe { path } {
return $path.frame
}
# ----------------------------------------------------------------------------
# Command ScrollableFrame::see
# ----------------------------------------------------------------------------
proc ScrollableFrame::see { path widget {vert top} {horz left} {xOffset 0} {yOffset 0}} {
set x0 [winfo x $widget]
set y0 [winfo y $widget]
set x1 [expr {$x0+[winfo width $widget]}]
set y1 [expr {$y0+[winfo height $widget]}]
set xb0 [$path:cmd canvasx 0]
set yb0 [$path:cmd canvasy 0]
set xb1 [$path:cmd canvasx [winfo width $path]]
set yb1 [$path:cmd canvasy [winfo height $path]]
set dx 0
set dy 0
if { [string equal $horz "left"] } {
if { $x1 > $xb1 } {
set dx [expr {$x1-$xb1}]
}
if { $x0 < $xb0+$dx } {
set dx [expr {$x0-$xb0}]
}
} elseif { [string equal $horz "right"] } {
if { $x0 < $xb0 } {
set dx [expr {$x0-$xb0}]
}
if { $x1 > $xb1+$dx } {
set dx [expr {$x1-$xb1}]
}
}
if { [string equal $vert "top"] } {
if { $y1 > $yb1 } {
set dy [expr {$y1-$yb1}]
}
if { $y0 < $yb0+$dy } {
set dy [expr {$y0-$yb0}]
}
} elseif { [string equal $vert "bottom"] } {
if { $y0 < $yb0 } {
set dy [expr {$y0-$yb0}]
}
if { $y1 > $yb1+$dy } {
set dy [expr {$y1-$yb1}]
}
}
if {($dx + $xOffset) != 0} {
set x [expr {($xb0+$dx+$xOffset)/[winfo width $path.frame]}]
$path:cmd xview moveto $x
}
if {($dy + $yOffset) != 0} {
set y [expr {($yb0+$dy+$yOffset)/[winfo height $path.frame]}]
$path:cmd yview moveto $y
}
}
# ----------------------------------------------------------------------------
# Command ScrollableFrame::xview
# ----------------------------------------------------------------------------
proc ScrollableFrame::xview { path args } {
return [eval [list $path:cmd xview] $args]
}
# ----------------------------------------------------------------------------
# Command ScrollableFrame::yview
# ----------------------------------------------------------------------------
proc ScrollableFrame::yview { path args } {
return [eval [list $path:cmd yview] $args]
}
# ----------------------------------------------------------------------------
# Command ScrollableFrame::_resize
# ----------------------------------------------------------------------------
proc ScrollableFrame::_resize { path } {
if { [Widget::getoption $path -constrainedwidth] } {
$path:cmd itemconfigure win -width [winfo width $path]
}
if { [Widget::getoption $path -constrainedheight] } {
$path:cmd itemconfigure win -height [winfo height $path]
}
}
# ----------------------------------------------------------------------------
# Command ScrollableFrame::_frameConfigure
# ----------------------------------------------------------------------------
proc ScrollableFrame::_frameConfigure {canvas frame width height} {
# This ensures that we don't get funny scrollability in the frame
# when it is smaller than the canvas space
if {[winfo height $frame] < [winfo height $canvas]} {
set height [winfo height $canvas]
}
if {[winfo width $frame] < [winfo width $canvas]} {
set width [winfo width $canvas]
}
$canvas:cmd configure -scrollregion [list 0 0 $width $height]
}
|