::bartabsTop


What's thatbartabs, Top

The bartabs Tcl/Tk package provides a bar widget containing tabs that are

  • scrollable
  • markable
  • moveable
  • closeable
  • disabled and enabled
  • static and changeable
  • selectable and multi-selectable
  • configureable
  • enhanceable with popup menu

The bartabs defines three TclOO classes:

  • Tab deals with tabs
  • Bar deals with a bar of tabs
  • Bars deals with bars of tabs

However, only the Bars class is used to create bars along with tabs. It can be also used to deal with any bars and tabs, providing all necessary interface.

The Bar does not create a real TclOO object, rather it provides syntax sugar for a convenient access to the bar methods.

The Tab does not create a real TclOO object as well. It serves actually for structuring bartabs code as for tab methods. Thus, its methods are accessible through the Bars ("real" TclOO) and Bar ("sugar") objects.


Work flowbartabs, Top

A common work flow with bartabs looks like this:

Firstly, we create a Bars object, e.g.

bartabs::Bars create NS::bars

Then we create a Bar object, e.g.

NS::bars create NS::bar $barOptions

If a tab of the bar should be displayed (with its possible contents), we show the bar and select the current tab:

set TID [NS::bar tabID "tab label"] ;# get the tab's ID by its label

NS::bar $TID show ;# show the bar and select the tab

or just draw the bar without mind-breaking about a tab:

NS::bar draw ;# show the bar without selecting a tab

The rest actions include:

  • responses to a selection of tab (through -csel command option of Bar object)
  • responses to a deletion of tab (through -cdel command option of Bar object)
  • responses to a reorganization of bar (through -cmov command option of Bar object)
  • inserting and renaming tabs
  • disabling and enabling tabs
  • marking tabs with colors or icons
  • processing the marked tabs
  • processing multiple tabs selected with Ctrl+click
  • scrolling tabs to left/right through key bindings
  • calling other handlers through key bindings and bartabs menu
  • using cget and configure methods to change the bar/tab appearance
  • redrawing bars at some events
  • removing and creating as much bars as required

Tab classbartabs, Top

The methods of Tab class are called from Bars or Bar object and are passed: tab ID (TID), method name, arguments. Syntax:

OBJECT TID method arguments

For example: NS::bars $TID close or NS::bar $TID show false


Bar classbartabs, Top

The methods of Bar class are called from Bar object or (more wordy) from Bars object. Syntax:

BAR_OBJECT method arguments

BARS_OBJECT BID method arguments

For example: NS::bar popList $X $Y or NS::bars $BID popList $X $Y


Bars classbartabs, Top

The methods of Bars class need no TID nor BID, though not protesting them passed before method name. Syntax:

BARS_OBJECT method arguments

For example:

NS::bars drawAll ;# good boy

NS::bars tab11 drawAll ;# bad boy uses the useless tab11 (TID)

NS::bars bar1 drawAll ;# bad boy's BID is useless as well


Virtual methodsbartabs, Top

There are three "virtual" methods:

  • NS::bar create NS::tab $label creates a tab object NS::tab for a tab labeled $label to access the tab methods, e.g. NS::tab show
  • NS::tab cget $option gets an option of tab, e.g. NS::tab cget -text
  • NS::tab configure $option $value sets an option of tab, e.g. NS::tab configure -text "new label"

BID and TIDbartabs, Top

Few words about BID and TID mentioned throughout the bartabs.

These are identifiers of bars and tabs, of form bar<index> and tab<index> where <index> is integer increased from 0 in order of bar/tab creation. The bars and the tabs of all bars have unique IDs.

You can use these literals freely, along with BIDs and TIDs gotten from bartabs methods. For example, if you know that "some tab" was created third, you can show it straightforward:

NS::bar tab2 show ;# show the 3rd tab (TID=tab2)

instead of

NS::bar [NS::bar tabID "some tab"] show ;# find and show the tab by its name


Linksbartabs, Top

Documentation

Reference on bartabs

Reference on baltip (package used by bartabs)


Commandsbartabs, Top




drawAll [::bartabs]bartabs, Top

Draws all bars. Used at updating themes etc.

drawAll

