1# 2# Fileselectiondialog 3# ---------------------------------------------------------------------- 4# Implements a file selection box similar to the OSF/Motif standard 5# file selection dialog composite widget. The Fileselectiondialog is 6# derived from the Dialog class and is composed of a FileSelectionBox 7# with attributes set to manipulate the dialog buttons. 8# 9# ---------------------------------------------------------------------- 10# AUTHOR: Mark L. Ulferts EMAIL: mulferts@spd.dsccc.com 11# 12# @(#) $Id: fileselectiondialog.itk,v 1.2 2001/08/07 19:56:48 smithc 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# 40itk::usual Fileselectiondialog { 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 -textbackground -textfont 46} 47 48# ------------------------------------------------------------------ 49# FILESELECTIONDIALOG 50# ------------------------------------------------------------------ 51itcl::class iwidgets::Fileselectiondialog { 52 inherit iwidgets::Dialog 53 54 constructor {args} {} 55 56 public { 57 method childsite {} 58 method get {} 59 method filter {} 60 } 61 62 protected method _dbldir {} 63} 64 65# 66# Provide a lowercased access method for the Fileselectiondialog class. 67# 68proc ::iwidgets::fileselectiondialog {pathName args} { 69 uplevel ::iwidgets::Fileselectiondialog $pathName $args 70} 71 72# 73# Use option database to override default resources of base classes. 74# 75option add *Fileselectiondialog.borderWidth 2 widgetDefault 76 77option add *Fileselectiondialog.title "File Selection Dialog" widgetDefault 78 79option add *Fileselectiondialog.width 350 widgetDefault 80option add *Fileselectiondialog.height 400 widgetDefault 81 82option add *Fileselectiondialog.master "." widgetDefault 83 84# ------------------------------------------------------------------ 85# CONSTRUCTOR 86# ------------------------------------------------------------------ 87itcl::body iwidgets::Fileselectiondialog::constructor {args} { 88 component hull configure -borderwidth 0 89 itk_option add hull.width hull.height 90 91 # 92 # Turn off pack propagation for the hull widget so the width 93 # and height options become active. 94 # 95 pack propagate $itk_component(hull) no 96 97 # 98 # Instantiate a file selection box widget. 99 # 100 itk_component add fsb { 101 iwidgets::Fileselectionbox $itk_interior.fsb -width 150 -height 150 \ 102 -selectioncommand [itcl::code $this invoke] \ 103 -selectdircommand [itcl::code $this default Apply] \ 104 -selectfilecommand [itcl::code $this default OK] 105 } { 106 usual 107 108 keep -labelfont -childsitepos -directory -dirslabel \ 109 -dirsearchcommand -dirson -fileslabel -fileson \ 110 -filesearchcommand -filterlabel -filteron \ 111 -filetype -invalid -mask -nomatchstring \ 112 -selectionlabel -selectionon 113 } 114 grid $itk_component(fsb) -sticky nsew 115 grid rowconfigure $itk_interior 0 -weight 1 116 grid columnconfigure $itk_interior 0 -weight 1 117 118 $itk_component(fsb) component filter configure \ 119 -focuscommand [itcl::code $this default Apply] 120 $itk_component(fsb) component selection configure \ 121 -focuscommand [itcl::code $this default OK] 122 $itk_component(fsb) component dirs configure \ 123 -dblclickcommand [itcl::code $this _dbldir] 124 $itk_component(fsb) component files configure \ 125 -dblclickcommand [itcl::code $this invoke] 126 127 buttonconfigure Apply -text "Filter" \ 128 -command [itcl::code $itk_component(fsb) filter] 129 130 set itk_interior [$itk_component(fsb) childsite] 131 132 hide Help 133 134 eval itk_initialize $args 135} 136 137# ------------------------------------------------------------------ 138# METHODS 139# ------------------------------------------------------------------ 140 141# ------------------------------------------------------------------ 142# METHOD: childsite 143# 144# Thinwrapped method of file selection box class. 145# ------------------------------------------------------------------ 146itcl::body iwidgets::Fileselectiondialog::childsite {} { 147 return [$itk_component(fsb) childsite] 148} 149 150# ------------------------------------------------------------------ 151# METHOD: get 152# 153# Thinwrapped method of file selection box class. 154# ------------------------------------------------------------------ 155itcl::body iwidgets::Fileselectiondialog::get {} { 156 return [$itk_component(fsb) get] 157} 158 159# ------------------------------------------------------------------ 160# METHOD: filter 161# 162# Thinwrapped method of file selection box class. 163# ------------------------------------------------------------------ 164itcl::body iwidgets::Fileselectiondialog::filter {} { 165 return [$itk_component(fsb) filter] 166} 167 168# ------------------------------------------------------------------ 169# PROTECTED METHOD: _dbldir 170# 171# Double select in directory list. If the files list is on then 172# make the default button the filter and invoke. If not, just invoke. 173# ------------------------------------------------------------------ 174itcl::body iwidgets::Fileselectiondialog::_dbldir {} { 175 if {$itk_option(-fileson)} { 176 default Apply 177 } 178 179 invoke 180} 181 182