1 |
578 |
markom |
#
|
2 |
|
|
# Selectiondialog
|
3 |
|
|
# ----------------------------------------------------------------------
|
4 |
|
|
# Implements a selection box similar to the OSF/Motif standard selection
|
5 |
|
|
# dialog composite widget. The Selectiondialog is derived from the
|
6 |
|
|
# Dialog class and is composed of a SelectionBox with attributes to
|
7 |
|
|
# manipulate the dialog buttons.
|
8 |
|
|
#
|
9 |
|
|
# ----------------------------------------------------------------------
|
10 |
|
|
# AUTHOR: Mark L. Ulferts EMAIL: mulferts@austin.dsccc.com
|
11 |
|
|
#
|
12 |
|
|
# @(#) $Id: selectiondialog.itk,v 1.1.1.1 2002-01-16 10:24:50 markom Exp $
|
13 |
|
|
# ----------------------------------------------------------------------
|
14 |
|
|
# Copyright (c) 1995 DSC Technologies Corporation
|
15 |
|
|
# ======================================================================
|
16 |
|
|
# Permission to use, copy, modify, distribute and license this software
|
17 |
|
|
# and its documentation for any purpose, and without fee or written
|
18 |
|
|
# agreement with DSC, is hereby granted, provided that the above copyright
|
19 |
|
|
# notice appears in all copies and that both the copyright notice and
|
20 |
|
|
# warranty disclaimer below appear in supporting documentation, and that
|
21 |
|
|
# the names of DSC Technologies Corporation or DSC Communications
|
22 |
|
|
# Corporation not be used in advertising or publicity pertaining to the
|
23 |
|
|
# software without specific, written prior permission.
|
24 |
|
|
#
|
25 |
|
|
# DSC DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
|
26 |
|
|
# ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, AND NON-
|
27 |
|
|
# INFRINGEMENT. THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, AND THE
|
28 |
|
|
# AUTHORS AND DISTRIBUTORS HAVE NO OBLIGATION TO PROVIDE MAINTENANCE,
|
29 |
|
|
# SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. IN NO EVENT SHALL
|
30 |
|
|
# DSC BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
|
31 |
|
|
# ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
|
32 |
|
|
# WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTUOUS ACTION,
|
33 |
|
|
# ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
|
34 |
|
|
# SOFTWARE.
|
35 |
|
|
# ======================================================================
|
36 |
|
|
|
37 |
|
|
#
|
38 |
|
|
# Usual options.
|
39 |
|
|
#
|
40 |
|
|
itk::usual Selectiondialog {
|
41 |
|
|
keep -activebackground -activerelief -background -borderwidth -cursor \
|
42 |
|
|
-elementborderwidth -foreground -highlightcolor -highlightthickness \
|
43 |
|
|
-insertbackground -insertborderwidth -insertofftime -insertontime \
|
44 |
|
|
-insertwidth -jump -labelfont -modality -selectbackground \
|
45 |
|
|
-selectborderwidth -selectforeground -textbackground -textfont \
|
46 |
|
|
-troughcolor
|
47 |
|
|
}
|
48 |
|
|
|
49 |
|
|
# ------------------------------------------------------------------
|
50 |
|
|
# SELECTIONDIALOG
|
51 |
|
|
# ------------------------------------------------------------------
|
52 |
|
|
class iwidgets::Selectiondialog {
|
53 |
|
|
inherit iwidgets::Dialog
|
54 |
|
|
|
55 |
|
|
constructor {args} {}
|
56 |
|
|
|
57 |
|
|
public method childsite {}
|
58 |
|
|
public method get {}
|
59 |
|
|
public method curselection {}
|
60 |
|
|
public method clear {component}
|
61 |
|
|
public method insert {component index args}
|
62 |
|
|
public method delete {first {last {}}}
|
63 |
|
|
public method size {}
|
64 |
|
|
public method scan {option args}
|
65 |
|
|
public method nearest {y}
|
66 |
|
|
public method index {index}
|
67 |
|
|
public method selection {option args}
|
68 |
|
|
public method selectitem {}
|
69 |
|
|
}
|
70 |
|
|
|
71 |
|
|
#
|
72 |
|
|
# Provide a lowercased access method for the Selectiondialog class.
|
73 |
|
|
#
|
74 |
|
|
proc ::iwidgets::selectiondialog {pathName args} {
|
75 |
|
|
uplevel ::iwidgets::Selectiondialog $pathName $args
|
76 |
|
|
}
|
77 |
|
|
|
78 |
|
|
#
|
79 |
|
|
# Use option database to override default resources of base classes.
|
80 |
|
|
#
|
81 |
|
|
option add *Selectiondialog.title "Selection Dialog" widgetDefault
|
82 |
|
|
option add *Selectiondialog.master "." widgetDefault
|
83 |
|
|
|
84 |
|
|
# ------------------------------------------------------------------
|
85 |
|
|
# CONSTRUCTOR
|
86 |
|
|
# ------------------------------------------------------------------
|
87 |
|
|
body iwidgets::Selectiondialog::constructor {args} {
|
88 |
|
|
#
|
89 |
|
|
# Set the borderwidth to zero.
|
90 |
|
|
#
|
91 |
|
|
component hull configure -borderwidth 0
|
92 |
|
|
|
93 |
|
|
#
|
94 |
|
|
# Instantiate a selection box widget.
|
95 |
|
|
#
|
96 |
|
|
itk_component add selectionbox {
|
97 |
|
|
iwidgets::Selectionbox $itk_interior.selectionbox \
|
98 |
|
|
-dblclickcommand [code $this invoke]
|
99 |
|
|
} {
|
100 |
|
|
usual
|
101 |
|
|
|
102 |
|
|
keep -childsitepos -exportselection -itemscommand -itemslabel \
|
103 |
|
|
-itemson -selectionlabel -selectionon -selectioncommand
|
104 |
|
|
}
|
105 |
|
|
configure -itemscommand [code $this selectitem]
|
106 |
|
|
|
107 |
|
|
pack $itk_component(selectionbox) -fill both -expand yes
|
108 |
|
|
set itk_interior [$itk_component(selectionbox) childsite]
|
109 |
|
|
|
110 |
|
|
hide Help
|
111 |
|
|
|
112 |
|
|
eval itk_initialize $args
|
113 |
|
|
}
|
114 |
|
|
|
115 |
|
|
# ------------------------------------------------------------------
|
116 |
|
|
# METHODS
|
117 |
|
|
# ------------------------------------------------------------------
|
118 |
|
|
|
119 |
|
|
# ------------------------------------------------------------------
|
120 |
|
|
# METHOD: childsite
|
121 |
|
|
#
|
122 |
|
|
# Thinwrapped method of selection box class.
|
123 |
|
|
# ------------------------------------------------------------------
|
124 |
|
|
body iwidgets::Selectiondialog::childsite {} {
|
125 |
|
|
return [$itk_component(selectionbox) childsite]
|
126 |
|
|
}
|
127 |
|
|
|
128 |
|
|
# ------------------------------------------------------------------
|
129 |
|
|
# METHOD: get
|
130 |
|
|
#
|
131 |
|
|
# Thinwrapped method of selection box class.
|
132 |
|
|
# ------------------------------------------------------------------
|
133 |
|
|
body iwidgets::Selectiondialog::get {} {
|
134 |
|
|
return [$itk_component(selectionbox) get]
|
135 |
|
|
}
|
136 |
|
|
|
137 |
|
|
# ------------------------------------------------------------------
|
138 |
|
|
# METHOD: curselection
|
139 |
|
|
#
|
140 |
|
|
# Thinwrapped method of selection box class.
|
141 |
|
|
# ------------------------------------------------------------------
|
142 |
|
|
body iwidgets::Selectiondialog::curselection {} {
|
143 |
|
|
return [$itk_component(selectionbox) curselection]
|
144 |
|
|
}
|
145 |
|
|
|
146 |
|
|
# ------------------------------------------------------------------
|
147 |
|
|
# METHOD: clear component
|
148 |
|
|
#
|
149 |
|
|
# Thinwrapped method of selection box class.
|
150 |
|
|
# ------------------------------------------------------------------
|
151 |
|
|
body iwidgets::Selectiondialog::clear {component} {
|
152 |
|
|
$itk_component(selectionbox) clear $component
|
153 |
|
|
|
154 |
|
|
return
|
155 |
|
|
}
|
156 |
|
|
|
157 |
|
|
# ------------------------------------------------------------------
|
158 |
|
|
# METHOD: insert component index args
|
159 |
|
|
#
|
160 |
|
|
# Thinwrapped method of selection box class.
|
161 |
|
|
# ------------------------------------------------------------------
|
162 |
|
|
body iwidgets::Selectiondialog::insert {component index args} {
|
163 |
|
|
eval $itk_component(selectionbox) insert $component $index $args
|
164 |
|
|
|
165 |
|
|
return
|
166 |
|
|
}
|
167 |
|
|
|
168 |
|
|
# ------------------------------------------------------------------
|
169 |
|
|
# METHOD: delete first ?last?
|
170 |
|
|
#
|
171 |
|
|
# Thinwrapped method of selection box class.
|
172 |
|
|
# ------------------------------------------------------------------
|
173 |
|
|
body iwidgets::Selectiondialog::delete {first {last {}}} {
|
174 |
|
|
$itk_component(selectionbox) delete $first $last
|
175 |
|
|
|
176 |
|
|
return
|
177 |
|
|
}
|
178 |
|
|
|
179 |
|
|
# ------------------------------------------------------------------
|
180 |
|
|
# METHOD: size
|
181 |
|
|
#
|
182 |
|
|
# Thinwrapped method of selection box class.
|
183 |
|
|
# ------------------------------------------------------------------
|
184 |
|
|
body iwidgets::Selectiondialog::size {} {
|
185 |
|
|
return [$itk_component(selectionbox) size]
|
186 |
|
|
}
|
187 |
|
|
|
188 |
|
|
# ------------------------------------------------------------------
|
189 |
|
|
# METHOD: scan option args
|
190 |
|
|
#
|
191 |
|
|
# Thinwrapped method of selection box class.
|
192 |
|
|
# ------------------------------------------------------------------
|
193 |
|
|
body iwidgets::Selectiondialog::scan {option args} {
|
194 |
|
|
return [eval $itk_component(selectionbox) scan $option $args]
|
195 |
|
|
}
|
196 |
|
|
|
197 |
|
|
# ------------------------------------------------------------------
|
198 |
|
|
# METHOD: nearest y
|
199 |
|
|
#
|
200 |
|
|
# Thinwrapped method of selection box class.
|
201 |
|
|
# ------------------------------------------------------------------
|
202 |
|
|
body iwidgets::Selectiondialog::nearest {y} {
|
203 |
|
|
return [$itk_component(selectionbox) nearest $y]
|
204 |
|
|
}
|
205 |
|
|
|
206 |
|
|
# ------------------------------------------------------------------
|
207 |
|
|
# METHOD: index index
|
208 |
|
|
#
|
209 |
|
|
# Thinwrapped method of selection box class.
|
210 |
|
|
# ------------------------------------------------------------------
|
211 |
|
|
body iwidgets::Selectiondialog::index {index} {
|
212 |
|
|
return [$itk_component(selectionbox) index $index]
|
213 |
|
|
}
|
214 |
|
|
|
215 |
|
|
# ------------------------------------------------------------------
|
216 |
|
|
# METHOD: selection option args
|
217 |
|
|
#
|
218 |
|
|
# Thinwrapped method of selection box class.
|
219 |
|
|
# ------------------------------------------------------------------
|
220 |
|
|
body iwidgets::Selectiondialog::selection {option args} {
|
221 |
|
|
eval $itk_component(selectionbox) selection $option $args
|
222 |
|
|
}
|
223 |
|
|
|
224 |
|
|
# ------------------------------------------------------------------
|
225 |
|
|
# METHOD: selectitem
|
226 |
|
|
#
|
227 |
|
|
# Set the default button to ok and select the item.
|
228 |
|
|
# ------------------------------------------------------------------
|
229 |
|
|
body iwidgets::Selectiondialog::selectitem {} {
|
230 |
|
|
default OK
|
231 |
|
|
$itk_component(selectionbox) selectitem
|
232 |
|
|
}
|
233 |
|
|
|