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

📄 combobox.itk

📁 openRisc2000编译链接器等,用于i386 cygwin
💻 ITK
📖 第 1 页 / 共 4 页
字号:
	_dropdownBindings	# Ugly hack to avoid tk buglet revealed in _dropdownBtnRelease where 	# relief is used but not set in scrollbar.tcl. 	global tkPriv	set tkPriv(relief) raise    } else {	# --- build a simple combobox ---	configure -childsitepos s	itk_component add list {	    iwidgets::Scrolledlistbox $itk_interior.list -exportselection no \		-vscrollmode dynamic -hscrollmode dynamic 	} {	    keep -background -borderwidth -cursor -foreground \		-highlightcolor -highlightthickness \		-hscrollmode -selectbackground \		-selectborderwidth -selectforeground -textbackground \		-textfont -visibleitems -vscrollmode 	    rename -height -listheight listHeight Height	}	# add mode specific bindings	_simpleBindings    }    # popup cursor applies only to the list within the combobox    configure -popupcursor $itk_option(-popupcursor)    # add mode independent bindings    _commonBindings}# ------------------------------------------------------# PROTECTED METHOD: _deleteList first ?last?## Delete an item or items from the listbox. Called via # "delete list args".## ------------------------------------------------------itcl::body iwidgets::Combobox::_deleteList {first {last {}}} {    if {$last == {}} {	set last $first    }    $itk_component(list) delete $first $last    # remove the item if it is no longer in the list    set text [$this get]    if {$text != ""} {	set index [lsearch -exact [$itk_component(list) get 0 end] $text ]	if {$index == -1} {	    clear entry	}    }    return}# ------------------------------------------------------# PROTECTED METHOD: _deleteText first ?last?## Renamed Entryfield delete method. Called via "delete entry args".## ------------------------------------------------------itcl::body iwidgets::Combobox::_deleteText {first {last {}}} {    $itk_component(entry) configure -state normal     set rtrn [delete $first $last]    switch -- $itk_option(-editable) {	0 - false - no - off {	    $itk_component(entry) configure -state disabled	}    }    return $rtrn}# ------------------------------------------------------# PROTECTED METHOD:	  _doLayout ?when?## Call methods to create and pack the Combobox components.## ------------------------------------------------------itcl::body iwidgets::Combobox::_doLayout {{when later}} {    _createComponents    _packComponents $when}# ------------------------------------------------------# PROTECTED METHOD:	  _drawArrow ## Draw the arrow button. Determines packing according to# -labelpos.## ------------------------------------------------------itcl::body iwidgets::Combobox::_drawArrow {} {    set flip false    set relief ""    set fg [cget -foreground]    if {$_isPosted} {	set flip true	set relief "-relief sunken"    } else {	set relief "-relief $itk_option(-arrowrelief)"    }    if {$flip} {	#	 	#				draw up arrow	#	eval $itk_component(arrowBtn) configure -image uparrow $relief    } else {	#	 	#				draw down arrow	#	eval $itk_component(arrowBtn) configure -image downarrow $relief    }}# ------------------------------------------------------# PROTECTED METHOD: _dropdownBtnRelease window x y## Event handler for button releases while a dropdown list# is posted.## ------------------------------------------------------itcl::body iwidgets::Combobox::_dropdownBtnRelease {{window {}} {x 1} {y 1}} {    # if it's a scrollbar then ignore the release    if {($window == [$itk_component(list) component vertsb]) ||	($window == [$itk_component(list) component horizsb])} {	return    }    # 1st release allows list to stay up unless we are in listbox    if {$_ignoreRelease} {	_ignoreNextBtnRelease false	return    }        # should I use just the listbox or also include the scrollbars    if { ($x >= 0) && ($x < [winfo width [_slbListbox]])	 && ($y >= 0) && ($y < [winfo height [_slbListbox]])} {	_stateSelect    }        _unpostList    # execute user command    if {$itk_option(-selectioncommand) != ""} {	uplevel #0 $itk_option(-selectioncommand)    }}# ------------------------------------------------------# PROTECTED METHOD: _ignoreNextBtnRelease ignore## Set private variable _ignoreRelease. If this variable# is true then the next button release will not remove# a dropdown list.## ------------------------------------------------------itcl::body iwidgets::Combobox::_ignoreNextBtnRelease {ignore} {    set _ignoreRelease $ignore}# ------------------------------------------------------# PROTECTED METHOD:	  _next## Select the next item in the list.## ------------------------------------------------------itcl::body iwidgets::Combobox::_next {} {    set _next_prevFLAG 1    if {[size] <= 1} {	return    }    set i [curselection]    if {($i == {}) || ($i == ([size]-1)) } {	set i 0    } else {	incr i    }    selection clear 0 end    selection set $i $i    see $i    set _currItem $i}# ------------------------------------------------------# PROTECTED METHOD:	  _packComponents ?when?## Pack the components of the combobox and add bindings.## ------------------------------------------------------itcl::body iwidgets::Combobox::_packComponents {{when later}} {    if {$when == "later"} {	if {$_repacking == ""} {	    set _repacking [after idle [itcl::code $this _packComponents now]]	    return	}    } elseif {$when != "now"} {	error "bad option \"$when\": should be now or later"    }    if {$itk_option(-dropdown)} {	grid configure $itk_component(list) -row 1 -column 0 -sticky news	_resizeArrow        grid config $itk_component(arrowBtn) -row 0 -column 1 -sticky nsew    } else {	# size and pack list hack	grid configure $itk_component(entry) -row 0 -column 0 -sticky ew	grid configure $itk_component(efchildsite) -row 1 -column 0 -sticky nsew	grid configure $itk_component(list) -row 0 -column 0 -sticky nsew	grid rowconfigure $itk_component(efchildsite) 1 -weight 1	grid columnconfigure $itk_component(efchildsite) 0 -weight 1    }    set _repacking ""}# ------------------------------------------------------# PROTECTED METHOD:	  _positionList## Determine the position (geometry) for the popped up list# and map it to the screen.## ------------------------------------------------------itcl::body iwidgets::Combobox::_positionList {} {    set x [winfo rootx $itk_component(entry) ]    set y [expr {[winfo rooty $itk_component(entry) ] + \	       [winfo height $itk_component(entry) ]}]    set w [winfo width $itk_component(entry) ]    set h [winfo height [_slbListbox] ]    set sh [winfo screenheight .]    if {(($y+$h) > $sh) && ($y > ($sh/2))} {	set y [expr {[winfo rooty $itk_component(entry) ] - $h}]    }        $itk_component(list) configure -width $w    wm overrideredirect $itk_component(popup) 0    wm geometry $itk_component(popup) +$x+$y    wm overrideredirect $itk_component(popup) 1}# ------------------------------------------------------# PROTECTED METHOD:	  _postList## Pop up the list in a dropdown style Combobox.## ------------------------------------------------------itcl::body iwidgets::Combobox::_postList {} {    if {[$itk_component(list) size] == ""} {	return    }    set _isPosted true    _positionList    # map window and do a grab    wm deiconify $itk_component(popup)    _listShowing -wait    # Added by csmith, 12/19/00.  Thanks to Erik Leunissen for    # finding this problem.  We need to restore any previous    # grabs after the dropdown listbox is withdrawn.  To do this,    # save the currently grabbed window.  It is then restored in    # the _unpostList method.    set _grab(window) [::grab current]    if {$_grab(window) != ""} {      set _grab(status) [::grab status $_grab(window)]    }    # Now grab the dropdown listbox.    if {$itk_option(-grab) == "global"} {	::grab -global $itk_component(popup)     } else {	::grab $itk_component(popup)     }    raise $itk_component(popup)    focus $itk_component(popup)    _drawArrow    # Added by csmith, 10/26/00.  This binding keeps the listbox    # from staying mapped if the window in which the combobox    # is packed is iconified.    bind $itk_component(entry) <Unmap> [itcl::code $this _unpostList]}# ------------------------------------------------------# PROTECTED METHOD:	   _previous## Select the previous item in the list. Wraps at front# and end of list. ## ------------------------------------------------------itcl::body iwidgets::Combobox::_previous {} {    set _next_prevFLAG 1    if {[size] <= 1} {	return    }    set i [curselection]    if {$i == "" || $i == 0} {	set i [expr {[size] - 1}]    } else {	incr i -1    }    selection clear 0 end    selection set $i $i    see $i    set _currItem $i}# ------------------------------------------------------# PROTECTED METHOD:	  _resizeArrow## Recalculate the arrow button size and then redraw it.## ------------------------------------------------------itcl::body iwidgets::Combobox::_resizeArrow {} {    set bw [expr {[$itk_component(arrowBtn) cget -borderwidth]+ \		[$itk_component(arrowBtn) cget -highlightthickness]}]    set newHeight [expr {[winfo reqheight $itk_component(entry)]-(2*$bw) - 2}]    $itk_component(arrowBtn) configure -width $newHeight -height $newHeight    _drawArrow}# ------------------------------------------------------# PROTECTED METHOD:	  _selectCmd## Called when list item is selected to insert new text # in entry, and call user -command callback if defined.## ------------------------------------------------------itcl::body iwidgets::Combobox::_selectCmd {} {    $itk_component(entry) configure -state normal        set _currItem [$itk_component(list) curselection]    set item [$itk_component(list) getcurselection]    clear entry    $itk_component(entry) insert 0 $item    switch -- $itk_option(-editable) {	0 - false - no - off {	    $itk_component(entry) configure -state disabled	}    }}# ------------------------------------------------------# PROTECTED METHOD:	 _toggleList## Post or unpost the dropdown listbox (toggle).## ------------------------------------------------------itcl::body iwidgets::Combobox::_toggleList {} {    if {[winfo ismapped $itk_component(popup)] } {	_unpostList

⌨️ 快捷键说明

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