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

📄 scrolledlistbox.itk

📁 这是一个Linux下的集成开发环境
💻 ITK
📖 第 1 页 / 共 2 页
字号:
    # bindings if they exist.  If the state is disabled, then we need    # to install the disabled bindings if they haven't been already.    #    switch -- $itk_option(-state) {	normal {	    if {[set index [lsearch $tags SLBDisabled]] != -1} {		bindtags $itk_component(listbox) \		    [lreplace $tags $index $index]	    }	}	disabled {	    if {[set index [lsearch $tags SLBDisabled]] == -1} {		bindtags $itk_component(listbox) \		    [linsert $tags 1 SLBDisabled]	    }	}	default {	    error "bad state value \"$itk_option(-state)\":\                   must be normal or disabled"	}    }}# ------------------------------------------------------------------#                            METHODS# ------------------------------------------------------------------# ------------------------------------------------------------------# METHOD: curselection ## Returns a list containing the indices of all the elements in the # listbox that are currently selected.# ------------------------------------------------------------------body iwidgets::Scrolledlistbox::curselection {} {    return [$itk_component(listbox) curselection]}# ------------------------------------------------------------------# METHOD: activate index## Sets the active element to the one indicated by index.# ------------------------------------------------------------------body iwidgets::Scrolledlistbox::activate {index} {    return [$itk_component(listbox) activate [_fixIndex $index]]}# ------------------------------------------------------------------# METHOD: bbox index## Returns four element list describing the bounding box for the list# item at index# ------------------------------------------------------------------body iwidgets::Scrolledlistbox::bbox {index} {    return [$itk_component(listbox) bbox [_fixIndex $index]]}# ------------------------------------------------------------------# METHOD clear ## Clear the listbox area of all items.# ------------------------------------------------------------------body iwidgets::Scrolledlistbox::clear {} {    delete 0 end}# ------------------------------------------------------------------# METHOD: see index## Adjusts the view such that the element given by index is visible.# ------------------------------------------------------------------body iwidgets::Scrolledlistbox::see {index} {    $itk_component(listbox) see [_fixIndex $index]}# ------------------------------------------------------------------# METHOD: index index## Returns the decimal string giving the integer index corresponding # to index.  The index value may be a integer number, active,# anchor, end, @x,y, or a pattern.# ------------------------------------------------------------------body iwidgets::Scrolledlistbox::index {index} {    if {[regexp {(^[0-9]+$)|(active)|(anchor)|(end)|(^@-?[0-9]+,-?[0-9]+$)} $index]} {	return [$itk_component(listbox) index $index]	    } else {	set indexValue [lsearch -glob [get 0 end] $index]		if {$indexValue == -1} {	    error "bad Scrolledlistbox index \"$index\": must be active, anchor, end, @x,y, number, or a pattern"	}		return $indexValue    }}# ------------------------------------------------------------------# METHOD: _fixIndex index## Similar to the regular "index" method, but it only converts# the index to a numerical value if it is a string pattern.  If# the index is in the proper form to be used with the listbox,# it is left alone.  This fixes problems associated with converting# an index such as "end" to a numerical value.# ------------------------------------------------------------------body iwidgets::Scrolledlistbox::_fixIndex {index} {    if {[regexp {(^[0-9]+$)|(active)|(anchor)|(end)|(^@[0-9]+,[0-9]+$)} $index]} {        return $index    } else {        set indexValue [lsearch -glob [get 0 end] $index]        if {$indexValue == -1} {            error "bad Scrolledlistbox index \"$index\": must be active, anchor, end, @x,y, number, or a pattern"        }        return $indexValue    }}# ------------------------------------------------------------------# METHOD: delete first ?last?## Delete one or more elements from list box based on the first and # last index values.  Indexes may be a number, active, anchor, end,# @x,y, or a pattern.# ------------------------------------------------------------------body iwidgets::Scrolledlistbox::delete {first {last {}}} {    set first [_fixIndex $first]        if {$last != {}} {	set last [_fixIndex $last]    } else {	set last $first    }        eval $itk_component(listbox) delete $first $last}# ------------------------------------------------------------------# METHOD: get first ?last?## Returns the elements of the listbox indicated by the indexes. # Indexes may be a number, active, anchor, end, @x,y, ora pattern.# ------------------------------------------------------------------body iwidgets::Scrolledlistbox::get {first {last {}}} {    set first [_fixIndex $first]        if {$last != {}} {	set last [_fixIndex $last]    }        if {$last == {}} {	return [$itk_component(listbox) get $first]    } else {	return [$itk_component(listbox) get $first $last]    }}# ------------------------------------------------------------------# METHOD: getcurselection ## Returns the contents of the listbox element indicated by the current # selection indexes.  Short cut version of get and curselection # command combination.# ------------------------------------------------------------------body iwidgets::Scrolledlistbox::getcurselection {} {    set rlist {}    if {[selecteditemcount] > 0} {	set cursels [$itk_component(listbox) curselection]    	switch $itk_option(-selectmode) {	    single -	    browse {		set rlist [$itk_component(listbox) get $cursels]	    }	    multiple -	    extended {		foreach sel $cursels {		    lappend rlist [$itk_component(listbox) get $sel]		}	    }	}    }        return $rlist}# ------------------------------------------------------------------# METHOD: insert index string ?string ...?## Insert zero or more elements in the list just before the element # given by index.# ------------------------------------------------------------------body iwidgets::Scrolledlistbox::insert {index string args} {    set index [_fixIndex $index]    set args [linsert $args 0 $string]    eval $itk_component(listbox) insert $index $args}# ------------------------------------------------------------------# METHOD: nearest y## Given a y-coordinate within the listbox, this command returns the # index of the visible listbox element nearest to that y-coordinate.# ------------------------------------------------------------------body iwidgets::Scrolledlistbox::nearest {y} {    $itk_component(listbox) nearest $y}# ------------------------------------------------------------------# METHOD: scan option args ## Implements scanning on listboxes.# ------------------------------------------------------------------body iwidgets::Scrolledlistbox::scan {option args} {    eval $itk_component(listbox) scan $option $args}# ------------------------------------------------------------------# METHOD: selection option first ?last?## Adjusts the selection within the listbox.  The index value may be # a integer number, active, anchor, end, @x,y, or a pattern.# ------------------------------------------------------------------body iwidgets::Scrolledlistbox::selection {option first {last {}}} {    set first [_fixIndex $first]        if {$last != {}} {	set last [_fixIndex $last]	$itk_component(listbox) selection $option $first $last    } else {	$itk_component(listbox) selection $option $first     }}# ------------------------------------------------------------------# METHOD: size ## Returns a decimal string indicating the total number of elements # in the listbox.# ------------------------------------------------------------------body iwidgets::Scrolledlistbox::size {} {    return [$itk_component(listbox) size]}# ------------------------------------------------------------------# METHOD: selecteditemcount ## Returns a decimal string indicating the total number of selected # elements in the listbox.# ------------------------------------------------------------------body iwidgets::Scrolledlistbox::selecteditemcount {} {    return [llength [$itk_component(listbox) curselection]]}# ------------------------------------------------------------------# METHOD: justify direction## Justifies the list scrolled region in one of four directions: top,# bottom, left, or right.# ------------------------------------------------------------------body iwidgets::Scrolledlistbox::justify {direction} {    switch $direction {	left { 	    $itk_component(listbox) xview moveto 0	}	right {	    $itk_component(listbox) xview moveto 1	}	top {	    $itk_component(listbox) yview moveto 0	}	bottom {	    $itk_component(listbox) yview moveto 1	}	default {	    error "bad justify argument \"$direction\": should\		    be left, right, top, or bottom"	}    }}# ------------------------------------------------------------------# METHOD: sort mode## Sort the current list in either "ascending/increasing" or # "descending/decreasing" order.# ------------------------------------------------------------------body iwidgets::Scrolledlistbox::sort {{mode ascending}} {    switch $mode {	ascending -	increasing {	    set vals [$itk_component(listbox) get 0 end]	    if {[llength $vals] != 0} {		$itk_component(listbox) delete 0 end		eval $itk_component(listbox) insert end \		    [lsort -increasing $vals]	    }	}	descending -	decreasing {	    set vals [$itk_component(listbox) get 0 end]	    if {[llength $vals] != 0} {		$itk_component(listbox) delete 0 end		eval $itk_component(listbox) insert end \		    [lsort -decreasing $vals]	    }	}	default {	    error "bad sort argument \"$mode\": should be\		    ascending, descending, increasing, or decreasing"	}    }}# ------------------------------------------------------------------# METHOD: xview args## Change or query the vertical position of the text in the list box.# ------------------------------------------------------------------body iwidgets::Scrolledlistbox::xview {args} {    return [eval $itk_component(listbox) xview $args]}# ------------------------------------------------------------------# METHOD: yview args## Change or query the horizontal position of the text in the list box.# ------------------------------------------------------------------body iwidgets::Scrolledlistbox::yview {args} {    return [eval $itk_component(listbox) yview $args]}# ------------------------------------------------------------------# METHOD: itemconfigure args## This is a wrapper method around the new tk8.3 itemconfigure command# for the listbox.# ------------------------------------------------------------------body iwidgets::Scrolledlistbox::itemconfigure {args} {    return [eval $itk_component(listbox) itemconfigure $args]}# ------------------------------------------------------------------# PROTECTED METHOD: _makeSelection ## Evaluate the selection command.# ------------------------------------------------------------------body iwidgets::Scrolledlistbox::_makeSelection {} {    uplevel #0 $itk_option(-selectioncommand)}# ------------------------------------------------------------------# PROTECTED METHOD: _dblclick ## Evaluate the double click command option if not empty.# ------------------------------------------------------------------body iwidgets::Scrolledlistbox::_dblclick {} {    uplevel #0 $itk_option(-dblclickcommand)}	

⌨️ 快捷键说明

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