From: <ro...@us...> - 2012-05-02 12:29:37
|
Revision: 1991 http://nsclspectcl.svn.sourceforge.net/nsclspectcl/?rev=1991&view=rev Author: ron-fox Date: 2012-05-02 12:29:31 +0000 (Wed, 02 May 2012) Log Message: ----------- issue 105 - Make spectrum save a 2-step so that it works on laptops with small screen space. Modified Paths: -------------- branches/3.3-008-dev/Gui/spectrum.tcl Modified: branches/3.3-008-dev/Gui/spectrum.tcl =================================================================== --- branches/3.3-008-dev/Gui/spectrum.tcl 2012-05-02 12:10:32 UTC (rev 1990) +++ branches/3.3-008-dev/Gui/spectrum.tcl 2012-05-02 12:29:31 UTC (rev 1991) @@ -477,8 +477,13 @@ } # saveSpectrumDialog # This dialog allows the user to save a bunch of spectra. -# The dialog is divided into a file selector from iwidgets -# and a spectrum selector using the browser and a list box. +# The dialog consists of a spectrum selector using the browser +# and a list box. +# Once the users selects the spectra, they can +# - Ok - which prompts for a filename and when one is provided +# invokes the -okcommand else if that's cancelled, the -cancelcommand. +# - Cancel -which invoke the -cancelcommand. +# # Layout: # Options: # - All those for ::iwidgets::fileselectionbox @@ -486,25 +491,21 @@ # -okcommand # -cancelcommand # methods: -# get,filter - delegated to the fileselectionbox. +# get - Get the selected filename. # # # snit::widget saveSpectrumDialog { hulltype toplevel - delegate method get to filebox - delegate method filter to filebox - delegate option * to filebox - option -spectra option -okcommand option -cancelcommand variable hidden {} + variable filename "" constructor args { - install filebox using ::iwidgets::fileselectionbox $win.fbox -mask *.spec label $win.speclabel -text {Spectra to Write} listbox $win.spectra -yscrollcommand [list $win.scrollbar set] @@ -519,7 +520,6 @@ button $win.command.cancel -text Cancel -command [mymethod onCancel] button $win.command.help -text Help -command [list spectclGuiDisplayHelpTopic savespectrum] - grid $win.fbox - - grid $win.b x x grid ^ $win.speclabel x -sticky s grid ^ $win.spectra $win.scrollbar -sticky ns @@ -549,14 +549,23 @@ # Called when the Ok Button is clicked. # method onOk {} { - set script $options(-okcommand) - if {$script != ""} { - eval $script - } - if {$hidden != ""} { - destroy $hidden - set hidden {} - } + set filename [tk_getSaveFile -defaultextension .spec \ + -parent $win \ + -filetypes [list \ + [list "Spectrum Files" .spec] \ + [list "All Files" *]]] + if {$filename eq ""} { + $self onCancel + } else { + set script $options(-okcommand) + if {$script != ""} { + eval $script + } + if {$hidden != ""} { + destroy $hidden + set hidden {} + } + } } # onCancel @@ -564,8 +573,8 @@ # method onCancel {} { $self configure -spectra {} - setEntry $win.fbox.selection {} + set script $options(-cancelcommand) if {$script != ""} { eval $script @@ -576,6 +585,12 @@ } } + # + # Return the selected filename. + # + method get {} { + return $filename + } # spectrumFilter # Works with the browser to ensure that only the unselected # spectra appear in the browser. @@ -611,12 +626,6 @@ $win.spectra delete $index $win.b update } - # getFilter - # Returns the current value of the filebox filter string. - # - method getFilter {} { - return [$win.fbox.filter get] - } # configure -spectra list # Sets the current set of spectra selected to the # list supplied. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |