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

📄 selectionbox.itk

📁 linux 下的源代码分析阅读器 red hat公司新版
💻 ITK
📖 第 1 页 / 共 2 页
字号:
body iwidgets::Selectionbox::childsite {} {    return $itk_component(sbchildsite)}# ------------------------------------------------------------------# METHOD: get ## Returns the current selection.# ------------------------------------------------------------------body iwidgets::Selectionbox::get {} {    return [$itk_component(selection) get]}# ------------------------------------------------------------------# METHOD: curselection## Returns the current selection index.# ------------------------------------------------------------------body iwidgets::Selectionbox::curselection {} {    return [$itk_component(items) curselection]}# ------------------------------------------------------------------# METHOD: clear component## Delete the contents of either the selection entry widget or items# list.# ------------------------------------------------------------------body iwidgets::Selectionbox::clear {component} {    switch $component {	selection {	    $itk_component(selection) clear	}		items {	    delete 0 end	}		default {	    error "bad clear argument \"$component\": should be\		   selection or items"	}    }}# ------------------------------------------------------------------# METHOD: insert component index args## Insert element(s) into either the selection or items list widget.# ------------------------------------------------------------------body iwidgets::Selectionbox::insert {component index args} {    switch $component {	selection {	    eval $itk_component(selection) insert $index $args	}		items {	    eval $itk_component(items) insert $index $args	}		default {	    error "bad insert argument \"$component\": should be\		   selection or items"	}    }}# ------------------------------------------------------------------# METHOD: delete first ?last?## Delete one or more elements from the items list box.  The default # is to delete by indexed range. If an item is to be removed by name, # it must be preceeded by the keyword "item". Only index numbers can # be used to delete a range of items. # ------------------------------------------------------------------body iwidgets::Selectionbox::delete {first {last {}}} {    set first [index $first]        if {$last != {}} {	set last [index $last]    } else {	set last $first    }        if {$first <= $last} {	eval $itk_component(items) delete $first $last    } else {	error "first index must not be greater than second"    }}# ------------------------------------------------------------------# METHOD: size ## Returns a decimal string indicating the total number of elements # in the items list.# ------------------------------------------------------------------body iwidgets::Selectionbox::size {} {    return [$itk_component(items) size]}# ------------------------------------------------------------------# METHOD: scan option args ## Implements scanning on items list.# ------------------------------------------------------------------body iwidgets::Selectionbox::scan {option args} {    eval $itk_component(items) scan $option $args}# ------------------------------------------------------------------# METHOD: nearest y## Returns the index to the nearest listbox item given a y coordinate.# ------------------------------------------------------------------body iwidgets::Selectionbox::nearest {y} {    return [$itk_component(items) nearest $y]}# ------------------------------------------------------------------# METHOD: index index## Returns the decimal string giving the integer index corresponding # to index.# ------------------------------------------------------------------body iwidgets::Selectionbox::index {index} {    return [$itk_component(items) index $index]}# ------------------------------------------------------------------# METHOD: selection option args## Adjusts the selection within the items list.# ------------------------------------------------------------------body iwidgets::Selectionbox::selection {option args} {    eval $itk_component(items) selection $option $args    selectitem}# ------------------------------------------------------------------# METHOD: selectitem## Replace the selection entry field contents with the currently # selected items value.# ------------------------------------------------------------------body iwidgets::Selectionbox::selectitem {} {    $itk_component(selection) clear    set numSelected [$itk_component(items) selecteditemcount]    if {$numSelected == 1} {	$itk_component(selection) insert end \	    [$itk_component(items) getcurselection]    } elseif {$numSelected > 1} {	$itk_component(selection) insert end \	    [lindex [$itk_component(items) getcurselection] 0]    }    $itk_component(selection) icursor end}# ------------------------------------------------------------------# PRIVATE METHOD: _packComponents ?when?## Pack the selection, items, and child site widgets based on options.# If "when" is "now", the change is applied immediately.  If it is # "later" or it is not specified, then the change is applied later, # when the application is idle.# ------------------------------------------------------------------body iwidgets::Selectionbox::_packComponents {{when later}} {    if {$when == "later"} {	if {$_repacking == ""} {	    set _repacking [after idle [code $this _packComponents now]]	}	return    } elseif {$when != "now"} {	error "bad option \"$when\": should be now or later"    }    set _repacking ""    set parent [winfo parent $itk_component(sbchildsite)]    set margin [winfo pixels $itk_component(hull) $itk_option(-margin)]    switch $itk_option(-childsitepos) {	n {	    grid $itk_component(sbchildsite) -row 0 -column 0 \		    -sticky nsew -rowspan 1	    grid $itk_component(items) -row 1 -column 0 -sticky nsew	    grid $itk_component(selection) -row 3 -column 0 -sticky ew	    	    grid rowconfigure $parent 0 -weight 0 -minsize 0	    grid rowconfigure $parent 1 -weight 1 -minsize 0	    grid rowconfigure $parent 2 -weight 0 -minsize $margin	    grid rowconfigure $parent 3 -weight 0 -minsize 0	    grid columnconfigure $parent 0 -weight 1 -minsize 0	    grid columnconfigure $parent 1 -weight 0 -minsize 0	}		w {	    grid $itk_component(sbchildsite) -row 0 -column 0 \		    -sticky nsew -rowspan 3	    grid $itk_component(items) -row 0 -column 1 -sticky nsew	    grid $itk_component(selection) -row 2 -column 1 -sticky ew	    	    grid rowconfigure $parent 0 -weight 1 -minsize 0	    grid rowconfigure $parent 1 -weight 0 -minsize $margin	    grid rowconfigure $parent 2 -weight 0 -minsize 0	    grid rowconfigure $parent 3 -weight 0 -minsize 0	    grid columnconfigure $parent 0 -weight 0 -minsize 0	    grid columnconfigure $parent 1 -weight 1 -minsize 0	}		s {	    grid $itk_component(items) -row 0 -column 0 -sticky nsew	    grid $itk_component(selection) -row 2 -column 0 -sticky ew	    grid $itk_component(sbchildsite) -row 3 -column 0 \		    -sticky nsew -rowspan 1	    	    grid rowconfigure $parent 0 -weight 1 -minsize 0	    grid rowconfigure $parent 1 -weight 0 -minsize $margin	    grid rowconfigure $parent 2 -weight 0 -minsize 0	    grid rowconfigure $parent 3 -weight 0 -minsize 0	    grid columnconfigure $parent 0 -weight 1 -minsize 0	    grid columnconfigure $parent 1 -weight 0 -minsize 0	}		e {	    grid $itk_component(items) -row 0 -column 0 -sticky nsew	    grid $itk_component(selection) -row 2 -column 0 -sticky ew	    grid $itk_component(sbchildsite) -row 0 -column 1 \		    -sticky nsew -rowspan 3	    	    grid rowconfigure $parent 0 -weight 1 -minsize 0	    grid rowconfigure $parent 1 -weight 0 -minsize $margin	    grid rowconfigure $parent 2 -weight 0 -minsize 0	    grid rowconfigure $parent 3 -weight 0 -minsize 0	    grid columnconfigure $parent 0 -weight 1 -minsize 0	    grid columnconfigure $parent 1 -weight 0 -minsize 0	}		center {	    grid $itk_component(items) -row 0 -column 0 -sticky nsew	    grid $itk_component(sbchildsite) -row 1 -column 0 \		    -sticky nsew -rowspan 1	    grid $itk_component(selection) -row 3 -column 0 -sticky ew	    	    grid rowconfigure $parent 0 -weight 1 -minsize 0	    grid rowconfigure $parent 1 -weight 0 -minsize 0	    grid rowconfigure $parent 2 -weight 0 -minsize $margin	    grid rowconfigure $parent 3 -weight 0 -minsize 0	    grid columnconfigure $parent 0 -weight 1 -minsize 0	    grid columnconfigure $parent 1 -weight 0 -minsize 0	}		default {	    error "bad childsitepos option \"$itk_option(-childsitepos)\":\		   should be n, e, s, w, or center"	}    }        if {$itk_option(-itemson)} {    } else {	grid forget $itk_component(items)    }        if {$itk_option(-selectionon)} {    } else {	grid forget $itk_component(selection)    }        raise $itk_component(sbchildsite)}

⌨️ 快捷键说明

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