proc ::bartabs::drawAll {} { # Draws all bars. Used at updating themes etc. foreach bars $::bartabs::BarsList {$bars drawAll} }




messageBox [::bartabs]bartabs, Top

Runs Tk's or apave's ok/yes/no/cancel dialogue.

messageBox type ttl msg ?args?
Parameters
typeok, yesno or yesnocancel
ttlmessage
msgNot documented.
argsadditional arguments of tk_messageBox
Return value

Returns 1 if 'yes' chosen, 2 if 'no', 0 otherwise.


proc ::bartabs::messageBox {type ttl msg args} { # Runs Tk's or apave's ok/yes/no/cancel dialogue. # type - ok, yesno or yesnocancel # ttl - title # ttl - message # args - additional arguments of tk_messageBox # Returns 1 if 'yes' chosen, 2 if 'no', 0 otherwise. # try the apave package's dialogue if {[catch {set res [::apave::obj $type ques $ttl $msg]}]} { # or run the standard tk_messageBox set res [tk_messageBox -title $ttl -message $msg -type $type -icon question {*}$args] set res [expr {$res eq {yes} ? 1 : ($res eq {no} ? 2 : 0)}] } return $res }


Classesbartabs, Top



Bar [::bartabs]bartabs, Top

Method summary
_runBound_Runs a method bound to an event occuring at a widget.
bindToEventBinds an event on a widget to a command.
cgetGets values of options of bars & tabs.
checkDisabledMenuChecks whether the popup menu's items are disabled.
clearForgets (hides) the shown tabs.
closeSee Tab.close
closeAllCloses tabs of bar.
comparetextCompares items (by -text attribute) for sort method.
configureSets values of options for bars & tabs.
drawDraws the bar tabs at slight changes.
insertTabInserts a new tab into a bar.
listFlagGets a list of TID + flags "visible", "marked", "selected", "disabled".
listTabGets a list of tabs.
moveTabMoves a tab to a new position in the bar.
popListShows a menu of tabs.
removeRemoves a bar.
scrollLeftScrolls tabs to the left.
scrollRightScrolls tabs to the right.
showSee Tab.show
sortSorts a list of tabs by the tab names.
tabIDGets TID by tab's label.
updateUpdates the bar in hard way.
visibleSee Tab.visible
Superclasses

Tab

Subclasses

Bars



_runBound_ [::bartabs::Bar]Bar, Top

Runs a method bound to an event occuring at a widget.

OBJECT _runBound_ w ev ?args?
Parameters
wwidget
evevent
argsthe bound method & its arguments

method _runBound_ {w ev args} { # Runs a method bound to an event occuring at a widget. # w - widget # ev - event # args - the bound method & its arguments if {[catch {my {*}$args}]} { ;# failed binding => remove it foreach b [split [bind $w $ev] \n] { if {[string first $args $b]==-1} { if {[incr is1]==1} {bind $w $ev $b} {my bindToEvent $w $ev $b} } } } }



bindToEvent [::bartabs::Bar]Bar, Top

Binds an event on a widget to a command.

OBJECT bindToEvent w event ?args?
Parameters
wthe widget's path
eventthe event
argsthe command

method bindToEvent {w event args} { # Binds an event on a widget to a command. # w - the widget's path # event - the event # args - the command if {[string first $args [bind $w $event]]<0} { bind $w $event [list + {*}$args] } }



cget [::bartabs::Bar]Bar, Top

Gets values of options of bars & tabs.

OBJECT cget ?args?
Parameters
argslist of options, e.g. {-tabcurrent -MyOpt}
Description

Return a list of values or one value if args is one option.


method cget {args} { # Gets values of options of bars & tabs. # args - list of options, e.g. {-tabcurrent -MyOpt} # Return a list of values or one value if args is one option. set BID [my ID] variable btData set res [list] set llen [dict get $btData $BID -LLEN] foreach opt $args { if {$opt eq "-listlen"} { lappend res $llen } elseif {$opt eq "-width"} { lassign [dict get [dict get $btData $BID] -wbar] wbar lappend res [my Aux_WidgetWidth $wbar] } elseif {[dict exists $btData $BID $opt] && ($llen || $opt ne "-tabcurrent")} { lappend res [dict get $btData $BID $opt] } else { lappend res {} } } if {[llength $args]==1} {return [lindex $res 0]} return $res }



checkDisabledMenu [::bartabs::Bar]Bar, Top

Checks whether the popup menu's items are disabled.

OBJECT checkDisabledMenu BID TID func
Parameters
BIDNot documented.
TIDNot documented.
funcclose function
Description

func equals to:

1for "Close All"
2for "Close All at Left"
3for "Close All at Right"
Return value

Returns "yes" if the menu's item is disabled.


method checkDisabledMenu {BID TID func} { # Checks whether the popup menu's items are disabled. # func - close function # *func* equals to: # 1 - for "Close All" # 2 - for "Close All at Left" # 3 - for "Close All at Right" # Returns "yes" if the menu's item is disabled. lassign [my Mc_MenuItems] list behind close closeall closeleft closeright switch $func { 1 {set item $closeall} 2 {set item $closeleft} 3 {set item $closeright} default {set item $close} } my CheckDsblPopup $BID $TID $item }



clear [::bartabs::Bar]Bar, Top

Forgets (hides) the shown tabs.

OBJECT clear

method clear {} { # Forgets (hides) the shown tabs. if {[my Locked [set BID [my ID]]]} return set wlist [] foreach tab [my $BID listTab] { lassign $tab TID text wb wb1 wb2 pf if {[my Tab_Is $wb] && $pf ne {}} { lappend wlist $wb my $TID configure -pf {} } } if {[llength $wlist]} {pack forget {*}$wlist} }



closeAll [::bartabs::Bar]Bar, Top

Closes tabs of bar.

OBJECT closeAll BID TID func ?args?
Parameters
BIDNot documented.
TIDNot documented.
funcclose function
argsOptional arguments.
Description

func equals to:

1for "Close All"
2for "Close All at Left"
3for "Close All at Right"

method closeAll {BID TID func args} { # Closes tabs of bar. # func - close function # *func* equals to: # 1 - for "Close All" # 2 - for "Close All at Left" # 3 - for "Close All at Right" switch $func { 1 {my $BID Tab_CloseFew -1 no {*}$args} 2 {my $BID Tab_CloseFew $TID yes} 3 {my $BID Tab_CloseFew $TID no} } }



comparetext [::bartabs::Bar]Bar, Top

Compares items (by -text attribute) for sort method.

OBJECT comparetext it1 it2
Parameters
it11st item to compare
it22nd item to compare
See also

sort


method comparetext {it1 it2} { # Compares items (by -text attribute) for sort method. # it1 - 1st item to compare # it2 - 2nd item to compare # See also: sort catch {set it1 [dict get $it1 -text]} catch {set it2 [dict get $it2 -text]} string compare -nocase $it1 $it2 }



configure [::bartabs::Bar]Bar, Top

Sets values of options for bars & tabs.

OBJECT configure ?args?
Parameters
argslist of pairs "option value"

method configure {args} { # Sets values of options for bars & tabs. # args - list of pairs "option value" set BID [my ID] variable btData foreach {opt val} $args { dict set btData $BID $opt $val if {$opt eq "-TABS"} {dict set btData $BID -LLEN [llength $val]} } if {[dict exists $args -static]} {my $BID Style} }



draw [::bartabs::Bar]Bar, Top

Draws the bar tabs at slight changes.

OBJECT draw ?upd?
Parameters
updif "yes", run "update" before redrawing; optional, default yes

method draw {{upd yes}} { # Draws the bar tabs at slight changes. # upd - if "yes", run "update" before redrawing if {[my Locked [set BID [my ID]]]} return if {$upd} update lassign [my Aux_InitDraw $BID] bwidth vislen bd arrlen llen tleft hidearr tabs wframe set tright [expr {$llen-1}] for {set i $tleft} {$i<$llen} {incr i} { lassign [my Tab_DictItem [lindex $tabs $i]] TID text wb wb1 wb2 pf lassign [my Tab_Create $BID $TID $wframe $text] wb wb1 wb2 if {[my Aux_CheckTabVisible $wb $wb1 $wb2 $i $tleft tright vislen $llen $hidearr $arrlen $bd $bwidth tabs $TID $text]} { my Tab_Pack $BID $TID $wb $wb1 $wb2 } } my Aux_EndDraw $BID $tleft $tright $llen my Tab_MarkBar $BID }



insertTab [::bartabs::Bar]Bar, Top

Inserts a new tab into a bar.

OBJECT insertTab txt ?pos? ?img?
Parameters
txttab's label
postab's position in tab list; optional, default end
imgtab's image; optional, default ""
Return value

Returns TID of new tab or "".


method insertTab {txt {pos end} {img {}}} { # Inserts a new tab into a bar. # txt - tab's label # pos - tab's position in tab list # img - tab's image # Returns TID of new tab or "". set tabs [my [set BID [my ID]] cget -TABS] set tab [my Tab_Data $BID $txt] if {$tab eq {}} {return {}} if {$pos eq {end}} { lappend tabs $tab } else { set tabs [linsert $tabs $pos $tab] } if {$img ne {}} { set imagetabs [my $BID cget -IMAGETABS] lappend imagetabs [list [lindex $tab 0] $img] my $BID configure -IMAGETABS $imagetabs } my $BID configure -TABS $tabs my $BID Refill $pos [expr {$pos ne "end"}] lindex $tab 0 }



listFlag [::bartabs::Bar]Bar, Top

Gets a list of TID + flags "visible", "marked", "selected", "disabled".

OBJECT listFlag ?filter?
Parameters
filter"" for all or "v","m","s","d" for visible, marked, selected, disabled; optional, default ""
Return value

Returns a list "TID, text, visible, marked, selected, disabled" for all or a list of TID for filtered.


method listFlag {{filter {}}} { # Gets a list of TID + flags "visible", "marked", "selected", "disabled". # filter - "" for all or "v","m","s","d" for visible, marked, selected, disabled # Returns a list "TID, text, visible, marked, selected, disabled" for all or a list of TID for filtered. set BID [my ID] lassign [my $BID cget -mark -disable -select -tabcurrent] mark dsbl fewsel tcurr set res [list] foreach tab [my $BID listTab] { lassign $tab TID text wb wb1 wb2 pf set visibl [expr {[my Tab_Is $wb] && $pf ne {}}] set marked [expr {[lsearch $mark $TID]>=0}] set dsbled [expr {[lsearch $dsbl $TID]>=0}] set select [expr {$TID == $tcurr || [lsearch $fewsel $TID]>-1}] if {$filter eq {}} { lappend res [list $TID $text $visibl $marked $select $dsbled] } elseif {$filter eq "v" && $visibl || $filter eq "m" && $marked || $filter eq "d" && $dsbled || $filter eq "s" && $select} { lappend res $TID } } return $res }



listTab [::bartabs::Bar]Bar, Top

Gets a list of tabs.

OBJECT listTab
Return value

Returns a list of TID, text, wb, wb1, wb2, pf.


method listTab {} { # Gets a list of tabs. # Returns a list of TID, text, wb, wb1, wb2, pf. set res [list] foreach tab [my [my ID] cget -TABS] {lappend res [my Tab_DictItem $tab]} return $res }



moveTab [::bartabs::Bar]Bar, Top

Moves a tab to a new position in the bar.

OBJECT moveTab TID pos
Parameters
TIDNot documented.
posthe new position

method moveTab {TID pos} { # Moves a tab to a new position in the bar. # pos - the new position set BID [my ID] set tabs [my $BID cget -TABS] if {[set i [lsearch -index 0 $tabs $TID]]>-1} { set tab [lindex $tabs $i] set tabs [lreplace $tabs $i $i] my $BID configure -TABS [linsert $tabs $pos $tab] } }



popList [::bartabs::Bar]Bar, Top

Shows a menu of tabs.

OBJECT popList ?X? ?Y? ?sortedList?
Parameters
Xx coordinate of mouse pointer; optional, default ""
Yy coordinate of mouse pointer; optional, default ""
sortedListflag "sorted list" optional, default 0

method popList {{X {}} {Y {}} {sortedList 0}} { # Shows a menu of tabs. # X - x coordinate of mouse pointer # Y - y coordinate of mouse pointer # sortedList - flag "sorted list" set BID [my ID] my $BID DestroyMoveWindow lassign [my $BID cget -wbar -title] wbar title set popi $wbar.popupList catch {destroy $popi} menu $popi -tearoff 1 -title $title if {[set plist [my $BID FillMenuList $BID $popi -1 {} $sortedList]] eq "s"} { destroy $popi } else { my Bar_MenuList $BID -1 $popi $plist if {$X eq {}} {lassign [winfo pointerxy .] X Y} tk_popup $popi $X $Y } }



remove [::bartabs::Bar]Bar, Top

Removes a bar.

OBJECT remove
Return value

Returns "yes" at success.


method remove {} { # Removes a bar. # Returns "yes" at success. set BID [my ID] variable btData if {[dict exists $btData $BID]} { catch {bind [my $BID cget -wbase] <Configure> {}} lassign [my $BID cget -BINDWBASE] wb bnd if {$wb ne {}} {bind $wb <Configure> $bnd} set bar [dict get $btData $BID] foreach tab [dict get $bar -TABS] {my Tab_RemoveLinks $BID [lindex $tab 0]} catch {destroy {*}[dict get $bar -WWID]} catch {destroy [my $BID cget -UNDERWID]} if {[set bc [my $BID cget -BARCOM]] ne {}} {catch {rename $bc {}}} foreach tc [my $BID cget -TABCOM] {catch {rename [lindex $tc 1] {}}} dict unset btData $BID return yes } return no }



scrollLeft [::bartabs::Bar]Bar, Top

Scrolls tabs to the left.

OBJECT scrollLeft

method scrollLeft {} { # Scrolls tabs to the left. set BID [my ID] lassign [my $BID cget -wbar -dotip] w dotip set wlarr $w.larr ;# left arrow if {[my $BID ScrollCurr -1]} { if {$dotip} {catch {::baltip::repaint $wlarr}} return } lassign [my $BID cget -tleft -LLEN -scrollsel] tleft llen sccur if {![string is integer -strict $tleft]} {set tleft 0} if {$tleft && $tleft<$llen} { incr tleft -1 set tID [lindex [my $BID listTab] $tleft 0] my $BID configure -tleft $tleft my $BID Refill $tleft yes if {$sccur} {my $tID Tab_BeCurrent} if {$dotip} {catch {::baltip::repaint $wlarr}} } }



scrollRight [::bartabs::Bar]Bar, Top

Scrolls tabs to the right.

OBJECT scrollRight

method scrollRight {} { # Scrolls tabs to the right. set BID [my ID] lassign [my $BID cget -wbar -dotip] w dotip set wrarr $w.rarr ;# left arrow if {[my $BID ScrollCurr 1]} { if {$dotip} {catch {::baltip::repaint $wrarr}} return } lassign [my $BID cget -tright -LLEN -scrollsel] tright llen sccur if {![string is integer -strict $tright]} {set tright [expr {$llen-2}]} if {$tright<($llen-1)} { incr tright set tID [lindex [my $BID listTab] $tright 0] my $BID configure -tright $tright my $BID Refill $tright no if {$sccur} {my $tID Tab_BeCurrent} if {$dotip} {catch {::baltip::repaint $wrarr}} } }



sort [::bartabs::Bar]Bar, Top

Sorts a list of tabs by the tab names.

OBJECT sort ?mode? ?cmd?
Parameters
modeoption of sort; optional, default -increasing
cmdcommand to compare two items; optional, default ""

method sort {{mode -increasing} {cmd {}}} { # Sorts a list of tabs by the tab names. # mode - option of sort # cmd - command to compare two items set BID [my ID] lassign [my $BID cget -tabcurrent -lifo] TID lifo set tabs [my $BID cget -TABS] if {$cmd eq {}} { set tabs [lsort $mode -index 1 -dictionary -command "[self] comparetext" $tabs] } else { set tabs [lsort $mode -dictionary -command $cmd $tabs] } my $BID configure -TABS $tabs -lifo no my $TID show yes my $BID configure -lifo $lifo }



tabID [::bartabs::Bar]Bar, Top

Gets TID by tab's label.

OBJECT tabID txt
Parameters
txtlabel
Return value

Returns TID or -1.


method tabID {txt} { # Gets TID by tab's label. # txt - label # Returns TID or -1. set BID [my ID] if {[catch {set ellipse [my $BID cget -ELLIPSE]}]} {return {}} if {[string first $ellipse $txt]>0} { set pattern [string map [list $ellipse "*"] $txt] } else { set pattern {} } foreach tab [my $BID listTab] { lassign $tab tID ttxt if {$txt eq $ttxt} {return $tID} if {$pattern ne {} && [string match $pattern $ttxt]} {return $tID} } return {} }



update [::bartabs::Bar]Bar, Top

Updates the bar in hard way.

OBJECT update

method update {} { # Updates the bar in hard way. if {[my Locked [set BID [my ID]]]} return update my $BID Refill 0 yes }



Bars [::bartabs]bartabs, Top

Method summary
constructorConstructor for the class.
destructorDestructor for the class.
_runBound_See Bar._runBound_
bindToEventSee Bar.bindToEvent
cgetSee Bar.cget
checkDisabledMenuSee Bar.checkDisabledMenu
clearSee Bar.clear
closeSee Tab.close
closeAllSee Bar.closeAll
comparetextSee Bar.comparetext
configureSee Bar.configure
createCreates a bar.
disableTabDisables tab(s).
drawSee Bar.draw
drawAllRedraws all bars.
enableTabEnables tab(s).
insertTabSee Bar.insertTab
isTabChecks if a tab exists.
listFlagSee Bar.listFlag
listTabSee Bar.listTab
markTabMarks tab(s).
moveSelTabChanges a tab's or selected tabs' position in bar.
moveTabSee Bar.moveTab
onSelectCmdRuns a command (set by "-csel3") on a list of tabs.
popListSee Bar.popList
removeSee Bar.remove
removeAllRemoves all bars.
scrollLeftSee Bar.scrollLeft
scrollRightSee Bar.scrollRight
selectTabSelects tab(s).
showSee Tab.show
sortSee Bar.sort
tabIDSee Bar.tabID
unmarkTabUnmarks tab(s).
unselectTabUnselects tab(s).
updateSee Bar.update
updateAllUpdates all bars in hard way.
visibleSee Tab.visible
Superclasses

Bar



constructor [::bartabs::Bars]Bars, Top

Bars create ?args?
Parameters
argsOptional arguments.

method constructor {args} { set btData [dict create] if {[llength [self next]]} { next {*}$args } oo::objdefine [self] "method tab-1 {args} {return {-1}}" lappend ::bartabs::BarsList [self] }



destructor [::bartabs::Bars]Bars, Top

OBJECT destroy

method destructor {} { my removeAll unset btData set i [lsearch -exact $::bartabs::BarsList [self]] set ::bartabs::BarsList [lreplace $::bartabs::BarsList $i $i] if {[llength [self next]]} next }



create [::bartabs::Bars]Bars, Top

Creates a bar.

OBJECT create barCom ?barOpts? ?tab1?
Parameters
barCombar command's name or barOpts
barOptslist of bar's options; optional, default ""
tab1tab to show after creating the bar; optional, default ""
Return value

Returns BID.


method create {barCom {barOpts {}} {tab1 {}}} { # Creates a bar. # barCom - bar command's name or barOpts # barOpts - list of bar's options # tab1 - tab to show after creating the bar # Returns BID. if {[set noComm [expr {$barOpts eq {}}]]} {set barOpts $barCom} set w [dict get $barOpts -wbar] ;# parent window set wframe $w.frame ;# frame set wlarr $w.larr ;# left arrow set wrarr $w.rarr ;# right arrow lappend barOpts -WWID [list $wframe $wlarr $wrarr] my My [set BID [my Bar_Data $barOpts]] my $BID InitColors set bgm [my $BID cget -BGMAIN] if {[my TtkTheme]} { ttk::button $wlarr -style ClButton$BID -image bts_ImgLeft -command [list [self] $BID scrollLeft] -takefocus 0 ttk::button $wrarr -style ClButton$BID -image bts_ImgRight -command [list [self] $BID scrollRight] -takefocus 0 } else { button $wlarr -image bts_ImgLeft -borderwidth 0 -highlightthickness 0 -command [list [self] $BID scrollLeft] -takefocus 0 -background $bgm button $wrarr -image bts_ImgRight -borderwidth 0 -highlightthickness 0 -command [list [self] $BID scrollRight] -takefocus 0 -background $bgm } if {$bgm eq {}} {set style {}} {set style "-background $bgm"} frame $wframe -relief flat {*}$style pack $wlarr -side left -padx 0 -pady 0 -anchor e pack $wframe -after $wlarr -side left -padx 0 -pady 0 -fill x -expand 1 pack $wrarr -after $wframe -side right -padx 0 -pady 0 -anchor w if {[my $BID cget -separator]} { if {![winfo exists $w.under]} { ttk::separator $w.under -orient horizontal my $BID configure -UNDERWID $w.under } pack $w.under -before $wlarr -side bottom -fill x -expand 1 -padx 0 -pady 2 } foreach w {wlarr wrarr} { bind [set $w] <Button-3> "[self] $BID popList %X %Y" } set wbase [my $BID cget -wbase] if {$wbase ne {}} { after 1 [list my $BID configure -BINDWBASE [list $wbase [bind $wbase <Configure>]] ; my $BID bindToEvent $wbase <Configure> [self] _runBound_ $wbase <Configure> $BID NeedDraw] } if {!$noComm} { ; proc $barCom {args} "return \[[self] $BID {*}\$args\]" my $BID configure -BARCOM $barCom } if {$tab1 eq {}} { after 50 [list [self] $BID NeedDraw ; [self] $BID draw] } else { set tab1 [my $BID tabID $tab1] if {$tab1 ne {}} {after 100 "[self] $BID clear; [self] $BID $tab1 show yes"} } return $BID }



disableTab [::bartabs::Bars]Bars, Top

Disables tab(s).

OBJECT disableTab ?args?
Parameters
argslist of TID

method disableTab {args} { # Disables tab(s). # args - list of TID my MarkTab -disable {*}$args }



drawAll [::bartabs::Bars]Bars, Top

Redraws all bars.

OBJECT drawAll ?upd?
Parameters
updif "yes", run "update" before redrawing; optional, default yes

method drawAll {{upd yes}} { # Redraws all bars. # upd - if "yes", run "update" before redrawing if {$upd} update my Bars_Method draw no }



enableTab [::bartabs::Bars]Bars, Top

Enables tab(s).

OBJECT enableTab ?args?
Parameters
argslist of TID or {}

method enableTab {args} { # Enables tab(s). # args - list of TID or {} my UnmarkTab -disable {*}$args }



isTab [::bartabs::Bars]Bars, Top

Checks if a tab exists.

OBJECT isTab TID
Parameters
TIDtab ID
Return value

Returns true if the tab exists.


method isTab {TID} { # Checks if a tab exists. # TID - tab ID # Returns true if the tab exists. expr {[my Tab_BID $TID check] ne {}} }



markTab [::bartabs::Bars]Bars, Top

Marks tab(s).

OBJECT markTab ?args?
Parameters
argslist of TID

method markTab {args} { # Marks tab(s). # args - list of TID my MarkTab -mark {*}$args }



moveSelTab [::bartabs::Bars]Bars, Top

Changes a tab's or selected tabs' position in bar.

OBJECT moveSelTab TID1 TID2
Parameters
TID1TID of the moved tab
TID2TID of a tab to move TID1 behind
Description

TID1 and TID2 must be of the same bar.


method moveSelTab {TID1 TID2} { # Changes a tab's or selected tabs' position in bar. # TID1 - TID of the moved tab # TID2 - TID of a tab to move TID1 behind # TID1 and TID2 must be of the same bar. if {[my $TID1 Tab_Cmd -cmov] ni {"1" "yes" "true"}} return ;# chosen to not move set BID [my Tab_BID $TID1 check] # -lifo option prevents moving, so it has to be temporarily disabled set lifo [my $BID cget -lifo] my $BID configure -lifo no set seltabs [my $BID listFlag "s"] if {[set i [llength $seltabs]]>1} { for {incr i -1} {$i>=0} {incr i -1} { set tid [lindex $seltabs $i] if {$tid ne $TID2} {my MoveTab $tid $TID2} } my $BID Bar_Cmd2 -cmov3 } else { my MoveTab $TID1 $TID2 my $BID Bar_Cmd2 -cmov3 $TID1 ;# command after the action } my $BID configure -lifo $lifo ;# restore -lifo option }



onSelectCmd [::bartabs::Bars]Bars, Top

Runs a command (set by "-csel3") on a list of tabs.

OBJECT onSelectCmd ?args?
Parameters
argslist of TID

method onSelectCmd {args} { # Runs a command (set by "-csel3") on a list of tabs. # args - list of TID foreach TID $args { if {$TID ni {{} -1}} { set BID [lindex [my Tab_BID $TID] 0] my $BID Bar_Cmd2 -csel3 $TID ;# command after the action } } }



removeAll [::bartabs::Bars]Bars, Top

Removes all bars.

OBJECT removeAll

method removeAll {} { # Removes all bars. my Bars_Method remove }



selectTab [::bartabs::Bars]Bars, Top

Selects tab(s).

OBJECT selectTab ?args?
Parameters
argslist of TID

method selectTab {args} { # Selects tab(s). # args - list of TID my MarkTab -select {*}$args my onSelectCmd {*}$args }



unmarkTab [::bartabs::Bars]Bars, Top

Unmarks tab(s).

OBJECT unmarkTab ?args?
Parameters
argslist of TID or {}

method unmarkTab {args} { # Unmarks tab(s). # args - list of TID or {} my UnmarkTab -mark {*}$args }



unselectTab [::bartabs::Bars]Bars, Top

Unselects tab(s).

OBJECT unselectTab ?args?
Parameters
argslist of TID or {}

method unselectTab {args} { # Unselects tab(s). # args - list of TID or {} my UnmarkTab -select {*}$args my onSelectCmd {*}$args }



updateAll [::bartabs::Bars]Bars, Top

Updates all bars in hard way.

OBJECT updateAll

method updateAll {} { # Updates all bars in hard way. my Bars_Method Refill 0 yes }



Tab [::bartabs]bartabs, Top

Method summary
closeCloses a tab and updates the bar.
showShows a tab in a bar and sets it current.
visibleChecks if a tab is visible.
Subclasses

Bar



close [::bartabs::Tab]Tab, Top

Closes a tab and updates the bar.

OBJECT close ?redraw? ?args?
Parameters
redrawif "yes", update the bar and select the new tab; optional, default yes
argsadditional argumens of the -cdel command
Return value

Returns "1" if the deletion was successful, otherwise 0 (no) or -1 (cancel).


method close {{redraw yes} args} { # Closes a tab and updates the bar. # redraw - if "yes", update the bar and select the new tab # args - additional argumens of the -cdel command # Returns "1" if the deletion was successful, otherwise 0 (no) or -1 (cancel). lassign [my Tab_BID [set TID [my ID]]] BID icurr tabcurr if {[my Disabled $TID]} { set ttl [msgcat::mc Closing] set t [my $TID cget -text] set msg [msgcat::mc "Can't close the disabled\n\"%t\"\n\nClose others?"] set msg [string map [list %t $t] $msg] return [expr {[::bartabs::messageBox yesno $ttl $msg -icon question]==1}] } set cdel [my $BID cget -cdel] if {$cdel eq {}} { set res 1 } else { set cdel [my PrepareCmd $TID $BID -cdel {*}$args] if {[catch {set res [{*}$cdel]}]} { set res [my $TID Tab_Cmd -cdel {*}$args] } } if {$res ni {1 yes true}} {return $res} if {$redraw} {my $BID clear} lassign [my $BID cget -TABS -tleft -tright -tabcurrent] tabs tleft tright tcurr my Tab_RemoveLinks $BID $TID destroy [my $TID cget -wb] set tabs [lreplace $tabs $icurr $icurr] oo::objdefine [self] [list deletemethod [lindex $tabcurr 0]] my $BID configure -TABS $tabs if {$redraw} { if {$icurr>=$tleft && $icurr<[llength $tabs]} { my $BID draw my [lindex $tabs $icurr 0] Tab_BeCurrent } else { if {[set TID [lindex $tabs end 0]] ne {}} { my $TID show yes ;# last tab deleted: show the new last if any } } } my $BID Bar_Cmd2 -cdel2 ;# command after the action return 1 }



show [::bartabs::Tab]Tab, Top

Shows a tab in a bar and sets it current.

OBJECT show ?refill? ?lifo?
Parameters
refillif "yes", update the bar; optional, default no
lifoif "yes", allows moving a tab to 0th position; optional, default yes
Description

When refill=no and lifo=no, just shows a tab in its current position.


method show {{refill no} {lifo yes}} { # Shows a tab in a bar and sets it current. # refill - if "yes", update the bar # lifo - if "yes", allows moving a tab to 0th position # When refill=no and lifo=no, just shows a tab in its current position. lassign [my IDs [my ID]] TID BID if {$refill} {my $BID clear} set itab 0 foreach tab [my $BID listTab] { lassign $tab tID text wb wb1 wb2 pf if {$TID eq $tID} { set refill [expr {$pf eq {}}] ;# check if visible break } incr itab } if {$refill && $lifo && [my $BID cget -lifo] && (![my $TID visible] || [string is true -strict [my $BID cget -lifoest]])} { my $BID moveTab $TID 0 set itab 0 } if {$refill} {my $BID Refill $itab no yes} my $TID Tab_BeCurrent }



visible [::bartabs::Tab]Tab, Top

Checks if a tab is visible.

OBJECT visible
Return value

Returns yes if the tab is visible,.


method visible {} { # Checks if a tab is visible. # Returns yes if the tab is visible,. lassign [my IDs [my ID]] TID BID lassign [my $BID cget -tleft -tright] tleft tright set tabs [my $BID listTab] for {set i $tleft} {$i<=$tright} {incr i} { if {$TID eq [lindex $tabs $i 0]} { return yes } } return no }

Document generated by Ruff!