home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World 2000 December
/
PCWorld_2000-12_cd.bin
/
Komunikace
/
Comanche
/
comanche.exe
/
lib
/
iwidgets2.2.0
/
scripts
/
selectiondialog.itk
< prev
next >
Wrap
Text File
|
1999-02-24
|
10KB
|
268 lines
#
# Selectiondialog
# ----------------------------------------------------------------------
# Implements a selection box similar to the OSF/Motif standard selection
# dialog composite widget. The Selectiondialog is derived from the
# Dialog class and is composed of a SelectionBox with attributes to
# manipulate the dialog buttons.
#
# ----------------------------------------------------------------------
# AUTHOR: Mark L. Ulferts EMAIL: mulferts@spd.dsccc.com
#
# @(#) $Id: selectiondialog.itk,v 1.1 1998/07/27 18:49:50 stanton 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.
# ======================================================================
#
# Default resources.
#
option add *Selectiondialog.borderWidth 2 widgetDefault
option add *Selectiondialog.itemsLabel Items widgetDefault
option add *Selectiondialog.itemsLabelPos nw widgetDefault
option add *Selectiondialog.itemsOn yes widgetDefault
option add *Selectiondialog.selectionLabel Selection widgetDefault
option add *Selectiondialog.selectionLabelPos nw widgetDefault
option add *Selectiondialog.selectionOn yes widgetDefault
option add *Selectiondialog.vscrollMode static widgetDefault
option add *Selectiondialog.hscrollMode dynamic widgetDefault
option add *Selectiondialog.scrollMargin 3 widgetDefault
option add *Selectiondialog.margin 7 widgetDefault
option add *Selectiondialog.title "Selection Dialog" widgetDefault
option add *Selectiondialog.padX 10 widgetDefault
option add *Selectiondialog.padY 10 widgetDefault
option add *Selectiondialog.height 350 widgetDefault
option add *Selectiondialog.width 300 widgetDefault
option add *Selectiondialog.master "." widgetDefault
#
# Usual options.
#
itk::usual Selectiondialog {
keep -activebackground -activerelief -background -borderwidth -cursor \
-elementborderwidth -foreground -highlightcolor -highlightthickness \
-insertbackground -insertborderwidth -insertofftime -insertontime \
-insertwidth -jump -labelfont -modality -selectbackground \
-selectborderwidth -selectforeground -textbackground -textfont \
-troughcolor
}
# ------------------------------------------------------------------
# SELECTIONDIALOG
# ------------------------------------------------------------------
class iwidgets::Selectiondialog {
inherit iwidgets::Dialog
constructor {args} {}
public method childsite {}
public method get {}
public method curselection {}
public method clear {component}
public method insert {component index args}
public method delete {first {last {}}}
public method size {}
public method scan {option args}
public method nearest {y}
public method index {index}
public method selection {option args}
public method selectitem {}
}
#
# Provide a lowercased access method for the Selectiondialog class.
#
proc ::iwidgets::selectiondialog {pathName args} {
uplevel ::iwidgets::Selectiondialog $pathName $args
}
# ------------------------------------------------------------------
# CONSTRUCTOR
# ------------------------------------------------------------------
body iwidgets::Selectiondialog::constructor {args} {
component hull configure -borderwidth 0
itk_option add hull.width hull.height
#
# Turn off pack propagation for the hull widget so the width
# and height options become active.
#
pack propagate $itk_component(hull) no
#
# Instantiate a selection box widget.
#
itk_component add sb {
iwidgets::Selectionbox $itk_interior.sb \
-width 100 -height 140 -dblclickcommand [code $this invoke]
} {
keep -activebackground -activerelief -background -borderwidth \
-childsitepos -cursor -elementborderwidth \
-exportselection -foreground \
-highlightcolor -highlightthickness -hscrollmode \
-jump -insertbackground -insertborderwidth \
-insertofftime -insertontime -insertwidth -items \
-itemslabel -itemslabelpos -itemson -labelfont \
-labelmargin -margin -relief -repeatdelay \
-repeatinterval -sbwidth -scrollmargin -selectbackground \
-selectborderwidth -selectforeground -selectionlabel \
-selectionlabelpos -selectionon -textbackground \
-textfont -troughcolor -vscrollmode \
-itemscommand -selectioncommand
}
configure -itemscommand [code $this selectitem]
pack $itk_component(sb) -fill both -expand yes
set itk_interior [$itk_component(sb) childsite]
hide Help
eval itk_initialize $args
}
# ------------------------------------------------------------------
# METHODS
# ------------------------------------------------------------------
# ------------------------------------------------------------------
# METHOD: childsite
#
# Thinwrapped method of selection box class.
# ------------------------------------------------------------------
body iwidgets::Selectiondialog::childsite {} {
return [$itk_component(sb) childsite]
}
# ------------------------------------------------------------------
# METHOD: get
#
# Thinwrapped method of selection box class.
# ------------------------------------------------------------------
body iwidgets::Selectiondialog::get {} {
return [$itk_component(sb) get]
}
# ------------------------------------------------------------------
# METHOD: curselection
#
# Thinwrapped method of selection box class.
# ------------------------------------------------------------------
body iwidgets::Selectiondialog::curselection {} {
return [$itk_component(sb) curselection]
}
# ------------------------------------------------------------------
# METHOD: clear component
#
# Thinwrapped method of selection box class.
# ------------------------------------------------------------------
body iwidgets::Selectiondialog::clear {component} {
$itk_component(sb) clear $component
set itk_option(-items) [$itk_component(sb) cget -items]
return
}
# ------------------------------------------------------------------
# METHOD: insert component index args
#
# Thinwrapped method of selection box class.
# ------------------------------------------------------------------
body iwidgets::Selectiondialog::insert {component index args} {
eval $itk_component(sb) insert $component $index $args
set itk_option(-items) [$itk_component(sb) cget -items]
return
}
# ------------------------------------------------------------------
# METHOD: delete first ?last?
#
# Thinwrapped method of selection box class.
# ------------------------------------------------------------------
body iwidgets::Selectiondialog::delete {first {last {}}} {
$itk_component(sb) delete $first $last
set itk_option(-items) [$itk_component(sb) cget -items]
return
}
# ------------------------------------------------------------------
# METHOD: size
#
# Thinwrapped method of selection box class.
# ------------------------------------------------------------------
body iwidgets::Selectiondialog::size {} {
return [$itk_component(sb) size]
}
# ------------------------------------------------------------------
# METHOD: scan option args
#
# Thinwrapped method of selection box class.
# ------------------------------------------------------------------
body iwidgets::Selectiondialog::scan {option args} {
return [eval $itk_component(sb) scan $option $args]
}
# ------------------------------------------------------------------
# METHOD: nearest y
#
# Thinwrapped method of selection box class.
# ------------------------------------------------------------------
body iwidgets::Selectiondialog::nearest {y} {
return [$itk_component(sb) nearest $y]
}
# ------------------------------------------------------------------
# METHOD: index index
#
# Thinwrapped method of selection box class.
# ------------------------------------------------------------------
body iwidgets::Selectiondialog::index {index} {
return [$itk_component(sb) index $index]
}
# ------------------------------------------------------------------
# METHOD: selection option args
#
# Thinwrapped method of selection box class.
# ------------------------------------------------------------------
body iwidgets::Selectiondialog::selection {option args} {
eval $itk_component(sb) selection $option $args
}
# ------------------------------------------------------------------
# METHOD: selectitem
#
# Set the default button to ok and select the item.
# ------------------------------------------------------------------
body iwidgets::Selectiondialog::selectitem {} {
default OK
$itk_component(sb) selectitem
}