📄 tabset.itk
字号:
} return $bbox}# ----------------------------------------------------------------------# PRIVATE METHOD: _recalcCanvasGeom# # Based on size of tabs, recalculates the canvas geometry that# will hold the tabs.# ----------------------------------------------------------------------body iwidgets::Tabset::_recalcCanvasGeom {} { if { [llength $_tabs] == 0 } { return } set bbox [_tabBounds] set width [lindex [_tabBounds] 2] set height [lindex [_tabBounds] 3] # now we have the dimensions of all the tabs in the canvas. switch $itk_option(-tabpos) { n { # height already includes margin $itk_component(canvas) configure \ -width $width \ -height $height } s { $itk_component(canvas) configure \ -width $width \ -height [expr $height + $_margin] } w { # width already includes margin $itk_component(canvas) configure \ -width $width \ -height [expr $height + 1] } e { $itk_component(canvas) configure \ -width [expr $width + $_margin] \ -height [expr $height + 1] } default { } }}# ----------------------------------------------------------------------# PRIVATE METHOD: _canvasReconfigure# # Bound to the reconfigure notify event of a canvas, this # method resets canvas's correct width (since we are fill x)# and redraws the beveled edge border.# will hold the tabs.# ----------------------------------------------------------------------body iwidgets::Tabset::_canvasReconfigure {width height} { set _canvasWidth $width set _canvasHeight $height if { [llength $_tabs] > 0 } { _drawBevelBorder }}# ----------------------------------------------------------------------# PRIVATE METHOD: _startMove# # This method is bound to the MB2 down in the canvas area of the# tab set. This starts animated scrolling of the tabs along their# major axis.# ----------------------------------------------------------------------body iwidgets::Tabset::_startMove {x y} { if { $itk_option(-tabpos) == "n" || $itk_option(-tabpos) == "s" } { set _anchorX $x } else { set _anchorY $y }}# ----------------------------------------------------------------------# PRIVATE METHOD: _moveTabs# # This method is bound to the MB2 motion in the canvas area of the# tab set. This causes the tabset to move with the mouse.# ----------------------------------------------------------------------body iwidgets::Tabset::_moveTabs {x y} { if { $itk_option(-tabpos) == "n" || $itk_option(-tabpos) == "s" } { set startX [expr $_start + $x - $_anchorX] foreach tab $_tabs { $tab configure -left $startX set startX [expr $startX + [_calcNextTabOffset $tab]] } } else { set startY [expr $_start + $y - $_anchorY] foreach tab $_tabs { $tab configure -top $startY set startY [expr $startY + [_calcNextTabOffset $tab]] } }}# ----------------------------------------------------------------------# PRIVATE METHOD: _endMove# # This method is bound to the MB2 release in the canvas area of the# tab set. This causes the tabset to end moving tabs.# ----------------------------------------------------------------------body iwidgets::Tabset::_endMove {x y} { if { $itk_option(-tabpos) == "n" || $itk_option(-tabpos) == "s" } { set startX [expr $_start + $x - $_anchorX] set _skipRelayout true configure -start $startX set _skipRelayout false } else { set startY [expr $_start + $y - $_anchorY] set _skipRelayout true configure -start $startY set _skipRelayout false }}#==============================================================# CLASS: Tab#==============================================================class iwidgets::Tab { constructor {args} {} destructor {} public variable bevelamount 0 {} public variable state normal {} public variable height 0 {} public variable width 0 {} public variable anchor c {} public variable left 0 {} public variable top 0 {} public variable image {} {} public variable bitmap {} {} public variable label {} {} public variable padx 4 {} public variable pady 4 {} public variable selectbackground "gray70" {} public variable selectforeground "black" {} public variable disabledforeground "gray" {} public variable background "white" {} public variable foreground "black" {} public variable orient vertical {} public variable invert false {} public variable angle 20 {} public variable font \ "-adobe-helvetica-bold-r-normal--34-240-100-100-p-182-iso8859-1" {} public variable tabborders true {} public method configure {args} public method bbox {} public method deselect {} public method lower {} public method majordim {} public method minordim {} public method offset {} public method raise {} public method select {} public method labelheight {} public method labelwidth {} private method _makeTab {} private method _createLabel {canvas tagList} private method _makeEastTab {canvas} private method _makeWestTab {canvas} private method _makeNorthTab {canvas} private method _makeSouthTab {canvas} private method _calcLabelDim {labelItem} private method _itk_config {args} @itcl-builtin-configure private method _selectNoRaise {} private method _deselectNoLower {} private variable _selected false private variable _padX 0 private variable _padY 0 private variable _canvas # these are in pixels private variable _left 0 private variable _width 0 private variable _height 0 private variable _oldLeft 0 private variable _top 0 private variable _oldTop 0 private variable _right private variable _bottom private variable _offset private variable _majorDim private variable _minorDim private variable _darkShadow private variable _lightShadow # # graphic components that make up a tab # private variable _gRegion private variable _gLabel private variable _gLightOutline {} private variable _gBlackOutline {} private variable _gTopLine private variable _gTopLineShadow private variable _gLightShadow private variable _gDarkShadow private variable _labelWidth 0 private variable _labelHeight 0 private variable _labelXOrigin 0 private variable _labelYOrigin 0 private variable _just left private variable _configTripped true common _tan set _tan(0) 0.0 set _tan(1) 0.0175 set _tan(2) 0.0349 set _tan(3) 0.0524 set _tan(4) 0.0699 set _tan(5) 0.0875 set _tan(6) 0.1051 set _tan(7) 0.1228 set _tan(8) 0.1405 set _tan(9) 0.1584 set _tan(10) 0.1763 set _tan(11) 0.1944 set _tan(12) 0.2126 set _tan(13) 0.2309 set _tan(14) 0.2493 set _tan(15) 0.2679 set _tan(16) 0.2867 set _tan(17) 0.3057 set _tan(18) 0.3249 set _tan(19) 0.3443 set _tan(20) 0.3640 set _tan(21) 0.3839 set _tan(22) 0.4040 set _tan(23) 0.4245 set _tan(24) 0.4452 set _tan(25) 0.4663 set _tan(26) 0.4877 set _tan(27) 0.5095 set _tan(28) 0.5317 set _tan(29) 0.5543 set _tan(30) 0.5774 set _tan(31) 0.6009 set _tan(32) 0.6294 set _tan(33) 0.6494 set _tan(34) 0.6745 set _tan(35) 0.7002 set _tan(36) 0.7265 set _tan(37) 0.7536 set _tan(38) 0.7813 set _tan(39) 0.8098 set _tan(40) 0.8391 set _tan(41) 0.8693 set _tan(42) 0.9004 set _tan(43) 0.9325 set _tan(44) 0.9657 set _tan(45) 1.0}# ----------------------------------------------------------------------# CONSTRUCTOR# ----------------------------------------------------------------------body iwidgets::Tab::constructor {args} { set _canvas [lindex $args 0] set args [lrange $args 1 [llength $args]] set _darkShadow [iwidgets::colors::bottomShadow $selectbackground] set _lightShadow [iwidgets::colors::topShadow $selectbackground] if { $args != "" } { eval configure $args }}# ----------------------------------------------------------------------# DESTRUCTOR# ----------------------------------------------------------------------body iwidgets::Tab::destructor {} { if { [winfo exists $_canvas] } { $_canvas delete $this }}# ----------------------------------------------------------------------# OPTIONS# ----------------------------------------------------------------------## Note, we trip _configTripped for every option that requires the tab# to be remade.## ----------------------------------------------------------------------# OPTION -bevelamount## Specifies the size of tab corners. A value of 0 with angle set # to 0 results in square tabs. A bevelAmount of 4, means that the # tab will be drawn with angled corners that cut in 4 pixels from # the edge of the tab. The default is 0.# ----------------------------------------------------------------------configbody iwidgets::Tab::bevelamount { }# ----------------------------------------------------------------------# OPTION -state## sets the active state of the tab. specifying normal allows # the tab to be selectable. Specifying disabled disables the tab, # causing its image, bitmap, or label to be drawn with the # disabledForeground color.# ----------------------------------------------------------------------configbody iwidgets::Tab::state { }# ----------------------------------------------------------------------# OPTION -height## the height of the tab. if 0, uses the font label height.# ----------------------------------------------------------------------configbody iwidgets::Tab::height { set _height [winfo pixels $_canvas $height] set _configTripped true}# ----------------------------------------------------------------------# OPTION -width## The width of the tab. If 0, uses the font label width.# ----------------------------------------------------------------------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# ----------------------------------------------------------------------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.# ----------------------------------------------------------------------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.# ----------------------------------------------------------------------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. # ----------------------------------------------------------------------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. # ----------------------------------------------------------------------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.# ----------------------------------------------------------------------configbody iwidgets::Tab::label {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -