📄 tabset.itk
字号:
set _configTripped true}# ----------------------------------------------------------------------# OPTION -padx## Horizontal padding around the label (text, image, or bitmap).# ----------------------------------------------------------------------configbody iwidgets::Tab::padx { set _configTripped true set _padX [winfo pixels $_canvas $padx]}# ----------------------------------------------------------------------# OPTION -pady## Vertical padding around the label (text, image, or bitmap).# ----------------------------------------------------------------------configbody iwidgets::Tab::pady { set _configTripped true set _padY [winfo pixels $_canvas $pady]}# ----------------------------------------------------------------------# OPTION -selectbackground# ----------------------------------------------------------------------configbody iwidgets::Tab::selectbackground { set _darkShadow [iwidgets::colors::bottomShadow $selectbackground] set _lightShadow [iwidgets::colors::topShadow $selectbackground] if { $_selected } { _selectNoRaise } else { _deselectNoLower }}# ----------------------------------------------------------------------# OPTION -selectforeground## Foreground of tab when selected# ----------------------------------------------------------------------configbody iwidgets::Tab::selectforeground { if { $_selected } { _selectNoRaise } else { _deselectNoLower }}# ----------------------------------------------------------------------# OPTION -disabledforeground## Background of tab when -state is disabled# ----------------------------------------------------------------------configbody iwidgets::Tab::disabledforeground { if { $_selected } { _selectNoRaise } else { _deselectNoLower }}# ----------------------------------------------------------------------# OPTION -background## Normal background of tab.# ----------------------------------------------------------------------configbody iwidgets::Tab::background { if { $_selected } { _selectNoRaise } else { _deselectNoLower } }# ----------------------------------------------------------------------# OPTION -foreground## Foreground of tabs when in normal unselected state# ----------------------------------------------------------------------configbody iwidgets::Tab::foreground { if { $_selected } { _selectNoRaise } else { _deselectNoLower }}# ----------------------------------------------------------------------# OPTION -orient## Specifies the orientation of the tab. Orient can be either # horizontal or vertical. # ----------------------------------------------------------------------configbody iwidgets::Tab::orient { set _configTripped true}# ----------------------------------------------------------------------# OPTION -invert## Specifies the direction to draw the tab. If invert is true, # it draws horizontal tabs upside down and vertical tabs opening # to the left (pointing right). The value may have any of the # forms accepted by the Tcl_GetBoolean, such as true, # false, 0, 1, yes, or no.# ----------------------------------------------------------------------configbody iwidgets::Tab::invert { set _configTripped true}# ----------------------------------------------------------------------# OPTION -angle## Specifes the angle of slope from the inner edge to the outer edge # of the tab. An angle of 0 specifies square tabs. Valid ranges are # 0 to 45 degrees inclusive. Default is 15 degrees. If this option # is specified as an empty string (the default), then the angle # option for the overall Tabset is used.# ----------------------------------------------------------------------configbody iwidgets::Tab::angle { if {$angle < 0 || $angle > 45 } { error "bad angle: must be between 0 and 45" } set _configTripped true}# ----------------------------------------------------------------------# OPTION -font## Font for tab text.# ----------------------------------------------------------------------configbody iwidgets::Tab::font { }# ----------------------------------------------------------------------# OPTION -tabborders## Specifies whether to draw the borders of a deselected tab. # Specifying true (the default) draws these borders, # specifying false disables this drawing. If the tab is in # its selected state this option has no effect. # The value may have any of the forms accepted by the # Tcl_GetBoolean, such as true, false, 0, 1, yes, or no.# ----------------------------------------------------------------------configbody iwidgets::Tab::tabborders { set _configTripped true}# ----------------------------------------------------------------------# METHOD: configure ?option value?## Configures the Tab, checks a configTripped flag to see if the tab# needs to be remade. We take the easy way since it is so inexpensive# to delete canvas items and remake them.# ----------------------------------------------------------------------body iwidgets::Tab::configure {args} { set len [llength $args] switch $len { 0 { set result [_itk_config] return $result } 1 { set result [eval _itk_config $args] return $result } default { eval _itk_config $args if { $_configTripped } { _makeTab set _configTripped false } return "" } }}# ----------------------------------------------------------------------# METHOD: bbox## Returns the bounding box of the tab# ----------------------------------------------------------------------body iwidgets::Tab::bbox {} { return [lappend bbox $_left $_top $_right $_bottom]}# ----------------------------------------------------------------------# METHOD: deselect## Causes the given tab to be drawn as deselected and lowered# ----------------------------------------------------------------------body iwidgets::Tab::deselect {} { global tcl_platform $_canvas lower $this if {$tcl_platform(os) == "HP-UX"} { update idletasks } _deselectNoLower}# ----------------------------------------------------------------------# METHOD: lower## Lowers the tab below all others in the canvas.## This is used as our tag name on the canvas.# ----------------------------------------------------------------------body iwidgets::Tab::lower {} { $_canvas lower $this}# ----------------------------------------------------------------------# METHOD: majordim## Returns the width for horizontal tabs and the height for# vertical tabs.# ----------------------------------------------------------------------body iwidgets::Tab::majordim {} { return $_majorDim }# ----------------------------------------------------------------------# METHOD: minordim## Returns the height for horizontal tabs and the width for# vertical tabs.# ----------------------------------------------------------------------body iwidgets::Tab::minordim {} { return $_minorDim }# ----------------------------------------------------------------------# METHOD: offset## Returns the width less the angle offset. This allows a # geometry manager to ask where to place a sibling tab.# ----------------------------------------------------------------------body iwidgets::Tab::offset {} { return $_offset }# ----------------------------------------------------------------------# METHOD: raise## Raises the tab above all others in the canvas.## This is used as our tag name on the canvas.# ----------------------------------------------------------------------body iwidgets::Tab::raise {} { $_canvas raise $this}# ----------------------------------------------------------------------# METHOD: select## Causes the given tab to be drawn as selected. 3d shadows are# turned on and top line and top line shadow are drawn in sel# bg color to hide them.# ----------------------------------------------------------------------body iwidgets::Tab::select {} { global tcl_platform $_canvas raise $this if {$tcl_platform(os) == "HP-UX"} { update idletasks } _selectNoRaise}# ----------------------------------------------------------------------# METHOD: labelheight## Returns the height of the tab's label in its current font.# ----------------------------------------------------------------------body iwidgets::Tab::labelheight {} { if {$_gLabel != 0} { set labelBBox [$_canvas bbox $_gLabel] set labelHeight [expr [lindex $labelBBox 3] - [lindex $labelBBox 1]] } else { set labelHeight 0 } return $labelHeight}# ----------------------------------------------------------------------# METHOD: labelwidth## Returns the width of the tab's label in its current font.# ----------------------------------------------------------------------body iwidgets::Tab::labelwidth {} { if {$_gLabel != 0} { set labelBBox [$_canvas bbox $_gLabel] set labelWidth [expr [lindex $labelBBox 2] - [lindex $labelBBox 0]] } else { set labelWidth 0 } return $labelWidth}# ----------------------------------------------------------------------# PRIVATE METHOD: _selectNoRaise## Draws tab as selected without raising it.# ----------------------------------------------------------------------body iwidgets::Tab::_selectNoRaise {} { if { ! [info exists _gRegion] } { return } $_canvas itemconfigure $_gRegion -fill $selectbackground $_canvas itemconfigure $_gTopLine -fill $selectbackground $_canvas itemconfigure $_gTopLineShadow -fill $selectbackground $_canvas itemconfigure $_gLightShadow -fill $_lightShadow $_canvas itemconfigure $_gDarkShadow -fill $_darkShadow if { $_gLightOutline != {} } { $_canvas itemconfigure $_gLightOutline -fill $_lightShadow } if { $_gBlackOutline != {} } { $_canvas itemconfigure $_gBlackOutline -fill black } if { $state == "normal" } { if { $image != {}} { # do nothing for now } elseif { $bitmap != {}} { $_canvas itemconfigure $_gLabel \ -foreground $selectforeground \ -background $selectbackground } else { $_canvas itemconfigure $_gLabel -fill $selectforeground } } else { if { $image != {}} { # do nothing for now } elseif { $bitmap != {}} { $_canvas itemconfigure $_gLabel \ -foreground $disabledforeground \ -background $selectbackground } else { $_canvas itemconfigure $_gLabel -fill $disabledforeground } } set _selected true}# ----------------------------------------------------------------------# PRIVATE METHOD: _deselectNoLower## Causes the given tab to be drawn as deselected. 3d shadows are# removed and top line and top line shadow are drawn in visible# colors to reveal them.# ----------------------------------------------------------------------body iwidgets::Tab::_deselectNoLower {} { if { ! [info exists _gRegion] } { return } $_canvas itemconfigure $_gRegion -fill $background $_canvas itemconfigure $_gTopLine -fill black $_canvas itemconfigure $_gTopLineShadow -fill $_darkShadow $_canvas itemconfigure $_gLightShadow -fill $background $_canvas itemconfigure $_gDarkShadow -fill $background if { $tabborders } { if { $_gLightOutline != {} } { $_canvas itemconfigure $_gLightOutline -fill $_lightShadow } if { $_gBlackOutline != {} } { $_canvas itemconfigure $_gBlackOutline -fill black } } else { if { $_gLightOutline != {} } { $_canvas itemconfigure $_gLightOutline -fill $background } if { $_gBlackOutline != {} } { $_canvas itemconfigure $_gBlackOutline -fill $background } } if { $state == "normal" } { if { $image != {}} { # do nothing for now } elseif { $bitmap != {}} { $_canvas itemconfigure $_gLabel \ -foreground $foreground \ -background $background } else { $_canvas itemconfigure $_gLabel -fill $foreground } } else { if { $image != {}} { # do nothing for now } elseif { $bitmap != {}} { $_canvas itemconfigure $_gLabel \ -foreground $disabledforeground \ -background $background } else { $_canvas itemconfigure $_gLabel -fill $disabledforeground } } set _selected false}# ----------------------------------------------------------------------# PRIVATE METHOD: _makeTab# ----------------------------------------------------------------------body iwidgets::Tab::_makeTab {} { if { $orient == "horizontal" } { if { $invert } { _makeNorthTab $_canvas } else { _m
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -