1#
2# Extfileselectiondialog
3# ----------------------------------------------------------------------
4# Implements a file selection dialog that is a slightly extended version
5# of the OSF/Motif standard composite widget.  The Extfileselectionbox
6# differs from the Motif standard in that the filter and selection
7# fields are comboboxes and the files and directory lists are in a
8# paned window.
9#
10# ----------------------------------------------------------------------
11#  AUTHOR: Mark L. Ulferts               EMAIL: mulferts@spd.dsccc.com
12#
13#  @(#) $Id: extfileselectiondialog.itk,v 1.3 2002/02/27 06:45:10 mgbacke Exp $
14# ----------------------------------------------------------------------
15#            Copyright (c) 1997 DSC Technologies Corporation
16# ======================================================================
17# Permission to use, copy, modify, distribute and license this software
18# and its documentation for any purpose, and without fee or written
19# agreement with DSC, is hereby granted, provided that the above copyright
20# notice appears in all copies and that both the copyright notice and
21# warranty disclaimer below appear in supporting documentation, and that
22# the names of DSC Technologies Corporation or DSC Communications
23# Corporation not be used in advertising or publicity pertaining to the
24# software without specific, written prior permission.
25#
26# DSC DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
27# ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, AND NON-
28# INFRINGEMENT. THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, AND THE
29# AUTHORS AND DISTRIBUTORS HAVE NO OBLIGATION TO PROVIDE MAINTENANCE,
30# SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. IN NO EVENT SHALL
31# DSC BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
32# ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
33# WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTUOUS ACTION,
34# ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
35# SOFTWARE.
36# ======================================================================
37
38#
39# Usual options.
40#
41itk::usual Extfileselectiondialog {
42    keep -activebackground -activerelief -background -borderwidth -cursor \
43     -elementborderwidth -foreground -highlightcolor -highlightthickness \
44     -insertbackground -insertborderwidth -insertofftime -insertontime \
45     -insertwidth -jump -labelfont -modality -selectbackground \
46     -selectborderwidth -textbackground -textfont
47}
48
49# ------------------------------------------------------------------
50#                        EXTFILESELECTIONDIALOG
51# ------------------------------------------------------------------
52itcl::class iwidgets::Extfileselectiondialog {
53    inherit iwidgets::Dialog
54
55    constructor {args} {}
56
57    public {
58    method childsite {}
59    method get {}
60    method filter {}
61    }
62
63    protected method _dbldir {}
64}
65
66#
67# Provide a lowercased access method for the Extfileselectiondialog class.
68#
69proc ::iwidgets::extfileselectiondialog {pathName args} {
70    uplevel ::iwidgets::Extfileselectiondialog $pathName $args
71}
72
73#
74# Use option database to override default resources of base classes.
75#
76option add *Extfileselectiondialog.borderWidth 2 widgetDefault
77
78option add *Extfileselectiondialog.title "File Selection Dialog" widgetDefault
79
80option add *Extfileselectiondialog.width 350 widgetDefault
81option add *Extfileselectiondialog.height 400 widgetDefault
82
83option add *Extfileselectiondialog.master "." widgetDefault
84
85# ------------------------------------------------------------------
86#                        CONSTRUCTOR
87# ------------------------------------------------------------------
88itcl::body iwidgets::Extfileselectiondialog::constructor {args} {
89    component hull configure -borderwidth 0
90    itk_option add hull.width hull.height
91
92    #
93    # Turn off pack propagation for the hull widget so the width
94    # and height options become active.
95    #
96    pack propagate $itk_component(hull) no
97
98    #
99    # Instantiate a file selection box widget.
100    #
101    itk_component add fsb {
102    iwidgets::Extfileselectionbox $itk_interior.fsb -width 150 -height 150 \
103        -selectioncommand [itcl::code $this invoke] \
104            -selectdircommand [itcl::code $this default Apply] \
105            -selectfilecommand [itcl::code $this default OK]
106    } {
107    usual
108
109    keep -labelfont -childsitepos -directory -dirslabel \
110        -dirsearchcommand -dirson -fileslabel -fileson \
111        -filesearchcommand -filterlabel -filteron \
112        -filetype -invalid -mask -nomatchstring \
113        -selectionlabel -selectionon -sashcursor
114    }
115    grid $itk_component(fsb) -sticky nsew
116    grid rowconfigure $itk_interior 0 -weight 1
117    grid columnconfigure $itk_interior 0 -weight 1
118
119    $itk_component(fsb) component filter configure \
120    -focuscommand [itcl::code $this default Apply]
121    $itk_component(fsb) component selection configure \
122    -focuscommand [itcl::code $this default OK]
123    $itk_component(fsb) component dirs configure \
124        -dblclickcommand [itcl::code $this _dbldir]
125    $itk_component(fsb) component files configure \
126        -dblclickcommand [itcl::code $this invoke]
127
128    buttonconfigure Apply -text "Filter" \
129        -command [itcl::code $itk_component(fsb) filter]
130
131    set itk_interior [$itk_component(fsb) childsite]
132
133    hide Help
134
135    eval itk_initialize $args
136}
137
138# ------------------------------------------------------------------
139#                            METHODS
140# ------------------------------------------------------------------
141
142# ------------------------------------------------------------------
143# METHOD: childsite
144#
145# Thinwrapped method of file selection box class.
146# ------------------------------------------------------------------
147itcl::body iwidgets::Extfileselectiondialog::childsite {} {
148    return [$itk_component(fsb) childsite]
149}
150
151# ------------------------------------------------------------------
152# METHOD: get
153#
154# Thinwrapped method of file selection box class.
155# ------------------------------------------------------------------
156itcl::body iwidgets::Extfileselectiondialog::get {} {
157    return [$itk_component(fsb) get]
158}
159
160# ------------------------------------------------------------------
161# METHOD: filter
162#
163# Thinwrapped method of file selection box class.
164# ------------------------------------------------------------------
165itcl::body iwidgets::Extfileselectiondialog::filter {} {
166    return [$itk_component(fsb) filter]
167}
168
169# ------------------------------------------------------------------
170# PROTECTED METHOD: _dbldir
171#
172# Double select in directory list.  If the files list is on then
173# make the default button the filter and invoke.  If not, just invoke.
174# ------------------------------------------------------------------
175itcl::body iwidgets::Extfileselectiondialog::_dbldir {} {
176    if {$itk_option(-fileson)} {
177    default Apply
178    }
179
180    invoke
181}
182
183