Mercurial > hg > octave-lyh
annotate scripts/plot/uiputfile.m @ 11551:84fa2ba414ee
print.m: Fix printing to eps for DOS.
author | Ben Abbott <bpabbott@mac.com> |
---|---|
date | Sun, 16 Jan 2011 18:31:25 -0500 |
parents | fd0a3ac60b0e |
children | 3c6e8aaa9555 |
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 ()) | |
24 ## Open a GUI dialog to select a file. @var{flt} contains a (list of) file | |
25 ## filter string(s) in one of the following formats: | |
26 ## | |
27 ## @table @code | |
28 ## @item "/path/to/filename.ext" | |
29 ## If a filename is given the file extension is | |
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" | |
36 ## A single file extension. | |
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 | |
44 ## | |
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. | |
50 ## If @var{default_file} is given it is preselected in the GUI dialog. | |
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 | |
59 if (nargin <= 3) | |
60 | |
61 defaultvals = {"All Files(*)", #FLTK File Filter | |
62 "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
|
63 pwd, #FLTK default file name |
11283 | 64 [240, 120], #Dialog Position (pixel x/y) |
65 "create"}; | |
66 | |
67 outargs = cell(5, 1); | |
68 for i = 1 : 5 | |
69 outargs{i} = defaultvals{i}; | |
70 endfor | |
71 | |
72 if (nargin > 0) | |
73 file_filter = varargin{1}; | |
74 outargs{1} = __fltk_file_filter__ (file_filter); | |
75 if (ischar (file_filter)) | |
76 outargs{3} = file_filter; | |
77 endif | |
78 endif | |
79 | |
80 if (nargin > 1) | |
81 outargs{2} = varargin{2}; | |
82 endif | |
83 | |
84 if (nargin > 2) | |
85 outargs{3} = varargin{3}; | |
86 endif | |
87 | |
88 else | |
11295
75ff3db6a687
Simplify code for uimenu.m. Fix error messages for ui file functions.
Kai Habel <kai.habel@gmx.de>
parents:
11284
diff
changeset
|
89 error ("uiputfile: number of input arguments must be less than four."); |
11283 | 90 endif |
91 | |
92 if (any (cellfun(@(x)strcmp (x, "fltk"), available_backends))) | |
93 [retfile, retpath, retindex] = __fltk_uigetfile__ (outargs{:}); | |
94 else | |
11295
75ff3db6a687
Simplify code for uimenu.m. Fix error messages for ui file functions.
Kai Habel <kai.habel@gmx.de>
parents:
11284
diff
changeset
|
95 error ("uiputfile: fltk backend required."); |
11283 | 96 endif |
97 | |
98 endfunction | |
99 | |
100 %!demo | |
101 %! uiputfile({"*.gif;*.png;*.jpg", "Supported Picture Formats"}) |