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

📄 tabset.itk

📁 windows下的GDB insight前端
💻 ITK
📖 第 1 页 / 共 5 页
字号:
    }    return ""}# ----------------------------------------------------------------------# METHOD: bbox# # calculates the bounding box that will completely enclose # all the tabs.# ----------------------------------------------------------------------itcl::body iwidgets::Tabset::bbox {} {    return [_tabBounds]}# ----------------------------------------------------------------------# PROTECTED METHOD: _selectName## internal method to allow selection by internal tab name # rather than index. This is used by the bind methods# ----------------------------------------------------------------------itcl::body iwidgets::Tabset::_selectName {tabName} {    # if the tab is disabled, then ignore this selection...    if { [$tabName cget -state] == "disabled" } {    return    }        set tab [lsearch -exact $_tabs $tabName]    select $tab}# ----------------------------------------------------------------------# PRIVATE METHOD: _createTab## Creates a tab, using unique tab naming, propagates background# and keeps unique id up to date.# ----------------------------------------------------------------------itcl::body iwidgets::Tabset::_createTab {args} {    #    # create an internal name for the tab: tab0, tab1, etc.    # these are one-up numbers they do not     # correspond to the position the tab is located in.    #    set tabName $this-tab$_uniqueID        switch $itk_option(-tabpos) {    n {        set invert true        set orient horizontal        set x 0        set y [expr {$_margin + 1}]    }    s {        set invert false        set orient horizontal        set x 0        set y 0    }    w {        set invert false        set orient vertical        set x 0         set y 0    }    e {        set invert true        set orient vertical        set x [expr {$_margin + 1}]        set y 0    }    default {        error "bad anchor position\            \"$itk_option(-tabpos)\" must be n, s, e, or w"    }    }        eval iwidgets::Tab $tabName $itk_component(canvas) \        -left             $x \        -top              $y \        -font             [list $itk_option(-font)] \        -background       $itk_option(-background) \        -foreground       $itk_option(-foreground) \        -selectforeground $itk_option(-selectforeground) \        -disabledforeground $itk_option(-disabledforeground) \        -selectbackground $itk_option(-selectbackground) \        -angle            $itk_option(-angle) \        -padx             $itk_option(-padx) \        -pady             $itk_option(-pady) \        -bevelamount      $itk_option(-bevelamount) \        -state            $itk_option(-state) \        -tabborders       $itk_option(-tabborders) \        -invert           $invert \        -orient           $orient \        $args        $tabName lower        $itk_component(canvas) \        bind $tabName <Button-1> [itcl::code $this _selectName $tabName]        incr _uniqueID        return $tabName}# ----------------------------------------------------------------------# PRIVATE METHOD: _deleteTabs## Deletes tabs from $fromTab to $toTab.## Operates in two passes, destroys all the widgets# Then removes the pathName from the tab list## Also keeps the current selection in bounds.# ----------------------------------------------------------------------itcl::body iwidgets::Tabset::_deleteTabs {fromTab toTab} {    for { set tab $fromTab } { $tab <= $toTab } { incr tab } {    set tabName [lindex $_tabs $tab]        # unbind Button-1 from this window name    $itk_component(canvas) bind $tabName <Button-1> {}        # Destroy the Tab class...    itcl::delete object $tabName     }        # physically remove the tab    set _tabs [lreplace $_tabs $fromTab $toTab]        # If we deleted a selected tab set our selection to none    if { $_currTab >= $fromTab && $_currTab <= $toTab } {    set _currTab -1    _drawBevelBorder    }        # make sure _currTab stays in sync with new numbering...    if { $_tabs == {} } {    # if deleted only remaining tab,    # reset current tab to undefined    set _currTab -1        # or if the current tab was the last tab, it needs come back    } elseif { $_currTab >= [llength $_tabs] } {    incr _currTab -1    if { $_currTab < 0 } {        # but only to zero        set _currTab 0    }    }        _relayoutTabs}# ----------------------------------------------------------------------# PRIVATE METHOD: _index## pathList : list of path names to search thru if index is a label# index    : either number, 'select', 'end', or pattern# select   : current selection## _index takes takes the value $index converts it to# a numeric identifier. If the value is not already# an integer it looks it up in the $pathList array.# If it fails it returns -1# ----------------------------------------------------------------------itcl::body iwidgets::Tabset::_index {pathList index select} {    switch $index {    select {        set number $select    }    end {        set number [expr {[llength $pathList] -1}]    }    default {        # is it an number already?        if { [regexp {^[0-9]+$} $index] } {        set number $index        if { $number < 0 || $number >= [llength $pathList] } {            set number -1        }                # otherwise it is a label        } else {        # look thru the pathList of pathNames and        # get each label and compare with index.        # if we get a match then set number to postion in $pathList        # and break out.        # otherwise number is still -1        set i 0        set number -1        foreach pathName $pathList {            set label [$pathName cget -label]            if { $label == $index } {            set number $i            break            }            incr i        }        }    }    }        return $number}# ----------------------------------------------------------------------# PRIVATE METHOD: _tabConfigure# ----------------------------------------------------------------------itcl::body iwidgets::Tabset::_tabConfigure {args} {    foreach tab $_tabs {    eval $tab configure $args    }        set _relayout true        if { $_tabs != {} } {    select select    }}# ----------------------------------------------------------------------# PRIVATE METHOD: _relayoutTabs# # relays out the tabs with correct spacing...# ----------------------------------------------------------------------itcl::body iwidgets::Tabset::_relayoutTabs {} {    if { [llength $_tabs] == 0 || ![winfo viewable $itk_component(hull)]} {    return    }        # get the max width for fixed width tabs...    set maxWidth 0    foreach tab $_tabs {    set width [$tab labelwidth]    if { $width > $maxWidth } {        set maxWidth $width    }    }        # get the max height for fixed height tabs...    set maxHeight 0    foreach tab $_tabs {    set height [$tab labelheight]    if { $height > $maxHeight } {        set maxHeight $height    }    }        # get curr tab's name    set currTabName [lindex $_tabs $_currTab]        # Start with our margin offset in pixels...    set tabStart $_start        if { $itk_option(-raiseselect) } {    set raiseAmt 2    } else {    set raiseAmt 0    }        #    # Depending on the tab layout: n, s, e, or w place the tabs    # according to orientation, raise, margins, etc.    #    switch $itk_option(-tabpos) {    n {        set _selectedTop [expr {$_margin + 1}]        set _deselectedTop [expr {$_selectedTop + $raiseAmt}]                if { $itk_option(-equaltabs) } {        set tabWidth $maxWidth        } else {        set tabWidth 0        }                foreach tab $_tabs {        if { $tab == $currTabName } {            $tab configure -left $tabStart -top $_selectedTop \                -height $maxHeight -width $tabWidth -anchor c        } else {            $tab configure -left $tabStart -top $_deselectedTop \                -height $maxHeight -width $tabWidth -anchor c        }        set tabStart [expr {$tabStart + [_calcNextTabOffset $tab]}]        }            }    s {        set _selectedTop 0        set _deselectedTop [expr {$_selectedTop - $raiseAmt}]                if { $itk_option(-equaltabs) } {        set tabWidth $maxWidth        } else {        set tabWidth 0        }                foreach tab $_tabs {        if { $tab == $currTabName } {            $tab configure -left $tabStart -top $_selectedTop \                -height $maxHeight -width $tabWidth -anchor c        } else {            $tab configure -left $tabStart -top $_deselectedTop \                -height $maxHeight -width $tabWidth -anchor c        }        set tabStart [expr {$tabStart + [_calcNextTabOffset $tab]}]        }            }    w {        set _selectedLeft [expr {$_margin + 1}]        set _deselectedLeft [expr {$_selectedLeft + $raiseAmt}]                if { $itk_option(-equaltabs) } {        set tabHeight $maxHeight        } else {        set tabHeight 0        }                foreach tab $_tabs {        # selected        if { $tab == $currTabName } {            $tab configure -top $tabStart -left $_selectedLeft \                -height $tabHeight -width $maxWidth -anchor e            # deselected        } else {            $tab configure -top $tabStart -left $_deselectedLeft \                -height $tabHeight -width $maxWidth -anchor e        }        set tabStart [expr {$tabStart + [_calcNextTabOffset $tab]}]        }            }    e {        set _selectedLeft 0        set _deselectedLeft [expr {$_selectedLeft - $raiseAmt}]                if { $itk_option(-equaltabs) } {        set tabHeight $maxHeight        } else {        set tabHeight 0        }                foreach tab $_tabs {        # selected        if { $tab == $currTabName } {            $tab configure -top $tabStart -left $_selectedLeft \                -height $tabHeight -width $maxWidth -anchor w            # deselected        } else {            $tab configure -top $tabStart -left $_deselectedLeft \                -height $tabHeight -width $maxWidth -anchor w        }        set tabStart [expr {$tabStart + [_calcNextTabOffset $tab]}]        }            }    default {        error "bad anchor position\            \"$itk_option(-tabpos)\" must be n, s, e, or w"    }    }        # put border on & calc our new canvas size...    _drawBevelBorder    _recalcCanvasGeom    }# ----------------------------------------------------------------------# PRIVATE METHOD: _drawBevelBorder# # draws the bevel border along tab edge (below selected tab)# ----------------------------------------------------------------------itcl::body iwidgets::Tabset::_drawBevelBorder {} {    $itk_component(canvas) delete bevelBorder        switch $itk_option(-tabpos) {    n {        $itk_component(canvas) create line \            0 [expr {$_canvasHeight - 1}] \            $_canvasWidth [expr {$_canvasHeight - 1}] \            -fill [iwidgets::colors::topShadow $itk_option(-selectbackground)] \            -tags bevelBorder        $itk_component(canvas) create line \            0 $_canvasHeight \            $_canvasWidth $_canvasHeight \            -fill [iwidgets::colors::topShadow $itk_option(-selectbackground)] \            -tags bevelBorder    }    s {        $itk_component(canvas) create line \            0 0 \            $_canvasWidth 0 \            -fill [iwidgets::colors::bottomShadow $itk_option(-selectbackground)] \            -tags bevelBorder        $itk_component(canvas) create line \            0 1 \            $_canvasWidth 1 \            -fill black \            -tags bevelBorder    }    w {        $itk_component(canvas) create line \            $_canvasWidth 0 \            $_canvasWidth [expr {$_canvasHeight - 1}] \            -fill [iwidgets::colors::topShadow $itk_option(-selectbackground)] \            -tags bevelBorder        $itk_component(canvas) create line \

⌨️ 快捷键说明

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