⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 notebook.tcl

📁 是TCL的另外一个编译(解释)器
💻 TCL
📖 第 1 页 / 共 3 页
字号:
# ------------------------------------------------------------------------------#  notebook.tcl#  This file is part of Unifix BWidget Toolkit#  $Id: notebook.tcl,v 1.14 2002/04/25 18:11:22 andreas_kupries Exp $# ------------------------------------------------------------------------------#  Index of commands:#     - NoteBook::create#     - NoteBook::configure#     - NoteBook::cget#     - NoteBook::compute_size#     - NoteBook::insert#     - NoteBook::delete#     - NoteBook::itemconfigure#     - NoteBook::itemcget#     - NoteBook::bindtabs#     - NoteBook::raise#     - NoteBook::see#     - NoteBook::page#     - NoteBook::pages#     - NoteBook::index#     - NoteBook::getframe#     - NoteBook::_test_page#     - NoteBook::_itemconfigure#     - NoteBook::_compute_width#     - NoteBook::_get_x_page#     - NoteBook::_xview#     - NoteBook::_highlight#     - NoteBook::_select#     - NoteBook::_redraw#     - NoteBook::_draw_page#     - NoteBook::_draw_arrows#     - NoteBook::_draw_area#     - NoteBook::_resize#     - NoteBook::_realize# ------------------------------------------------------------------------------namespace eval NoteBook {    ArrowButton::use    namespace eval Page {        Widget::declare NoteBook::Page {            {-state      Enum       normal 0 {normal disabled}}            {-createcmd  String     ""     0}            {-raisecmd   String     ""     0}            {-leavecmd   String     ""     0}            {-image      TkResource ""     0 label}            {-text       String     ""     0}            {-foreground         String     ""     0}            {-background         String     ""     0}            {-activeforeground   String     ""     0}            {-activebackground   String     ""     0}            {-disabledforeground String     ""     0}        }    }    Widget::bwinclude NoteBook ArrowButton .c.fg \	    include {-foreground -background -activeforeground \		-activebackground -disabledforeground -repeatinterval \		-repeatdelay -borderwidth} \	    initialize {-borderwidth 1}    Widget::bwinclude NoteBook ArrowButton .c.fd \	    include {-foreground -background -activeforeground \		-activebackground -disabledforeground -repeatinterval \		-repeatdelay -borderwidth} \	    initialize {-borderwidth 1}    Widget::declare NoteBook {	{-foreground		TkResource "" 0 button}        {-background		TkResource "" 0 button}        {-activebackground	TkResource "" 0 button}        {-activeforeground	TkResource "" 0 button}        {-disabledforeground	TkResource "" 0 button}        {-font			TkResource "" 0 button}        {-side			Enum       top 0 {top bottom}}        {-homogeneous		Boolean 0   0}        {-borderwidth		Int 1   0 "%d >= 1 && %d <= 2"} 	{-internalborderwidth	Int 10  0 "%d >= 0"}        {-width			Int 0   0 "%d >= 0"}        {-height		Int 0   0 "%d >= 0"}        {-repeatdelay        BwResource ""  0 ArrowButton}        {-repeatinterval     BwResource ""  0 ArrowButton}        {-fg                 Synonym -foreground}        {-bg                 Synonym -background}        {-bd                 Synonym -borderwidth}        {-ibd                Synonym -internalborderwidth}	{-arcradius             Int 2   0 "%d >= 0 && %d <= 8"}	{-tabbevelsize          Int 0   0 "%d >= 0 && %d <= 8"}    }    Widget::addmap NoteBook "" .c {-background {}}    variable _warrow 12    proc ::NoteBook { path args } { return [eval NoteBook::create $path $args] }    proc use {} {}}# ------------------------------------------------------------------------------#  Command NoteBook::create# ------------------------------------------------------------------------------proc NoteBook::create { path args } {    variable $path    upvar 0  $path data    Widget::init NoteBook $path $args    set font [Widget::cget $path -font]    set data(base)     0    set data(select)   ""    set data(pages)    {}    set data(pages)    {}    set data(cpt)      0    set data(realized) 0    set data(wpage)    0    set data(hpage)    [expr {[font metrics $font -linespace] + 6}]    # Create the canvas    set w [expr {[Widget::cget $path -width]+4}]    set h [expr {[Widget::cget $path -height]+$data(hpage)+4}]    frame $path -class NoteBook -borderwidth 0 -highlightthickness 0 \	    -relief flat    eval canvas $path.c			\	    [Widget::subcget $path .c] \	    -relief flat		\	    -borderwidth 0		\	    -highlightthickness 0	\	    -width $w			\	    -height $h    pack $path.c -expand yes -fill both    # Removing the Canvas global bindings from our canvas as    # application specific bindings on that tag may interfere with its    # operation here. [SF item #459033]    set bindings [bindtags $path.c]    set pos [lsearch -exact $bindings Canvas]    if {$pos >= 0} {	set bindings [lreplace $bindings $pos $pos]    }    bindtags $path.c $bindings    # Create the arrow button    eval ArrowButton::create $path.c.fg [Widget::subcget $path .c.fg] \        -highlightthickness 0 \        -type button  -dir left \        -armcommand [list "NoteBook::_xview $path -1"]    eval ArrowButton::create $path.c.fd [Widget::subcget $path .c.fd] \        -highlightthickness 0 \        -type button  -dir right \        -armcommand [list "NoteBook::_xview $path 1"]    bind $path <Configure> "NoteBook::_realize $path"    bind $path <Destroy>   "NoteBook::_destroy $path"    rename $path ::$path:cmd    proc ::$path { cmd args } "return \[eval NoteBook::\$cmd $path \$args\]"    set bg [Widget::cget $path -background]    foreach {data(dbg) data(lbg)} [BWidget::get3dcolor $path $bg] {break}    return $path}# ------------------------------------------------------------------------------#  Command NoteBook::configure# ------------------------------------------------------------------------------proc NoteBook::configure { path args } {    variable $path    upvar 0  $path data    set res [Widget::configure $path $args]    set redraw 0    if { [set chf [Widget::hasChanged $path -font font]] ||         [Widget::hasChanged $path -homogeneous foo] } {        if { $chf } {            set data(hpage) [expr {[font metrics $font -linespace] + 6}]        }        _compute_width $path        set redraw 1    }    set chibd [Widget::hasChanged $path -internalborderwidth ibd]    set chbg  [Widget::hasChanged $path -background bg]    if {$chibd || $chbg} {        foreach page $data(pages) {            $path.f$page configure \                -borderwidth $ibd -background $bg        }    }    if {$chbg} {        set col [BWidget::get3dcolor $path $bg]        set data(dbg)  [lindex $col 0]        set data(lbg)  [lindex $col 1]        set redraw 1    }    if { [Widget::hasChanged $path -foreground  fg] ||         [Widget::hasChanged $path -borderwidth bd] ||	 [Widget::hasChanged $path -arcradius radius] ||         [Widget::hasChanged $path -tabbevelsize bevel] ||         [Widget::hasChanged $path -side side] } {        set redraw 1    }    set wc [Widget::hasChanged $path -width  w]    set hc [Widget::hasChanged $path -height h]    if { $wc || $hc } {        $path.c configure \		-width [expr {$w+4}] \		-height [expr {$h + $data(hpage)+4}]    }    if { $redraw } {        _redraw $path    }    return $res}# ------------------------------------------------------------------------------#  Command NoteBook::cget# ------------------------------------------------------------------------------proc NoteBook::cget { path option } {    return [Widget::cget $path $option]}# ------------------------------------------------------------------------------#  Command NoteBook::compute_size# ------------------------------------------------------------------------------proc NoteBook::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    # Sven... well ok so this is called twice in some cases...    NoteBook::_redraw $path    # Sven end}# ------------------------------------------------------------------------------#  Command NoteBook::insert# ------------------------------------------------------------------------------proc NoteBook::insert { path index page args } {    variable $path    upvar 0  $path data    if { [lsearch $data(pages) $page] != -1 } {        return -code error "page \"$page\" already exists"    }    Widget::init NoteBook::Page $path.f$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 						\		-relief flat						\		-background	[Widget::cget $path -background]	\		-borderwidth	[Widget::cget $path -internalborderwidth]        set data($page,realized) 0    } else {	$path.f$page configure						\		-background	[Widget::cget $path -background]	\		-borderwidth	[Widget::cget $path -internalborderwidth]    }    _compute_width $path    _draw_page $path $page 1    _redraw $path    return $path.f$page}# ------------------------------------------------------------------------------#  Command NoteBook::delete# ------------------------------------------------------------------------------proc NoteBook::delete { path page {destroyframe 1} } {    variable $path    upvar 0  $path data    set pos [_test_page $path $page]    set data(pages) [lreplace $data(pages) $pos $pos]    _compute_width $path    $path.c delete p:$page    if { $data(select) == $page } {        set data(select) ""    }    if { $pos < $data(base) } {        incr data(base) -1    }    if { $destroyframe } {        destroy $path.f$page    }    _redraw $path}# ------------------------------------------------------------------------------#  Command NoteBook::itemconfigure# ------------------------------------------------------------------------------proc NoteBook::itemconfigure { path page args } {    _test_page $path $page    set res [_itemconfigure $path $page $args]    _redraw $path    return $res}# ------------------------------------------------------------------------------#  Command NoteBook::itemcget# ------------------------------------------------------------------------------proc NoteBook::itemcget { path page option } {    _test_page $path $page    return [Widget::cget $path.f$page $option]}# ------------------------------------------------------------------------------#  Command NoteBook::bindtabs# ------------------------------------------------------------------------------proc NoteBook::bindtabs { path event script } {    if { $script != "" } {        $path.c bind "page" $event \            "$script \[string range \[lindex \[$path.c gettags current\] 1\] 2 end\]"    } else {        $path.c bind "page" $event {}    }}# ------------------------------------------------------------------------------#  Command NoteBook::move# ------------------------------------------------------------------------------proc NoteBook::move { path page index } {    variable $path    upvar 0  $path data    set pos [_test_page $path $page]    set data(pages) [linsert [lreplace $data(pages) $pos $pos] $index $page]    _redraw $path}# ------------------------------------------------------------------------------#  Command NoteBook::raise

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -