Ignore:
Timestamp:
Mar 18, 2009, 2:59:21 PM (16 years ago)
Author:
gah
Message:

preliminary HQ output from molvisviewer; unexpand tabs; all jpeg generation at 100%

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/gui/scripts/notebook.tcl

    r115 r1342  
    4141    private variable _current ""    ;# page currently shown
    4242}
    43                                                                                
     43                                                                               
    4444itk::usual Notebook {
    4545    keep -background -cursor
     
    6969    set rlist ""
    7070    foreach name $args {
    71         if {[lsearch $_pages $name] >= 0} {
    72             error "page \"$name\" already exists"
    73         }
    74         set pname "page[incr _count]"
    75         itk_component add $pname {
    76             frame $itk_interior.$pname
    77         }
    78         set _pages [linsert $_pages $pos $name]
    79         set _name2page($name) $itk_component($pname)
    80 
    81         bind $itk_component($pname) <Configure> \
    82             [itcl::code $_dispatcher event -after 100 !fixsize]
    83 
    84         lappend rlist $itk_component($pname)
     71        if {[lsearch $_pages $name] >= 0} {
     72            error "page \"$name\" already exists"
     73        }
     74        set pname "page[incr _count]"
     75        itk_component add $pname {
     76            frame $itk_interior.$pname
     77        }
     78        set _pages [linsert $_pages $pos $name]
     79        set _name2page($name) $itk_component($pname)
     80
     81        bind $itk_component($pname) <Configure> \
     82            [itcl::code $_dispatcher event -after 100 !fixsize]
     83
     84        lappend rlist $itk_component($pname)
    8585    }
    8686    return $rlist
     
    9898itcl::body Rappture::Notebook::delete {args} {
    9999    if {$args == "-all"} {
    100         set args $_pages
     100        set args $_pages
    101101    }
    102102    foreach name $args {
    103         set i [index $name]
    104         set pname [lindex $_pages $i]
    105         if {$pname != ""} {
    106             set _pages [lreplace $_pages $i $i]
    107             destroy $_name2page($pname)
    108             unset _name2page($pname)
    109         }
     103        set i [index $name]
     104        set pname [lindex $_pages $i]
     105        if {$pname != ""} {
     106            set _pages [lreplace $_pages $i $i]
     107            destroy $_name2page($pname)
     108            unset _name2page($pname)
     109        }
    110110    }
    111111}
     
    119119    set i [lsearch $_pages $name]
    120120    if {$i >= 0} {
    121         return $i
     121        return $i
    122122    }
    123123    if {[regexp {^@([0-9]+)$} $name match i]} {
    124         return $i
     124        return $i
    125125    }
    126126    error "bad page name \"$name\": should be @int or one of [join [lsort $_pages] {, }]"
     
    148148itcl::body Rappture::Notebook::current {args} {
    149149    switch -- [llength $args] {
    150         0 {
    151             return $_current
    152         }
    153         1 {
    154             set name [lindex $args 0]
    155             set index 0
    156             if {$name == "next>"} {
    157                 if {$_current == ""} {
    158                     set index 0
    159                 } else {
    160                     set i [lsearch -exact $_pages $_current]
    161                     set index [expr {$i+1}]
    162                     if {$index >= [llength $_pages]} {
    163                         set index [expr {[llength $_pages]-1}]
    164                     }
    165                 }
    166             } elseif {$name == "<back"} {
    167                 if {$_current == ""} {
    168                     set index end
    169                 } else {
    170                     set i [lsearch -exact $_pages $_current]
    171                     set index [expr {$i-1}]
    172                     if {$index < 0} {
    173                         set index 0
    174                     }
    175                 }
    176             } else {
    177                 set index [lsearch -exact $_pages $name]
    178                 if {$index < 0} {
    179                     error "can't move to page \"$name\""
    180                 }
    181             }
    182 
    183             set _current [lindex $_pages $index]
    184 
    185             foreach w [pack slaves $itk_component(hull)] {
    186                 pack forget $w
    187             }
    188             pack $_name2page($_current) -expand yes -fill both
    189         }
    190         default {
    191             error "wrong # args: should be \"current name|next>|<back\""
    192         }
     150        0 {
     151            return $_current
     152        }
     153        1 {
     154            set name [lindex $args 0]
     155            set index 0
     156            if {$name == "next>"} {
     157                if {$_current == ""} {
     158                    set index 0
     159                } else {
     160                    set i [lsearch -exact $_pages $_current]
     161                    set index [expr {$i+1}]
     162                    if {$index >= [llength $_pages]} {
     163                        set index [expr {[llength $_pages]-1}]
     164                    }
     165                }
     166            } elseif {$name == "<back"} {
     167                if {$_current == ""} {
     168                    set index end
     169                } else {
     170                    set i [lsearch -exact $_pages $_current]
     171                    set index [expr {$i-1}]
     172                    if {$index < 0} {
     173                        set index 0
     174                    }
     175                }
     176            } else {
     177                set index [lsearch -exact $_pages $name]
     178                if {$index < 0} {
     179                    error "can't move to page \"$name\""
     180                }
     181            }
     182
     183            set _current [lindex $_pages $index]
     184
     185            foreach w [pack slaves $itk_component(hull)] {
     186                pack forget $w
     187            }
     188            pack $_name2page($_current) -expand yes -fill both
     189        }
     190        default {
     191            error "wrong # args: should be \"current name|next>|<back\""
     192        }
    193193    }
    194194}
     
    204204itcl::body Rappture::Notebook::_fixSize {} {
    205205    if {$itk_option(-width) <= 0} {
    206         set maxw 0
    207         foreach name $_pages {
    208             set w [winfo reqwidth $_name2page($name)]
    209             if {$w > $maxw} { set maxw $w }
    210         }
    211         component hull configure -width $maxw
     206        set maxw 0
     207        foreach name $_pages {
     208            set w [winfo reqwidth $_name2page($name)]
     209            if {$w > $maxw} { set maxw $w }
     210        }
     211        component hull configure -width $maxw
    212212    } else {
    213         component hull configure -width $itk_option(-width)
     213        component hull configure -width $itk_option(-width)
    214214    }
    215215
    216216    if {$itk_option(-height) <= 0} {
    217         set maxh 0
    218         foreach name $_pages {
    219             set h [winfo reqheight $_name2page($name)]
    220             if {$h > $maxh} { set maxh $h }
    221         }
    222         component hull configure -height $maxh
     217        set maxh 0
     218        foreach name $_pages {
     219            set h [winfo reqheight $_name2page($name)]
     220            if {$h > $maxh} { set maxh $h }
     221        }
     222        component hull configure -height $maxh
    223223    } else {
    224         component hull configure -height $itk_option(-height)
     224        component hull configure -height $itk_option(-height)
    225225    }
    226226}
Note: See TracChangeset for help on using the changeset viewer.