/usr/share/ftools/POW/notebook.tcl is in ftools-pow 5.4+dfsg-4.
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 | # A Notebook widget for Tcl/Tk
# $Revision: 1.8 $
#
# Copyright (C) 1996,1997,1998 D. Richard Hipp
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Library General Public
# License as published by the Free Software Foundation; either
# version 2 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Library General Public License for more details.
#
# You should have received a copy of the GNU Library General Public
# License along with this library; if not, write to the
# Free Software Foundation, Inc., 59 Temple Place - Suite 330,
# Boston, MA 02111-1307, USA.
#
# Author contact information:
# drh@acm.org
# http://www.hwaci.com/drh/
#
# Create a new notebook widget
#
proc Notebook:create {w args} {
global Notebook powbg
global g_notebookTitleFont
set fontName [font names]
if { [string first "g_notebookTitleFont" $fontName] >= 0 } {
set Notebook($w,fontName) g_notebookTitleFont
} else {
set Notebook($w,fontName) [list System 16]
}
set Notebook($w,width) 300
set Notebook($w,height) 300
set Notebook($w,pages) {}
set Notebook($w,top) 0
set Notebook($w,pad) 5
set Notebook($w,fg,on) black
set Notebook($w,textFg,on) black
set Notebook($w,textFg,off) grey50
set Notebook($w,fg,off) grey50
canvas $w -bd 0 -highlightthickness 0 -takefocus 0
set Notebook($w,bg) [$w cget -bg]
bind $w <1> "Notebook:click $w %x %y"
bind $w <Configure> "Notebook:scheduleExpand $w"
eval Notebook:config $w $args
}
#
# Change configuration options for the notebook widget
#
proc Notebook:config {w args} {
global Notebook
foreach {tag value} $args {
switch -- $tag {
-width {
set Notebook($w,width) $value
}
-height {
set Notebook($w,height) $value
}
-pages {
set Notebook($w,pages) $value
}
-pad {
set Notebook($w,pad) $value
}
-bg {
set Notebook($w,bg) $value
}
-fg {
set Notebook($w,fg,on) $value
}
-disabledforeground {
set Notebook($w,fg,off) $value
}
-font {
set Notebook($w,fontName) $value
}
-textFg {
set Notebook($w,textFg,on) $value
}
}
}
#
# After getting new configuration values, reconstruct the widget
#
$w delete all
set Notebook($w,x1) $Notebook($w,pad)
set Notebook($w,x2) [expr $Notebook($w,x1)+2]
set Notebook($w,x3) [expr $Notebook($w,x2)+$Notebook($w,width)]
set Notebook($w,x4) [expr $Notebook($w,x3)+2]
set Notebook($w,y1) [expr $Notebook($w,pad)+2]
set Notebook($w,y2) [expr $Notebook($w,y1)+2]
set Notebook($w,y5) [expr $Notebook($w,y1)+30]
set Notebook($w,y6) [expr $Notebook($w,y5)+2]
set Notebook($w,y3) [expr $Notebook($w,y6)+$Notebook($w,height)]
set Notebook($w,y4) [expr $Notebook($w,y3)+2]
set x $Notebook($w,x1)
set cnt 0
set y7 [expr $Notebook($w,y1)+10]
foreach p $Notebook($w,pages) {
set Notebook($w,p$cnt,x5) $x
set id [$w create text 0 0 -text $p -anchor nw -tags "p$cnt t$cnt" \
-font $Notebook($w,fontName) \
-fill $Notebook($w,textFg,on)]
set bbox [$w bbox $id]
set width [lindex $bbox 2]
$w move $id [expr $x+10] $y7
$w create line \
$x $Notebook($w,y5)\
$x $Notebook($w,y2) \
[expr $x+2] $Notebook($w,y1) \
[expr $x+$width+16] $Notebook($w,y1) \
-width 2 -fill white -tags p$cnt
$w create line \
[expr $x+$width+16] $Notebook($w,y1) \
[expr $x+$width+18] $Notebook($w,y2) \
[expr $x+$width+18] $Notebook($w,y5) \
-width 2 -fill black -tags p$cnt
set x [expr $x+$width+20]
set Notebook($w,p$cnt,x6) [expr $x-2]
if {![winfo exists $w.f$cnt]} {
frame $w.f$cnt -bd 0
}
place $w.f$cnt -x $Notebook($w,x2) -y $Notebook($w,y6) \
-width $Notebook($w,width) -height $Notebook($w,height)
$w.f$cnt config -bg $Notebook($w,bg)
incr cnt
}
$w create line \
$Notebook($w,x1) [expr $Notebook($w,y5)-2] \
$Notebook($w,x1) $Notebook($w,y3) \
-width 2 -fill white
$w create line \
$Notebook($w,x1) $Notebook($w,y3) \
$Notebook($w,x2) $Notebook($w,y4) \
$Notebook($w,x3) $Notebook($w,y4) \
$Notebook($w,x4) $Notebook($w,y3) \
$Notebook($w,x4) $Notebook($w,y6) \
$Notebook($w,x3) $Notebook($w,y5) \
-width 2 -fill black
if {![info exists Notebook($w,expand)]} {
$w config -width [expr $Notebook($w,x4)+$Notebook($w,pad)] \
-height [expr $Notebook($w,y4)+$Notebook($w,pad)] \
-bg $Notebook($w,bg)
}
set top $Notebook($w,top)
set Notebook($w,top) -1
Notebook:raise.page $w $top
}
#
# This routine is called whenever the mouse-button is pressed over
# the notebook. It determines if any page should be raised and raises
# that page.
#
proc Notebook:click {w x y} {
global Notebook
if {$y<$Notebook($w,y1) || $y>$Notebook($w,y6)} return
set N [llength $Notebook($w,pages)]
for {set i 0} {$i<$N} {incr i} {
if {$x>=$Notebook($w,p$i,x5) && $x<=$Notebook($w,p$i,x6)} {
Notebook:raise.page $w $i
break
}
}
}
#
# For internal use only. This procedure raised the n-th page of
# the notebook
#
proc Notebook:raise.page {w n} {
global Notebook
if {$n<0 || $n>=[llength $Notebook($w,pages)]} return
set top $Notebook($w,top)
if {$top>=0 && $top<[llength $Notebook($w,pages)]} {
$w move p$top 0 2
}
$w move p$n 0 -2
$w delete topline
if {$n>0} {
$w create line \
$Notebook($w,x1) $Notebook($w,y6) \
$Notebook($w,x2) $Notebook($w,y5) \
$Notebook($w,p$n,x5) $Notebook($w,y5) \
$Notebook($w,p$n,x5) [expr $Notebook($w,y5)-2] \
-width 2 -fill white -tags topline
}
$w create line \
$Notebook($w,p$n,x6) [expr $Notebook($w,y5)-2] \
$Notebook($w,p$n,x6) $Notebook($w,y5) \
-width 2 -fill white -tags topline
$w create line \
$Notebook($w,p$n,x6) $Notebook($w,y5) \
$Notebook($w,x3) $Notebook($w,y5) \
-width 2 -fill white -tags topline
set Notebook($w,top) $n
raise $w.f$n
}
#
# Change the page-specific configuration options for the notebook
#
proc Notebook:pageconfig {w name args} {
global Notebook
set i [lsearch $Notebook($w,pages) $name]
if {$i<0} return
foreach {tag value} $args {
switch -- $tag {
-state {
if {"$value"=="disabled"} {
$w itemconfig t$i -fg $Notebook($w,fg,off)
} else {
$w itemconfig t$i -fg $Notebook($w,fg,on)
}
}
-onexit {
set Notebook($w,p$i,onexit) $value
}
}
}
}
#
# This procedure raises a notebook page given its name. But first
# we check the "onexit" procedure for the current page (if any) and
# if it returns false, we don't allow the raise to proceed.
#
proc Notebook:raise {w name} {
global Notebook
set i [lsearch $Notebook($w,pages) $name]
if {$i<0} return
if {[info exists Notebook($w,p$i,onexit)]} {
set onexit $Notebook($w,p$i,onexit)
if {"$onexit"!="" && [eval uplevel #0 $onexit]!=0} {
Notebook:raise.page $w $i
}
} else {
Notebook:raise.page $w $i
}
}
#
# Return the frame associated with a given page of the notebook.
#
proc Notebook:frame {w name} {
global Notebook
set i [lsearch $Notebook($w,pages) $name]
if {$i>=0} {
return $w.f$i
} else {
return {}
}
}
#
# Try to resize the notebook to the next time we become idle.
#
proc Notebook:scheduleExpand w {
global Notebook
if {[info exists Notebook($w,expand)]} return
set Notebook($w,expand) 1
after idle "Notebook:expand $w"
}
#
# Resize the notebook to fit inside its containing widget.
#
proc Notebook:expand w {
global Notebook
set wi [expr [winfo width $w]-($Notebook($w,pad)*2+4)]
set hi [expr [winfo height $w]-($Notebook($w,pad)*2+36)]
Notebook:config $w -width $wi -height $hi
catch {unset Notebook($w,expand)}
}
#
# Locate minimum dimensions of frame and expand to it
#
proc Notebook:resize w {
global Notebook
update
set minWid [expr [winfo width $w]-($Notebook($w,pad)*2+4)]
set minHgt [expr [winfo height $w]-($Notebook($w,pad)*2+36)]
foreach pg $Notebook($w,pages) {
set frm [Notebook:frame $w $pg]
set hgt [winfo reqheight $frm]
set wid [winfo reqwidth $frm]
if { $hgt>$minHgt } { set minHgt $hgt }
if { $wid>$minWid } { set minWid $wid }
}
Notebook:config $w -width $minWid -height $minHgt
}
|