Attachment "notebook.diff" to
ticket [768610ffff]
added by
vincentdarley
2003-07-10 19:53:57.
Index: notebook.tcl
===================================================================
RCS file: /cvsroot/tcllib/bwidget/notebook.tcl,v
retrieving revision 1.16
diff -u -r1.16 notebook.tcl
--- notebook.tcl 15 May 2003 00:09:03 -0000 1.16
+++ notebook.tcl 10 Jul 2003 12:50:33 -0000
@@ -183,7 +183,7 @@
set chbg [Widget::hasChanged $path -background bg]
if {$chibd || $chbg} {
foreach page $data(pages) {
- $path.f$page configure \
+ [getframe $path $page] configure \
-borderwidth $ibd -background $bg
}
}
@@ -235,8 +235,8 @@
set hmax 0
update idletasks
foreach page $data(pages) {
- set w [winfo reqwidth $path.f$page]
- set h [winfo reqheight $path.f$page]
+ set w [winfo reqwidth [getframe $path $page]]
+ set h [winfo reqheight [getframe $path $page]]
set wmax [expr {$w>$wmax ? $w : $wmax}]
set hmax [expr {$h>$hmax ? $h : $hmax}]
}
@@ -254,22 +254,29 @@
variable $path
upvar 0 $path data
- if { [lsearch $data(pages) $page] != -1 } {
+ if { [lsearch -exact $data(pages) $page] != -1 } {
return -code error "page \"$page\" already exists"
}
- Widget::init NoteBook::Page $path.f$page $args
+ if {![info exists data(frame,$page)]} {
+ set counter 0
+ while {[winfo exists $path.f$counter]} {
+ incr counter
+ }
+ set data(frame,$page) $path.f$counter
+ }
+ Widget::init NoteBook::Page [getframe $path $page] $args
set data(pages) [linsert $data(pages) $index $page]
# If the page doesn't exist, create it; if it does reset its bg and ibd
- if { ![winfo exists $path.f$page] } {
- frame $path.f$page \
+ if { ![winfo exists [getframe $path $page]] } {
+ frame [getframe $path $page] \
-relief flat \
-background [Widget::cget $path -background] \
-borderwidth [Widget::cget $path -internalborderwidth]
set data($page,realized) 0
} else {
- $path.f$page configure \
+ [getframe $path $page] configure \
-background [Widget::cget $path -background] \
-borderwidth [Widget::cget $path -internalborderwidth]
}
@@ -277,7 +284,7 @@
_draw_page $path $page 1
_redraw $path
- return $path.f$page
+ return [getframe $path $page]
}
@@ -299,7 +306,8 @@
incr data(base) -1
}
if { $destroyframe } {
- destroy $path.f$page
+ destroy [getframe $path $page]
+ unset data(frame,$page)
}
_redraw $path
}
@@ -322,7 +330,7 @@
# ---------------------------------------------------------------------------
proc NoteBook::itemcget { path page option } {
_test_page $path $page
- return [Widget::cget $path.f$page $option]
+ return [Widget::cget [getframe $path $page] $option]
}
@@ -435,7 +443,7 @@
variable $path
upvar 0 $path data
- return [lsearch $data(pages) $page]
+ return [lsearch -exact $data(pages) $page]
}
@@ -447,7 +455,7 @@
upvar 0 $path data
foreach page $data(pages) {
- Widget::destroy $path.f$page
+ Widget::destroy [getframe $path $page]
}
Widget::destroy $path
unset data
@@ -459,7 +467,10 @@
# Command NoteBook::getframe
# ---------------------------------------------------------------------------
proc NoteBook::getframe { path page } {
- return $path.f$page
+ variable $path
+ upvar 0 $path data
+
+ return $data(frame,$page)
}
@@ -470,14 +481,14 @@
variable $path
upvar 0 $path data
- if { [set pos [lsearch $data(pages) $page]] == -1 } {
- return -code error "page \"$page\" does not exists"
+ if { [set pos [lsearch -exact $data(pages) $page]] == -1 } {
+ return -code error "page \"$page\" does not exist"
}
return $pos
}
proc NoteBook::_getoption { path page option } {
- set value [Widget::cget $path.f$page $option]
+ set value [Widget::cget [getframe $path $page] $option]
if {![string length $value]} {
set value [Widget::cget $path $option]
}
@@ -491,14 +502,14 @@
variable $path
upvar 0 $path data
- set res [Widget::configure $path.f$page $lres]
- if { [Widget::hasChanged $path.f$page -text foo] } {
+ set res [Widget::configure [getframe $path $page] $lres]
+ if { [Widget::hasChanged [getframe $path $page] -text foo] } {
_compute_width $path
- } elseif { [Widget::hasChanged $path.f$page -image foo] } {
+ } elseif { [Widget::hasChanged [getframe $path $page] -image foo] } {
set data(hpage) [expr {[font metrics [Widget::cget $path -font] -linespace] + 6}]
_compute_width $path
}
- if { [Widget::hasChanged $path.f$page -state state] &&
+ if { [Widget::hasChanged [getframe $path $page] -state state] &&
$state == "disabled" && $data(select) == $page } {
set data(select) ""
}
@@ -523,14 +534,14 @@
set id $data(textid)
$path.c itemconfigure $id -font $font
foreach page $data(pages) {
- $path.c itemconfigure $id -text [Widget::cget $path.f$page -text]
+ $path.c itemconfigure $id -text [Widget::cget [getframe $path $page] -text]
# Get the bbox for this text to determine its width, then substract
# 6 from the width to account for canvas bbox oddness w.r.t. widths of
# simple text.
foreach {x1 y1 x2 y2} [$path.c bbox $id] break
set x2 [expr {$x2 - 6}]
set wtext [expr {$x2 - $x1 + 20}]
- if { [set img [Widget::cget $path.f$page -image]] != "" } {
+ if { [set img [Widget::cget [getframe $path $page] -image]] != "" } {
set wtext [expr {$wtext+[image width $img]+4}]
set himg [expr {[image height $img]+6}]
if { $himg > $hmax } {
@@ -607,7 +618,7 @@
variable $path
upvar 0 $path data
- if { ![string compare [Widget::cget $path.f$page -state] "disabled"] } {
+ if { ![string compare [Widget::cget [getframe $path $page] -state] "disabled"] } {
return
}
@@ -635,11 +646,11 @@
variable $path
upvar 0 $path data
- if { ![string compare [Widget::cget $path.f$page -state] "normal"] } {
+ if { ![string compare [Widget::cget [getframe $path $page] -state] "normal"] } {
set oldsel $data(select)
if { [string compare $page $oldsel] } {
if { ![string equal $oldsel ""] } {
- set cmd [Widget::cget $path.f$oldsel -leavecmd]
+ set cmd [Widget::cget [getframe $path $oldsel] -leavecmd]
if { ![string equal $cmd ""] } {
set code [catch {uplevel \#0 $cmd} res]
if { $code == 1 || $res == 0 } {
@@ -653,12 +664,12 @@
if { ![string equal $page ""] } {
if { !$data($page,realized) } {
set data($page,realized) 1
- set cmd [Widget::cget $path.f$page -createcmd]
+ set cmd [Widget::cget [getframe $path $page] -createcmd]
if { ![string equal $cmd ""] } {
uplevel \#0 $cmd
}
}
- set cmd [Widget::cget $path.f$page -raisecmd]
+ set cmd [Widget::cget [getframe $path $page] -raisecmd]
if { ![string equal $cmd ""] } {
uplevel \#0 $cmd
}
@@ -697,7 +708,7 @@
upvar 0 $path data
# --- calcul des coordonnees et des couleurs de l'onglet ------------------
- set pos [lsearch $data(pages) $page]
+ set pos [lsearch -exact $data(pages) $page]
set bg [_getoption $path $page -background]
# lookup the tab colors
@@ -793,7 +804,7 @@
]
}
- set img [Widget::cget $path.f$page -image]
+ set img [Widget::cget [getframe $path $page] -image]
set ytext $top
if { $tabsOnBottom } {
@@ -820,7 +831,7 @@
set fg [_getoption $path $page -foreground]
} else {
set bd 1
- if { [Widget::cget $path.f$page -state] == "normal" } {
+ if { [Widget::cget [getframe $path $page] -state] == "normal" } {
set fg [_getoption $path $page -foreground]
} else {
set fg [_getoption $path $page -disabledforeground]
@@ -841,7 +852,7 @@
eval [list $path.c create line] $lb [list \
-tags [list page p:$page $page:bot bot] -fill $fgb -width $bd]
$path.c create text $xtext $ytext \
- -text [Widget::cget $path.f$page -text] \
+ -text [Widget::cget [getframe $path $page] -text] \
-font [Widget::cget $path -font] \
-fill $fg \
-anchor nw \
@@ -857,7 +868,7 @@
$path.c coords "$page:text" $xtext $ytext
$path.c itemconfigure "$page:text" \
- -text [Widget::cget $path.f$page -text] \
+ -text [Widget::cget [getframe $path $page] -text] \
-font [Widget::cget $path -font] \
-fill $fg
}
@@ -1002,7 +1013,7 @@
set xf $xd
set lbg $data(dbg)
} else {
- set xd [_get_x_page $path [lsearch $data(pages) $data(select)]]
+ set xd [_get_x_page $path [lsearch -exact $data(pages) $data(select)]]
set xf [expr {$xd + $data($sel,width) + $arcRadius + 1}]
set lbg $data(lbg)
}
@@ -1042,13 +1053,13 @@
-height [expr {$yo-3}] \
-anchor nw \
-tags "window" \
- -window $path.f$sel
+ -window [getframe $path $sel]
}
$path.c coords "window" 2 [expr {$y0+1}]
$path.c itemconfigure "window" \
-width [expr {$w-3}] \
-height [expr {$yo-3}] \
- -window $path.f$sel
+ -window [getframe $path $sel]
# Sven end
} else {
$path.c delete "window"