/usr/share/astk/BWidget-1.7.0/pagesmgr.tcl is in code-aster-gui 1.13.1-2.
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 | # ------------------------------------------------------------------------------
# pagesmgr.tcl
# This file is part of Unifix BWidget Toolkit
# $Id: pagesmgr.tcl 606 2004-04-05 07:06:06Z mcourtoi $
# ------------------------------------------------------------------------------
# Index of commands:
# - PagesManager::create
# - PagesManager::configure
# - PagesManager::cget
# - PagesManager::compute_size
# - PagesManager::add
# - PagesManager::delete
# - PagesManager::raise
# - PagesManager::page
# - PagesManager::pages
# - PagesManager::getframe
# - PagesManager::_test_page
# - PagesManager::_select
# - PagesManager::_redraw
# - PagesManager::_draw_area
# - PagesManager::_realize
# ------------------------------------------------------------------------------
package require Tcl 8.1.1
namespace eval PagesManager {
Widget::define PagesManager pagesmgr
Widget::declare PagesManager {
{-background TkResource "" 0 frame}
{-cursor TkResource "" 0 frame}
{-width Int 0 0 "%d >= 0"}
{-height Int 0 0 "%d >= 0"}
}
Widget::addmap PagesManager "" :cmd { -width {} -height {} -cursor {} }
}
# ------------------------------------------------------------------------------
# Command PagesManager::create
# ------------------------------------------------------------------------------
proc PagesManager::create { path args } {
variable $path
upvar 0 $path data
Widget::init PagesManager $path $args
set data(select) ""
set data(pages) {}
set data(cpt) 0
set data(realized) 0
# --- creation du canvas -----------------------------------------------------------------
eval canvas $path -relief flat -bd 0 -highlightthickness 0 \
[Widget::subcget $path :cmd]
bind $path <Configure> [list PagesManager::_realize $path]
bind $path <Destroy> [list PagesManager::_destroy $path]
return [Widget::create PagesManager $path]
}
# ------------------------------------------------------------------------------
# Command PagesManager::configure
# ------------------------------------------------------------------------------
proc PagesManager::configure { path args } {
return [Widget::configure $path $args]
}
# ------------------------------------------------------------------------------
# Command PagesManager::cget
# ------------------------------------------------------------------------------
proc PagesManager::cget { path option } {
return [Widget::cget $path $option]
}
# ------------------------------------------------------------------------------
# Command PagesManager::compute_size
# ------------------------------------------------------------------------------
proc PagesManager::compute_size { path } {
variable $path
upvar 0 $path data
set wmax 0
set hmax 0
update idletasks
foreach page $data(pages) {
set w [winfo reqwidth $path.f$page]
set h [winfo reqheight $path.f$page]
set wmax [expr {$w>$wmax ? $w : $wmax}]
set hmax [expr {$h>$hmax ? $h : $hmax}]
}
configure $path -width $wmax -height $hmax
}
# ------------------------------------------------------------------------------
# Command PagesManager::add
# ------------------------------------------------------------------------------
proc PagesManager::add { path page } {
variable $path
upvar 0 $path data
if { [lsearch -exact $data(pages) $page] != -1 } {
return -code error "page \"$page\" already exists"
}
lappend data(pages) $page
frame $path.f$page -relief flat \
-background [Widget::cget $path -background] -borderwidth 0
return $path.f$page
}
# ------------------------------------------------------------------------------
# Command PagesManager::delete
# ------------------------------------------------------------------------------
proc PagesManager::delete { path page } {
variable $path
upvar 0 $path data
set pos [_test_page $path $page]
set data(pages) [lreplace $data(pages) $pos $pos]
if { $data(select) == $page } {
set data(select) ""
}
destroy $path.f$page
_redraw $path
}
# ------------------------------------------------------------------------------
# Command PagesManager::raise
# ------------------------------------------------------------------------------
proc PagesManager::raise { path {page ""} } {
variable $path
upvar 0 $path data
if { $page != "" } {
_test_page $path $page
_select $path $page
}
return $data(select)
}
# ------------------------------------------------------------------------------
# Command PagesManager::page - deprecated, use pages
# ------------------------------------------------------------------------------
proc PagesManager::page { path first {last ""} } {
variable $path
upvar 0 $path data
if { $last == "" } {
return [lindex $data(pages) $first]
} else {
return [lrange $data(pages) $first $last]
}
}
# ------------------------------------------------------------------------------
# Command PagesManager::pages
# ------------------------------------------------------------------------------
proc PagesManager::pages { path {first ""} {last ""} } {
variable $path
upvar 0 $path data
if { ![string length $first] } {
return $data(pages)
}
if { ![string length $last] } {
return [lindex $data(pages) $first]
} else {
return [lrange $data(pages) $first $last]
}
}
# ------------------------------------------------------------------------------
# Command PagesManager::getframe
# ------------------------------------------------------------------------------
proc PagesManager::getframe { path page } {
return $path.f$page
}
# ------------------------------------------------------------------------------
# Command PagesManager::_test_page
# ------------------------------------------------------------------------------
proc PagesManager::_test_page { path page } {
variable $path
upvar 0 $path data
if { [set pos [lsearch $data(pages) $page]] == -1 } {
return -code error "page \"$page\" does not exists"
}
return $pos
}
# ------------------------------------------------------------------------------
# Command PagesManager::_select
# ------------------------------------------------------------------------------
proc PagesManager::_select { path page } {
variable $path
upvar 0 $path data
set oldsel $data(select)
if { $page != $oldsel } {
set data(select) $page
_draw_area $path
}
}
# ------------------------------------------------------------------------------
# Command PagesManager::_redraw
# ------------------------------------------------------------------------------
proc PagesManager::_redraw { path } {
variable $path
upvar 0 $path data
if { !$data(realized) } {
return
}
_draw_area $path
}
# ------------------------------------------------------------------------------
# Command PagesManager::_draw_area
# ------------------------------------------------------------------------------
proc PagesManager::_draw_area { path } {
variable $path
upvar 0 $path data
set w [winfo width $path]
set h [winfo height $path]
set sel $data(select)
if { $sel != "" } {
if { [llength [$path:cmd find withtag "window"]] } {
$path:cmd coords "window" 0 0
$path:cmd itemconfigure "window" \
-width $w \
-height $h \
-window $path.f$sel
} else {
$path:cmd create window 0 0 \
-width $w \
-height $h \
-anchor nw \
-tags "window" \
-window $path.f$sel
}
} else {
$path:cmd delete "window"
}
}
# ------------------------------------------------------------------------------
# Command PagesManager::_realize
# ------------------------------------------------------------------------------
proc PagesManager::_realize { path } {
variable $path
upvar 0 $path data
if { [set width [Widget::cget $path -width]] == 0 ||
[set height [Widget::cget $path -height]] == 0 } {
compute_size $path
}
set data(realized) 1
_draw_area $path
bind $path <Configure> [list PagesManager::_draw_area $path]
}
# ------------------------------------------------------------------------------
# Command PagesManager::_destroy
# ------------------------------------------------------------------------------
proc PagesManager::_destroy { path } {
variable $path
upvar 0 $path data
Widget::destroy $path
unset data
}
|