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

📄 buttonbox.itk

📁 这是一个Linux下的集成开发环境
💻 ITK
📖 第 1 页 / 共 2 页
字号:
## Buttonbox# ----------------------------------------------------------------------# Manages a framed area with Motif style buttons.  The button box can # be configured either horizontally or vertically.  ## ----------------------------------------------------------------------#  AUTHOR: Mark L. Ulferts              EMAIL: mulferts@austin.dsccc.com#          Bret A. Schuhmacher          EMAIL: bas@wn.com##  @(#) $Id: buttonbox.itk,v 1.1 2003/02/05 10:54:05 mdejong Exp $# ----------------------------------------------------------------------#            Copyright (c) 1995 DSC Technologies Corporation# ======================================================================# Permission to use, copy, modify, distribute and license this software # and its documentation for any purpose, and without fee or written # agreement with DSC, is hereby granted, provided that the above copyright # notice appears in all copies and that both the copyright notice and # warranty disclaimer below appear in supporting documentation, and that # the names of DSC Technologies Corporation or DSC Communications # Corporation not be used in advertising or publicity pertaining to the # software without specific, written prior permission.# # DSC DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING # ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, AND NON-# INFRINGEMENT. THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, AND THE# AUTHORS AND DISTRIBUTORS HAVE NO OBLIGATION TO PROVIDE MAINTENANCE, # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. IN NO EVENT SHALL # DSC BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR # ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, # WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTUOUS ACTION,# ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS # SOFTWARE.# ======================================================================## Usual options.#itk::usual Buttonbox {    keep -background -cursor -foreground}# ------------------------------------------------------------------#                            BUTTONBOX# ------------------------------------------------------------------class iwidgets::Buttonbox {    inherit itk::Widget    constructor {args} {}    destructor {}    itk_option define -pady padY Pad 5    itk_option define -padx padX Pad 5    itk_option define -orient orient Orient "horizontal"    itk_option define -foreground foreground Foreground black        public method index {args}    public method add {args}    public method insert {args}    public method delete {args}    public method default {args}    public method hide {args}    public method show {args}    public method invoke {args}    public method buttonconfigure {args}    public method buttoncget {index option}    private method _positionButtons {}    private method _setBoxSize {{when later}}    private method _getMaxWidth {}    private method _getMaxHeight {}    private variable _resizeFlag {}         ;# Flag for resize needed.    private variable _buttonList {}         ;# List of all buttons in box.    private variable _displayList {}        ;# List of displayed buttons.    private variable _unique 0              ;# Counter for button widget ids.}namespace eval iwidgets::Buttonbox {    #    # Set up some class level bindings for map and configure events.    #    bind bbox-map <Map> [code %W _setBoxSize]    bind bbox-config <Configure> [code %W _positionButtons]}## Provide a lowercased access method for the Buttonbox class.# proc ::iwidgets::buttonbox {pathName args} {    uplevel ::iwidgets::Buttonbox $pathName $args}    # ------------------------------------------------------------------#                        CONSTRUCTOR# ------------------------------------------------------------------body iwidgets::Buttonbox::constructor {args} {    #     # Add Configure bindings for geometry management.      #    bindtags $itk_component(hull) \	    [linsert [bindtags $itk_component(hull)] 0 bbox-map]    bindtags $itk_component(hull) \	    [linsert [bindtags $itk_component(hull)] 1 bbox-config]        pack propagate $itk_component(hull) no        #    # Initialize the widget based on the command line options.    #    eval itk_initialize $args}# ------------------------------------------------------------------#                           DESTRUCTOR# ------------------------------------------------------------------body iwidgets::Buttonbox::destructor {} {    if {$_resizeFlag != ""} {after cancel $_resizeFlag}}# ------------------------------------------------------------------#                             OPTIONS# ------------------------------------------------------------------# ------------------------------------------------------------------# OPTION: -pady## Pad the y space between the button box frame and the hull.# ------------------------------------------------------------------configbody iwidgets::Buttonbox::pady {    _setBoxSize}# ------------------------------------------------------------------# OPTION: -padx## Pad the x space between the button box frame and the hull.# ------------------------------------------------------------------configbody iwidgets::Buttonbox::padx {    _setBoxSize}# ------------------------------------------------------------------# OPTION: -orient## Position buttons either horizontally or vertically.# ------------------------------------------------------------------configbody iwidgets::Buttonbox::orient {    switch $itk_option(-orient) {	"horizontal" -	"vertical" {	    _setBoxSize	}		default {	    error "bad orientation option \"$itk_option(-orient)\",\		    should be either horizontal or vertical"	}    }}# ------------------------------------------------------------------#                            METHODS# ------------------------------------------------------------------# ------------------------------------------------------------------# METHOD: index index## Searches the buttons in the box for the one with the requested tag,# numerical index, keyword "end" or "default".  Returns the button's # tag if found, otherwise error.# ------------------------------------------------------------------    body iwidgets::Buttonbox::index {index} {    if {[llength $_buttonList] > 0} {	if {[regexp {(^[0-9]+$)} $index]} {	    if {$index < [llength $_buttonList]} {		return $index	    } else {		error "Buttonbox index \"$index\" is out of range"	    }	    	} elseif {$index == "end"} {	    return [expr [llength $_buttonList] - 1]	    	} elseif {$index == "default"} {	    foreach knownButton $_buttonList {		if {[$itk_component($knownButton) cget -defaultring]} {		    return [lsearch -exact $_buttonList $knownButton]		}	    }	    	    error "Buttonbox \"$itk_component(hull)\" has no default"	    	} else {	    if {[set idx [lsearch $_buttonList $index]] != -1} {		return $idx	    }	    	    error "bad Buttonbox index \"$index\": must be number, end,\		    default, or pattern"	}	    } else {	error "Buttonbox \"$itk_component(hull)\" has no buttons"    }}# ------------------------------------------------------------------# METHOD: add tag ?option value option value ...?## Add the specified button to the button box.  All PushButton options# are allowed.  New buttons are added to the list of buttons and the # list of displayed buttons.  The PushButton path name is returned.# ------------------------------------------------------------------body iwidgets::Buttonbox::add {tag args} {    itk_component add $tag {	iwidgets::Pushbutton $itk_component(hull).[incr _unique]    } {	usual	rename -highlightbackground -background background Background    }        if {$args != ""} {	uplevel $itk_component($tag) configure $args    }        lappend _buttonList $tag    lappend _displayList $tag        _setBoxSize}# ------------------------------------------------------------------# METHOD: insert index tag ?option value option value ...?## Insert the specified button in the button box just before the one # given by index.  All PushButton options are allowed.  New buttons # are added to the list of buttons and the list of displayed buttons.# The PushButton path name is returned.# ------------------------------------------------------------------body iwidgets::Buttonbox::insert {index tag args} {    itk_component add $tag {	iwidgets::Pushbutton $itk_component(hull).[incr _unique]    } {	usual	rename -highlightbackground -background background Background    }        if {$args != ""} {	uplevel $itk_component($tag) configure $args    }        set index [index $index]    set _buttonList [linsert $_buttonList $index $tag]    set _displayList [linsert $_displayList $index $tag]        _setBoxSize}# ------------------------------------------------------------------# METHOD: delete index## Delete the specified button from the button box.# ------------------------------------------------------------------body iwidgets::Buttonbox::delete {index} {    set index [index $index]    set tag [lindex $_buttonList $index]        destroy $itk_component($tag)        set _buttonList [lreplace $_buttonList $index $index]        if {[set dind [lsearch $_displayList $tag]] != -1} {	set _displayList [lreplace $_displayList $dind $dind]    }        _setBoxSize    update idletasks}# ------------------------------------------------------------------# METHOD: default index## Sets the default to the push button given by index.# ------------------------------------------------------------------body iwidgets::Buttonbox::default {index} {

⌨️ 快捷键说明

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