Mercurial > hg > octave-lyh
annotate scripts/plot/uiputfile.m @ 12462:e4dbfe3019b1
Use PCRE regular expressions throughout Octave.
author | Rik <octave@nomad.inbox5.com> |
---|---|
date | Sat, 19 Feb 2011 18:21:58 -0800 |
parents | b4d26c65e7e6 |
children | 33bbae85769a |
rev | line source |
---|---|
11523 | 1 ## Copyright (C) 2010-2011 Kai Habel |
11283 | 2 ## |
3 ## This file is part of Octave. | |
4 ## | |
5 ## Octave is free software; you can redistribute it and/or modify it | |
6 ## under the terms of the GNU General Public License as published by | |
7 ## the Free Software Foundation; either version 3 of the License, or (at | |
8 ## your option) any later version. | |
9 ## | |
10 ## Octave is distributed in the hope that it will be useful, but | |
11 ## WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
13 ## General Public License for more details. | |
14 ## | |
15 ## You should have received a copy of the GNU General Public License | |
16 ## along with Octave; see the file COPYING. If not, see | |
17 ## <http://www.gnu.org/licenses/>. | |
18 | |
19 ## -*- texinfo -*- | |
20 ## @deftypefn {Function File} {[@var{fname}, @var{fpath}, @var{fltidx}] =} uiputfile (@var{flt}, @var{dialog_name}, @var{default_file}) | |
21 ## @deftypefnx {Function File} {[@var{fname}, @var{fpath}, @var{fltidx}] =} uiputfile (@var{flt}, @var{dialog_name}) | |
22 ## @deftypefnx {Function File} {[@var{fname}, @var{fpath}, @var{fltidx}] =} uiputfile (@var{flt}) | |
23 ## @deftypefnx {Function File} {[@var{fname}, @var{fpath}, @var{fltidx}] =} uiputfile ()) | |
11563
3c6e8aaa9555
Grammarcheck m-files before 3.4 release.
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
24 ## Open a GUI dialog to select a file. @var{flt} contains a (list of) file |
11283 | 25 ## filter string(s) in one of the following formats: |
26 ## | |
27 ## @table @code | |
28 ## @item "/path/to/filename.ext" | |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11583
diff
changeset
|
29 ## If a filename is given the file extension is |
11283 | 30 ## extracted and used as filter. |
31 ## In addtion the path is selected as current path and the filname is selected | |
32 ## as default file. | |
33 ## Example: uiputfile("myfun.m"); | |
34 ## | |
35 ## @item "*.ext" | |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11583
diff
changeset
|
36 ## A single file extension. |
11283 | 37 ## Example: uiputfile("*.ext"); |
38 ## | |
39 ## @item @{"*.ext","My Description"@} | |
40 ## A 2-column cell array containing the file extension in the 1st column and | |
41 ## a brief description in the 2nd column. | |
42 ## Example: uiputfile(@{"*.ext","My Description";"*.xyz","XYZ-Format"@}); | |
43 ## @end table | |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11583
diff
changeset
|
44 ## |
11283 | 45 ## The filter string can also contain a semicolon separated list of filter |
46 ## extensions. | |
47 ## Example: uiputfile(@{"*.gif;*.png;*.jpg", "Supported Picture Formats"@}); | |
48 ## | |
49 ## @var{dialog_name} can be used to customize the dialog title. | |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11583
diff
changeset
|
50 ## If @var{default_file} is given it is preselected in the GUI dialog. |
11283 | 51 ## If in addtion a path is given it is also used as current path. |
52 ## @end deftypefn | |
53 | |
54 ## Author: Kai Habel | |
55 | |
56 function [retfile, retpath, retindex] = uiputfile (varargin) | |
57 | |
58 if (nargin <= 3) | |
59 | |
60 defaultvals = {"All Files(*)", #FLTK File Filter | |
61 "Save File?", #Dialog Title | |
11284
b9bc32327c4d
ChangeLog fix, set default directory to pwd for ui file functions
Kai Habel <kai.habel@gmx.de>
parents:
11283
diff
changeset
|
62 pwd, #FLTK default file name |
11283 | 63 [240, 120], #Dialog Position (pixel x/y) |
64 "create"}; | |
65 | |
66 outargs = cell(5, 1); | |
67 for i = 1 : 5 | |
68 outargs{i} = defaultvals{i}; | |
69 endfor | |
70 | |
71 if (nargin > 0) | |
72 file_filter = varargin{1}; | |
73 outargs{1} = __fltk_file_filter__ (file_filter); | |
74 if (ischar (file_filter)) | |
75 outargs{3} = file_filter; | |
76 endif | |
77 endif | |
11583
c4c2cd67c440
Fixes for ui file functions, bug#32190
Kai Habel <kai.habel@gmx.de>
parents:
11576
diff
changeset
|
78 |
11283 | 79 if (nargin > 1) |
80 outargs{2} = varargin{2}; | |
81 endif | |
82 | |
83 if (nargin > 2) | |
84 outargs{3} = varargin{3}; | |
85 endif | |
86 | |
87 else | |
11588
d5bd2766c640
style fixes for warning and error messages in script files
John W. Eaton <jwe@octave.org>
parents:
11587
diff
changeset
|
88 error ("uiputfile: number of input arguments must be less than four"); |
11283 | 89 endif |
90 | |
12183
b4d26c65e7e6
Allow ui file function to work if gnuplot is the selected toolkit and fltk is available
Kai Habel <kai.habel@gmx.de>
parents:
11588
diff
changeset
|
91 if (exist("__fltk_uigetfile__") == 3) |
11583
c4c2cd67c440
Fixes for ui file functions, bug#32190
Kai Habel <kai.habel@gmx.de>
parents:
11576
diff
changeset
|
92 [retfile, retpath, retindex] = __fltk_uigetfile__ (outargs{:}); |
11283 | 93 else |
11576
8ac9687dbe9f
rename backend to graphics_toolkit
John W. Eaton <jwe@octave.org>
parents:
11563
diff
changeset
|
94 error ("uiputfile: fltk graphics toolkit required"); |
11283 | 95 endif |
96 | |
97 endfunction | |
98 | |
11583
c4c2cd67c440
Fixes for ui file functions, bug#32190
Kai Habel <kai.habel@gmx.de>
parents:
11576
diff
changeset
|
99 %!demo |
11283 | 100 %! uiputfile({"*.gif;*.png;*.jpg", "Supported Picture Formats"}) |