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

📄 combobox.itk

📁 windows下的GDB insight前端
💻 ITK
📖 第 1 页 / 共 4 页
字号:
	readonly {	  $itk_component(entry) configure -state readonly	}	default {	    error "bad state value \"$itk_option(-state)\":\				   must be normal  or disabled"	}    }    if {[info exists itk_component(arrowBtn)]} {	$itk_component(arrowBtn) configure -state $itk_option(-state)    }}# --------------------------------------------------------------------# OPTION: -unique  ## Boolean which disallows/allows adding duplicate items to the listbox.# --------------------------------------------------------------------itcl::configbody iwidgets::Combobox::unique {    # boolean error check    switch -- $itk_option(-unique) {	1 - true - yes - on { }	0 - false - no - off { }	default {	    error "bad unique value \"$itk_option(-unique)\":\				   should be boolean"	}    }}# =================================================================#							 METHODS# =================================================================# ------------------------------------------------------#  PUBLIC METHOD: clear ?component?##  Remove all elements from the listbox, all contents#  from the entry component, or both (if all).## ------------------------------------------------------itcl::body iwidgets::Combobox::clear {{component all}} {    switch -- $component {	entry {	    iwidgets::Entryfield::clear	}	list {	    delete list 0 end	}	all {	    delete list 0 end	    iwidgets::Entryfield::clear	}	default {	    error "bad Combobox component \"$component\":\				   must be entry, list, or all."	}    }    return}# ------------------------------------------------------# PUBLIC METHOD: curselection## Return the current selection index.## ------------------------------------------------------itcl::body iwidgets::Combobox::curselection {} {    return [$itk_component(list) curselection]}# ------------------------------------------------------# PUBLIC METHOD: delete component first ?last?## Delete an item or items from the listbox OR delete# text from the entry field. First argument determines# which component deletion occurs in - valid values are# entry or list.## ------------------------------------------------------itcl::body iwidgets::Combobox::delete {component first {last {}}} {    switch -- $component {	entry {	    if {$last == {}} {	      set last [expr {$first + 1}]	    }	    iwidgets::Entryfield::delete $first $last	}	list {	    _deleteList $first $last	}	default {	    error "bad Combobox component \"$component\":\				   must be entry or list."	}    }}# ------------------------------------------------------# PUBLIC METHOD: get ?index?### Retrieve entry contents if no args OR use args as list # index and retrieve list item at index .## ------------------------------------------------------itcl::body iwidgets::Combobox::get {{index {}}} {    # no args means to get the current text in the entry field area    if {$index == {}} {	iwidgets::Entryfield::get    } else {	eval $itk_component(list) get $index    }}# ------------------------------------------------------# PUBLIC METHOD: getcurselection## Return currently selected item in the listbox. Shortcut# version of get curselection command combination.## ------------------------------------------------------itcl::body iwidgets::Combobox::getcurselection {} {    return [$itk_component(list) getcurselection]}# ------------------------------------------------------------------# PUBLIC METHOD: invoke## Pops up or down a dropdown combobox.# # ------------------------------------------------------------------itcl::body iwidgets::Combobox::invoke {} {    if {$itk_option(-dropdown)} {	return [_toggleList]    }    return }# ------------------------------------------------------------# PUBLIC METHOD: insert comonent index string ?string ...?## Insert an item into the listbox OR text into the entry area.# Valid component names are entry or list.## ------------------------------------------------------------itcl::body iwidgets::Combobox::insert {component index args} {    set nargs [llength $args]    if {$nargs == 0} {	error "no value given for parameter \"string\" in function\			   \"Combobox::insert\""    }     switch -- $component {	entry {	    if { $nargs > 1} {		error "called function \"Combobox::insert entry\"\					   with too many arguments"	    } else {		if {$itk_option(-state) == "normal"} {		    eval iwidgets::Entryfield::insert $index $args		    [itcl::code $this _lookup ""]		}	    }	}	list {	    if {$itk_option(-state) == "normal"} {		eval $itk_component(list) insert $index $args	    }	}	default {	    error "bad Combobox component \"$component\": must\				   be entry or list."	}    }}# ------------------------------------------------------# PUBLIC METHOD: justify direction## Wrapper for justifying the listbox items in one of# 4 directions:	 top, bottom, left, or right.## ------------------------------------------------------itcl::body iwidgets::Combobox::justify {direction} {    return [$itk_component(list) justify $direction]}# ------------------------------------------------------------------# PUBLIC METHOD: see index## Adjusts the view such that the element given by index is visible.# ------------------------------------------------------------------itcl::body iwidgets::Combobox::see {index} {    return [$itk_component(list) see $index]}# ------------------------------------------------------------------# PUBLIC METHOD: selection option first ?last?## Adjusts the selection within the listbox and changes the contents# of the entry component to be the value of the selected list item.# ------------------------------------------------------------------itcl::body iwidgets::Combobox::selection {option first {last {}}} {    # thin wrap    if {$option == "set"} {	$itk_component(list) selection clear 0 end	$itk_component(list) selection set $first	set rtn ""    } else {	set rtn [eval $itk_component(list) selection $option $first $last]    }    set _currItem $first    # combobox additions    set theText [getcurselection]    if {$theText != [$itk_component(entry) get]} {	clear entry	if {$theText != ""} {	    insert entry 0 $theText	}    }    return $rtn}# ------------------------------------------------------------------# PUBLIC METHOD: size ## Returns a decimal string indicating the total number of elements # in the listbox.# ------------------------------------------------------------------itcl::body iwidgets::Combobox::size {} {    return [$itk_component(list) size]}# ------------------------------------------------------# PUBLIC METHOD: sort ?mode?## Sort the current list in either "ascending" or "descending" order.##	jss: how should i handle selected items?## ------------------------------------------------------itcl::body iwidgets::Combobox::sort {{mode ascending}} {    $itk_component(list) sort $mode    #	 return [$itk_component(list) sort $mode]}# ------------------------------------------------------------------# PUBLIC METHOD: xview ?arg arg ...?## Change or query the vertical position of the text in the list box.# ------------------------------------------------------------------itcl::body iwidgets::Combobox::xview {args} {    return [eval $itk_component(list) xview $args]}# ------------------------------------------------------------------# PUBLIC METHOD: yview ?arg arg ...?## Change or query the horizontal position of the text in the list box.# ------------------------------------------------------------------itcl::body iwidgets::Combobox::yview {args} {    return [eval $itk_component(list) yview $args]}# ------------------------------------------------------# PROTECTED METHOD: _addToList## Add the current item in the entry to the listbox.## ------------------------------------------------------itcl::body iwidgets::Combobox::_addToList {} {    set input [get]    if {$input != ""} {	if {$itk_option(-unique)} {	    # if item is already in list, select it and exit	    set item [lsearch -exact [$itk_component(list) get 0 end] $input]	    if {$item != -1} {		selection clear 0 end		if {$item != {}} {		    selection set $item $item		    set _currItem $item		}		return	    }	}	# add the item to end of list	selection clear 0 end	insert list end $input	selection set end end    }}# ------------------------------------------------------# PROTECTED METHOD:	  _createComponents## Create deferred combobox components and add bindings.## ------------------------------------------------------itcl::body iwidgets::Combobox::_createComponents {} {    if {$itk_option(-dropdown)} {	# --- build a dropdown combobox ---	# make the arrow childsite be on the right hand side  	#-------------------------------------------------------------	# BUG FIX: csmith (Chad Smith: csmith@adc.com), 3/4/99  	#-------------------------------------------------------------	# The following commented line of code overwrites the -command	# option when passed into the constructor.  The order of calls	# in the constructor is:	# 	1) eval itk_initalize $args (initializes -command)	#       2) _doLayout	#       3) _createComponents (overwrites -command)	# The solution is to only set the -command option if it hasn't	# already been set.  The following 4 lines of code do this.  	#-------------------------------------------------------------	# ** configure -childsitepos e -command [code $this _addToList]  	#-------------------------------------------------------------	configure -childsitepos e	if ![llength [cget -command]] {	  configure -command [itcl::code $this _addToList]	}		# arrow button to popup the list	itk_component add arrowBtn {	    button $itk_interior.arrowBtn -borderwidth 2 \		-width 15 -height 15 -image downarrow \		-command [itcl::code $this _toggleList] -state $itk_option(-state)	} {	    keep -background -borderwidth -cursor  -state \		-highlightcolor -highlightthickness	    rename -relief -arrowrelief arrowRelief Relief	    rename -highlightbackground -background background Background	}		# popup list container	itk_component add popup {	    toplevel $itk_interior.popup	} {	    keep -background -cursor	}	wm withdraw $itk_interior.popup		# the listbox	itk_component add list {	    iwidgets::Scrolledlistbox $itk_interior.popup.list -exportselection no \		-vscrollmode dynamic -hscrollmode dynamic -selectmode browse	} {	    keep -background -borderwidth -cursor -foreground \		-highlightcolor -highlightthickness \		-hscrollmode -selectbackground \		-selectborderwidth -selectforeground -textbackground \		-textfont -vscrollmode	    rename -height -listheight listHeight Height	    rename -cursor -popupcursor popupCursor Cursor	}	# mode specific bindings

⌨️ 快捷键说明

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