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

📄 combobox.itk

📁 windows下的GDB insight前端
💻 ITK
📖 第 1 页 / 共 4 页
字号:
# Combobox# ----------------------------------------------------------------------# Implements a Combobox widget. A Combobox has 2 basic styles: simple and# dropdown. Dropdowns display an entry field with an arrow button to the # right of it. When the arrow button is pressed a selectable list of# items is popped up. A simple Combobox displays an entry field and a listbox # just beneath it which is always displayed. In both types, if the user # selects an item in the listbox, the contents of the entry field are # replaced with the text from the selected item. If the Combobox is # editable, the user can type in the entry field and when <Return> is# pressed the item will be inserted into the list.## WISH LIST:#	This section lists possible future enhancements.  ##	  Combobox 1.x:#		  - convert bindings to bindtags.## ----------------------------------------------------------------------#  ORIGINAL AUTHOR: John S. Sigler# ----------------------------------------------------------------------#  CURRENT MAINTAINER: Chad Smith	EMAIL: csmith@adc.com, itclguy@yahoo.com##					Copyright (c) 1995	John S. Sigler#					Copyright (c) 1997	Mitch Gorman# ======================================================================# Permission is hereby granted, without written agreement and without# license or royalty fees, to use, copy, modify, and distribute this# software and its documentation for any purpose, provided that the# above copyright notice and the following two paragraphs appear in# all copies of this software.# # IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR# DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES # ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN # IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH # DAMAGE.## THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, # BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND # FITNESS FOR A PARTICULAR PURPOSE.	 THE SOFTWARE PROVIDED HEREUNDER IS# ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO# PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.# ======================================================================## Default resources.#option add *Combobox.borderWidth 2 widgetDefaultoption add *Combobox.labelPos wn widgetDefaultoption add *Combobox.listHeight 150 widgetDefaultoption add *Combobox.hscrollMode dynamic widgetDefaultoption add *Combobox.vscrollMode dynamic widgetDefault## Usual options.#itk::usual Combobox {    keep -background -borderwidth -cursor -foreground -highlightcolor \	-highlightthickness -insertbackground -insertborderwidth \	-insertofftime -insertontime -insertwidth -labelfont -popupcursor \	-selectbackground -selectborderwidth -selectforeground \	-textbackground -textfont}# ------------------------------------------------------------------#							 COMBOBOX# ------------------------------------------------------------------itcl::class iwidgets::Combobox {    inherit iwidgets::Entryfield        constructor {args} {}    destructor {}    itk_option define -arrowrelief arrowRelief Relief raised    itk_option define -completion completion Completion true    itk_option define -dropdown dropdown Dropdown true    itk_option define -editable editable Editable true    itk_option define -grab grab Grab local    itk_option define -listheight listHeight Height 150    itk_option define -margin margin Margin 1    itk_option define -popupcursor popupCursor Cursor arrow    itk_option define -selectioncommand selectionCommand SelectionCommand {}    itk_option define -state state State normal    itk_option define -unique unique Unique true    public method clear {{component all}}    public method curselection {}    public method delete {component first {last {}}}    public method get {{index {}}}    public method getcurselection {}    public method insert {component index args}    public method invoke {}    public method justify {direction}    public method see {index}    public method selection {option first {last {}}}    public method size {}    public method sort {{mode ascending}}    public method xview {args}    public method yview {args}    protected method _addToList {}    protected method _createComponents {}    protected method _deleteList {first {last {}}}    protected method _deleteText {first {last {}}}    protected method _doLayout {{when later}}    protected method _drawArrow {}    protected method _dropdownBtnRelease {{window {}} {x 1} {y 1}}    protected method _ignoreNextBtnRelease {ignore}    protected method _next {}    protected method _packComponents {{when later}}    protected method _positionList {}    protected method _postList {}    protected method _previous {}    protected method _resizeArrow {}    protected method _selectCmd {}    protected method _toggleList {}    protected method _unpostList {}    protected method _commonBindings {}    protected method _dropdownBindings {}    protected method _simpleBindings {}    protected method _listShowing {{val ""}}    private method _bs {}    private method _lookup {key}    private method _slbListbox {}    private method _stateSelect {}    private variable _doit 0;    private variable _inbs 0;    private variable _inlookup 0;    private variable _currItem {};			 ;# current selected item.    private variable _ignoreRelease false	 ;# next button release ignored.    private variable _isPosted false;		 ;# is the dropdown popped up.    private variable _repacking {}	  ;# non-null => _packComponents pending.    private variable _grab                ;# used to restore grabs    private variable _next_prevFLAG 0 ;# Used in _lookup to fix SF Bug 501300    private common _listShowing    private common count 0}	 ## Provide a lowercase access method for the Combobox class.# proc ::iwidgets::combobox {pathName args} {    uplevel ::iwidgets::Combobox $pathName $args}# ------------------------------------------------------------------#						CONSTRUCTOR# ------------------------------------------------------------------itcl::body iwidgets::Combobox::constructor {args} {    set _listShowing($this) 0    set _grab(window) ""    set _grab(status) ""    # combobox is different as all components are created     # after determining what the dropdown style is...    # configure args    eval itk_initialize $args        # create components that are dependent on options     # (Scrolledlistbox, arrow button) and pack them.    if {$count == 0} {	image create bitmap downarrow -data {	    #define down_width 16	    #define down_height 16	    static unsigned char down_bits[] = {		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 		0x00, 0x00, 0x00, 0x00, 0xfc, 0x7f, 0xf8, 0x3f, 		0xf0, 0x1f, 0xe0, 0x0f, 0xc0, 0x07, 0x80, 0x03, 		0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00	    };	}	image create bitmap uparrow -data {	    #define up_width 16	    #define up_height 16	    static unsigned char up_bits[] = {		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 		0xc0, 0x01, 0xe0, 0x03, 0xf0, 0x07, 0xf8, 0x0f, 		0xfc, 0x1f, 0xfe, 0x3f, 0x00, 0x00, 0x00, 0x00,		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00	    };	}    }    incr count    _doLayout}# ------------------------------------------------------------------#						   DESTRUCTOR# ------------------------------------------------------------------itcl::body iwidgets::Combobox::destructor {} {    # catch any repacking that may be waiting for idle time    if {$_repacking != ""} {	after cancel $_repacking    }    incr count -1    if {$count == 0} {	image delete uparrow	image delete downarrow    }}# ================================================================#							OPTIONS# ================================================================# --------------------------------------------------------------------# OPTION:  -arrowrelief## Relief style used on the arrow button.# --------------------------------------------------------------------itcl::configbody iwidgets::Combobox::arrowrelief {}# --------------------------------------------------------------------# OPTION:  -completion## Relief style used on the arrow button.# --------------------------------------------------------------------itcl::configbody iwidgets::Combobox::completion {    switch -- $itk_option(-completion) {	0 - no - false - off { }	1 - yes - true - on { }	default {	    error "bad completion option \"$itk_option(-completion)\":\					   should be boolean"	}    }}# --------------------------------------------------------------------# OPTION:  -dropdown  ## Boolean which determines the Combobox style: dropdown or simple.# Because the two style's lists reside in different toplevel widgets# this is more complicated than it should be.# --------------------------------------------------------------------itcl::configbody iwidgets::Combobox::dropdown {    switch -- $itk_option(-dropdown) {	1 - yes - true - on {	    if {[winfo exists $itk_interior.list]} {		set vals [$itk_component(list) get 0 end]		destroy $itk_component(list)		_doLayout		if [llength $vals] {		    eval insert list end $vals		}	    }	}	0 - no - false - off {	    if {[winfo exists $itk_interior.popup.list]} {		set vals [$itk_component(list) get 0 end]		catch {destroy $itk_component(arrowBtn)}		destroy $itk_component(popup)  ;# this deletes the list too		_doLayout		if [llength $vals] {		    eval insert list end $vals		}	    }	}	default {	    error "bad dropdown option \"$itk_option(-dropdown)\":\					   should be boolean"	}    }}# --------------------------------------------------------------------# OPTION: -editable	 ## Boolean which allows/disallows user input to the entry field area.# --------------------------------------------------------------------itcl::configbody iwidgets::Combobox::editable {    switch -- $itk_option(-editable) {	1 - true - yes - on {	    switch -- $itk_option(-state) {		normal {		    $itk_component(entry) configure -state normal		}	    }	}	0 - false - no - off {	    $itk_component(entry) configure -state disabled	}	default {	    error "bad editable option \"$itk_option(-editable)\":\				   should be boolean"	}    }}# --------------------------------------------------------------------# OPTION:  -grab## grab-state of megawidget# --------------------------------------------------------------------itcl::configbody iwidgets::Combobox::grab {    switch -- $itk_option(-grab) {	local { }	global { }	default {	    error "bad grab value \"$itk_option(-grab)\":\				   must be global or local"	}    }}# --------------------------------------------------------------------# OPTION: -listheight  ## Listbox height in pixels. (Need to integrate the scrolledlistbox# -visibleitems option here - at least for simple listbox.)# --------------------------------------------------------------------itcl::configbody iwidgets::Combobox::listheight {}# --------------------------------------------------------------------# OPTION:  -margin## Spacer between the entry field and arrow button of dropdown style# Comboboxes.# --------------------------------------------------------------------itcl::configbody iwidgets::Combobox::margin {    grid columnconfigure $itk_interior 0 -minsize $itk_option(-margin)}# --------------------------------------------------------------------# OPTION:  -popupcursor## Set the cursor for the popup list.# --------------------------------------------------------------------itcl::configbody iwidgets::Combobox::popupcursor {}# --------------------------------------------------------------------# OPTION:  -selectioncommand## Defines the proc to be called when an item is selected in the list.# --------------------------------------------------------------------itcl::configbody iwidgets::Combobox::selectioncommand {}# --------------------------------------------------------------------# OPTION:  -state## overall state of megawidget# --------------------------------------------------------------------itcl::configbody iwidgets::Combobox::state {    switch -- $itk_option(-state) {	disabled {	    $itk_component(entry) configure -state disabled	}	normal {	    switch -- $itk_option(-editable) {		1 - true - yes - on {		    $itk_component(entry) configure -state normal		}		0 - false - no - off {		    $itk_component(entry) configure -state disabled		}	    }	}

⌨️ 快捷键说明

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