📄 tabset.itk
字号:
set _configTripped true}# ----------------------------------------------------------------------# OPTION -width## The width of the tab. If 0, uses the font label width.# ----------------------------------------------------------------------itcl::configbody iwidgets::Tab::width { set _width [winfo pixels $_canvas $width] set _configTripped true}# ----------------------------------------------------------------------# OPTION -anchor## Where the text in the tab will be anchored: n,nw,ne,s,sw,se,e,w,center# ----------------------------------------------------------------------itcl::configbody iwidgets::Tab::anchor { }# ----------------------------------------------------------------------# OPTION -left## Specifies the left edge of the tab's bounding box. This value # may have any of the forms acceptable to Tk_GetPixels.# ----------------------------------------------------------------------itcl::configbody iwidgets::Tab::left { # get into pixels set _left [winfo pixels $_canvas $left] # move by offset from last setting $_canvas move $this [expr {$_left - $_oldLeft}] 0 # update old for next time set _oldLeft $_left}# ----------------------------------------------------------------------# OPTION -top## Specifies the topedge of the tab's bounding box. This value may # have any of the forms acceptable to Tk_GetPixels.# ----------------------------------------------------------------------itcl::configbody iwidgets::Tab::top { # get into pixels set _top [winfo pixels $_canvas $top] # move by offset from last setting $_canvas move $this 0 [expr {$_top - $_oldTop}] # update old for next time set _oldTop $_top}# ----------------------------------------------------------------------# OPTION -image## Specifies the imageto display in the tab. # Images are created with the image create command. # ----------------------------------------------------------------------itcl::configbody iwidgets::Tab::image { set _configTripped true}# ----------------------------------------------------------------------# OPTION -bitmap## If bitmap is an empty string, specifies the bitmap to display in # the tab. Bitmap may be of any of the forms accepted by Tk_GetBitmap. # ----------------------------------------------------------------------itcl::configbody iwidgets::Tab::bitmap { set _configTripped true}# ----------------------------------------------------------------------# OPTION -label## If image is an empty string and bitmap is an empty string, # it specifies a text string to be placed in the tab's label. # This label serves as an additional identifier used to reference # the tab. Label may be used for the index value in widget commands.# ----------------------------------------------------------------------itcl::configbody iwidgets::Tab::label { set _configTripped true}# ----------------------------------------------------------------------# OPTION -padx## Horizontal padding around the label (text, image, or bitmap).# ----------------------------------------------------------------------itcl::configbody iwidgets::Tab::padx { set _configTripped true set _padX [winfo pixels $_canvas $padx]}# ----------------------------------------------------------------------# OPTION -pady## Vertical padding around the label (text, image, or bitmap).# ----------------------------------------------------------------------itcl::configbody iwidgets::Tab::pady { set _configTripped true set _padY [winfo pixels $_canvas $pady]}# ----------------------------------------------------------------------# OPTION -selectbackground# ----------------------------------------------------------------------itcl::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# ----------------------------------------------------------------------itcl::configbody iwidgets::Tab::selectforeground { if { $_selected } { _selectNoRaise } else { _deselectNoLower }}# ----------------------------------------------------------------------# OPTION -disabledforeground## Background of tab when -state is disabled# ----------------------------------------------------------------------itcl::configbody iwidgets::Tab::disabledforeground { if { $_selected } { _selectNoRaise } else { _deselectNoLower }}# ----------------------------------------------------------------------# OPTION -background## Normal background of tab.# ----------------------------------------------------------------------itcl::configbody iwidgets::Tab::background { if { $_selected } { _selectNoRaise } else { _deselectNoLower } }# ----------------------------------------------------------------------# OPTION -foreground## Foreground of tabs when in normal unselected state# ----------------------------------------------------------------------itcl::configbody iwidgets::Tab::foreground { if { $_selected } { _selectNoRaise } else { _deselectNoLower }}# ----------------------------------------------------------------------# OPTION -orient## Specifies the orientation of the tab. Orient can be either # horizontal or vertical. # ----------------------------------------------------------------------itcl::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.# ----------------------------------------------------------------------itcl::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.# ----------------------------------------------------------------------itcl::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.# ----------------------------------------------------------------------itcl::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.# ----------------------------------------------------------------------itcl::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.# ----------------------------------------------------------------------itcl::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# ----------------------------------------------------------------------itcl::body iwidgets::Tab::bbox {} { return [lappend bbox $_left $_top $_right $_bottom]}# ----------------------------------------------------------------------# METHOD: deselect## Causes the given tab to be drawn as deselected and lowered# ----------------------------------------------------------------------itcl::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.# ----------------------------------------------------------------------itcl::body iwidgets::Tab::lower {} { $_canvas lower $this}# ----------------------------------------------------------------------# METHOD: majordim## Returns the width for horizontal tabs and the height for# vertical tabs.# ----------------------------------------------------------------------itcl::body iwidgets::Tab::majordim {} { return $_majorDim }# ----------------------------------------------------------------------# METHOD: minordim## Returns the height for horizontal tabs and the width for# vertical tabs.# ----------------------------------------------------------------------itcl::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.# ----------------------------------------------------------------------itcl::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.# ----------------------------------------------------------------------itcl::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.# ----------------------------------------------------------------------itcl::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.# ----------------------------------------------------------------------itcl::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.# ----------------------------------------------------------------------itcl::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.# ----------------------------------------------------------------------itcl::body iwidgets::Tab::_selectNoRaise {} { if { ! [info exists _gRegion] } { return } $_canvas itemconfigure $_gRegion -fill $selectbackground $_canvas itemconfigure $_gTopLine -fill $selectbackground $_canvas itemconfigure $_gTopLineShadow -fill $selectbackg
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -