annotate scripts/gui/uigetfile.m @ 18971:f084aab05cd9

Move checks for graphics_toolkit GUI functions to own script. * __get_funcname__.m: New function to buid the function name from basename and graphics_toolkit. * uigetdir.m, uigetfile.m, uiputfile.m: Adapt to use __get_funcname__ with basename = mfilename ()
author Andreas Weber <andy.weber.aw@gmail.com>
date Thu, 31 Jul 2014 00:03:56 +0200
parents bb2a03f9ed20
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
17744
d63878346099 maint: Update copyright notices for release.
John W. Eaton <jwe@octave.org>
parents: 17572
diff changeset
1 ## Copyright (C) 2010-2013 Kai Habel
11283
58f175d39a7a GUI file functions
Kai Habel <kai.habel@gmx.de>
parents:
diff changeset
2 ##
58f175d39a7a GUI file functions
Kai Habel <kai.habel@gmx.de>
parents:
diff changeset
3 ## This file is part of Octave.
58f175d39a7a GUI file functions
Kai Habel <kai.habel@gmx.de>
parents:
diff changeset
4 ##
58f175d39a7a GUI file functions
Kai Habel <kai.habel@gmx.de>
parents:
diff changeset
5 ## Octave is free software; you can redistribute it and/or modify it
58f175d39a7a GUI file functions
Kai Habel <kai.habel@gmx.de>
parents:
diff changeset
6 ## under the terms of the GNU General Public License as published by
58f175d39a7a GUI file functions
Kai Habel <kai.habel@gmx.de>
parents:
diff changeset
7 ## the Free Software Foundation; either version 3 of the License, or (at
58f175d39a7a GUI file functions
Kai Habel <kai.habel@gmx.de>
parents:
diff changeset
8 ## your option) any later version.
58f175d39a7a GUI file functions
Kai Habel <kai.habel@gmx.de>
parents:
diff changeset
9 ##
58f175d39a7a GUI file functions
Kai Habel <kai.habel@gmx.de>
parents:
diff changeset
10 ## Octave is distributed in the hope that it will be useful, but
58f175d39a7a GUI file functions
Kai Habel <kai.habel@gmx.de>
parents:
diff changeset
11 ## WITHOUT ANY WARRANTY; without even the implied warranty of
58f175d39a7a GUI file functions
Kai Habel <kai.habel@gmx.de>
parents:
diff changeset
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
58f175d39a7a GUI file functions
Kai Habel <kai.habel@gmx.de>
parents:
diff changeset
13 ## General Public License for more details.
58f175d39a7a GUI file functions
Kai Habel <kai.habel@gmx.de>
parents:
diff changeset
14 ##
58f175d39a7a GUI file functions
Kai Habel <kai.habel@gmx.de>
parents:
diff changeset
15 ## You should have received a copy of the GNU General Public License
58f175d39a7a GUI file functions
Kai Habel <kai.habel@gmx.de>
parents:
diff changeset
16 ## along with Octave; see the file COPYING. If not, see
58f175d39a7a GUI file functions
Kai Habel <kai.habel@gmx.de>
parents:
diff changeset
17 ## <http://www.gnu.org/licenses/>.
58f175d39a7a GUI file functions
Kai Habel <kai.habel@gmx.de>
parents:
diff changeset
18
58f175d39a7a GUI file functions
Kai Habel <kai.habel@gmx.de>
parents:
diff changeset
19 ## -*- texinfo -*-
12522
33bbae85769a Add uimenu, uigetdir, uigetfile, and uiputfile to documentation.
Rik <octave@nomad.inbox5.com>
parents: 12183
diff changeset
20 ## @deftypefn {Function File} {[@var{fname}, @var{fpath}, @var{fltidx}] =} uigetfile ()
33bbae85769a Add uimenu, uigetdir, uigetfile, and uiputfile to documentation.
Rik <octave@nomad.inbox5.com>
parents: 12183
diff changeset
21 ## @deftypefnx {Function File} {[@dots{}] =} uigetfile (@var{flt})
33bbae85769a Add uimenu, uigetdir, uigetfile, and uiputfile to documentation.
Rik <octave@nomad.inbox5.com>
parents: 12183
diff changeset
22 ## @deftypefnx {Function File} {[@dots{}] =} uigetfile (@var{flt}, @var{dialog_name})
11563
3c6e8aaa9555 Grammarcheck m-files before 3.4 release.
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
23 ## @deftypefnx {Function File} {[@dots{}] =} uigetfile (@var{flt}, @var{dialog_name}, @var{default_file})
12642
f96b9b9f141b doc: Periodic grammarcheck and spellcheck of documentation.
Rik <octave@nomad.inbox5.com>
parents: 12522
diff changeset
24 ## @deftypefnx {Function File} {[@dots{}] =} uigetfile (@dots{}, "Position", [@var{px} @var{py}])
12522
33bbae85769a Add uimenu, uigetdir, uigetfile, and uiputfile to documentation.
Rik <octave@nomad.inbox5.com>
parents: 12183
diff changeset
25 ## @deftypefnx {Function File} {[@dots{}] =} uigetfile (@dots{}, "MultiSelect", @var{mode})
11283
58f175d39a7a GUI file functions
Kai Habel <kai.habel@gmx.de>
parents:
diff changeset
26 ##
16580
adc150db1809 style fixes for uigetfile changes
John W. Eaton <jwe@octave.org>
parents: 16579
diff changeset
27 ## Open a GUI dialog for selecting a file and return the filename @var{fname},
11563
3c6e8aaa9555 Grammarcheck m-files before 3.4 release.
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
28 ## the path to this file @var{fpath}, and the filter index @var{fltidx}.
11283
58f175d39a7a GUI file functions
Kai Habel <kai.habel@gmx.de>
parents:
diff changeset
29 ## @var{flt} contains a (list of) file filter string(s) in one of the following
58f175d39a7a GUI file functions
Kai Habel <kai.habel@gmx.de>
parents:
diff changeset
30 ## formats:
58f175d39a7a GUI file functions
Kai Habel <kai.habel@gmx.de>
parents:
diff changeset
31 ##
11563
3c6e8aaa9555 Grammarcheck m-files before 3.4 release.
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
32 ## @table @asis
17281
bc924baa2c4e doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents: 16580
diff changeset
33 ## @item @qcode{"/path/to/filename.ext"}
12522
33bbae85769a Add uimenu, uigetdir, uigetfile, and uiputfile to documentation.
Rik <octave@nomad.inbox5.com>
parents: 12183
diff changeset
34 ## If a filename is given then the file extension is extracted and used as
33bbae85769a Add uimenu, uigetdir, uigetfile, and uiputfile to documentation.
Rik <octave@nomad.inbox5.com>
parents: 12183
diff changeset
35 ## filter. In addition, the path is selected as current path and the filename
33bbae85769a Add uimenu, uigetdir, uigetfile, and uiputfile to documentation.
Rik <octave@nomad.inbox5.com>
parents: 12183
diff changeset
36 ## is selected as default file. Example: @code{uigetfile ("myfun.m")}
11283
58f175d39a7a GUI file functions
Kai Habel <kai.habel@gmx.de>
parents:
diff changeset
37 ##
17281
bc924baa2c4e doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents: 16580
diff changeset
38 ## @item A single file extension @qcode{"*.ext"}
11563
3c6e8aaa9555 Grammarcheck m-files before 3.4 release.
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
39 ## Example: @code{uigetfile ("*.ext")}
11283
58f175d39a7a GUI file functions
Kai Habel <kai.habel@gmx.de>
parents:
diff changeset
40 ##
11563
3c6e8aaa9555 Grammarcheck m-files before 3.4 release.
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
41 ## @item A 2-column cell array
12522
33bbae85769a Add uimenu, uigetdir, uigetfile, and uiputfile to documentation.
Rik <octave@nomad.inbox5.com>
parents: 12183
diff changeset
42 ## containing a file extension in the first column and a brief description
11563
3c6e8aaa9555 Grammarcheck m-files before 3.4 release.
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
43 ## in the second column.
3c6e8aaa9555 Grammarcheck m-files before 3.4 release.
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
44 ## Example: @code{uigetfile (@{"*.ext", "My Description";"*.xyz",
3c6e8aaa9555 Grammarcheck m-files before 3.4 release.
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
45 ## "XYZ-Format"@})}
11583
c4c2cd67c440 Fixes for ui file functions, bug#32190
Kai Habel <kai.habel@gmx.de>
parents: 11576
diff changeset
46 ##
11283
58f175d39a7a GUI file functions
Kai Habel <kai.habel@gmx.de>
parents:
diff changeset
47 ## The filter string can also contain a semicolon separated list of filter
58f175d39a7a GUI file functions
Kai Habel <kai.habel@gmx.de>
parents:
diff changeset
48 ## extensions.
11563
3c6e8aaa9555 Grammarcheck m-files before 3.4 release.
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
49 ## Example: @code{uigetfile (@{"*.gif;*.png;*.jpg", "Supported Picture
3c6e8aaa9555 Grammarcheck m-files before 3.4 release.
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
50 ## Formats"@})}
11283
58f175d39a7a GUI file functions
Kai Habel <kai.habel@gmx.de>
parents:
diff changeset
51 ## @end table
58f175d39a7a GUI file functions
Kai Habel <kai.habel@gmx.de>
parents:
diff changeset
52 ##
58f175d39a7a GUI file functions
Kai Habel <kai.habel@gmx.de>
parents:
diff changeset
53 ## @var{dialog_name} can be used to customize the dialog title.
12522
33bbae85769a Add uimenu, uigetdir, uigetfile, and uiputfile to documentation.
Rik <octave@nomad.inbox5.com>
parents: 12183
diff changeset
54 ## If @var{default_file} is given then it will be selected in the GUI dialog.
33bbae85769a Add uimenu, uigetdir, uigetfile, and uiputfile to documentation.
Rik <octave@nomad.inbox5.com>
parents: 12183
diff changeset
55 ## If, in addition, a path is given it is also used as current path.
11587
c792872f8942 all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents: 11583
diff changeset
56 ##
17281
bc924baa2c4e doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents: 16580
diff changeset
57 ## The screen position of the GUI dialog can be set using the
bc924baa2c4e doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents: 16580
diff changeset
58 ## @qcode{"Position"} key and a 2-element vector containing the pixel
bc924baa2c4e doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents: 16580
diff changeset
59 ## coordinates. Two or more files can be selected when setting the
bc924baa2c4e doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents: 16580
diff changeset
60 ## @qcode{"MultiSelect"} key to @qcode{"on"}. In that case @var{fname} is a
bc924baa2c4e doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents: 16580
diff changeset
61 ## cell array containing the files.
15532
95d7475a0a89 doc: Add seealso links between uigetfile, uiputfile, uigetdir.
Rik <rik@octave.org>
parents: 15467
diff changeset
62 ## @seealso{uiputfile, uigetdir}
11283
58f175d39a7a GUI file functions
Kai Habel <kai.habel@gmx.de>
parents:
diff changeset
63 ## @end deftypefn
58f175d39a7a GUI file functions
Kai Habel <kai.habel@gmx.de>
parents:
diff changeset
64
58f175d39a7a GUI file functions
Kai Habel <kai.habel@gmx.de>
parents:
diff changeset
65 ## Author: Kai Habel
58f175d39a7a GUI file functions
Kai Habel <kai.habel@gmx.de>
parents:
diff changeset
66
58f175d39a7a GUI file functions
Kai Habel <kai.habel@gmx.de>
parents:
diff changeset
67 function [retfile, retpath, retindex] = uigetfile (varargin)
58f175d39a7a GUI file functions
Kai Habel <kai.habel@gmx.de>
parents:
diff changeset
68
18971
f084aab05cd9 Move checks for graphics_toolkit GUI functions to own script.
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18970
diff changeset
69 funcname = __get_funcname__ (mfilename ());
f084aab05cd9 Move checks for graphics_toolkit GUI functions to own script.
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18970
diff changeset
70
12522
33bbae85769a Add uimenu, uigetdir, uigetfile, and uiputfile to documentation.
Rik <octave@nomad.inbox5.com>
parents: 12183
diff changeset
71 if (nargin > 7)
11295
75ff3db6a687 Simplify code for uimenu.m. Fix error messages for ui file functions.
Kai Habel <kai.habel@gmx.de>
parents: 11284
diff changeset
72 error ("uigetfile: number of input arguments must be less than eight");
11283
58f175d39a7a GUI file functions
Kai Habel <kai.habel@gmx.de>
parents:
diff changeset
73 endif
58f175d39a7a GUI file functions
Kai Habel <kai.habel@gmx.de>
parents:
diff changeset
74
13697
0f8ff98929b2 Allow a toolkit to provide its own version of UI dialogs.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13215
diff changeset
75 defaultvals = {cell(0, 2), # File Filter
0f8ff98929b2 Allow a toolkit to provide its own version of UI dialogs.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13215
diff changeset
76 "Open File", # Dialog Title
0f8ff98929b2 Allow a toolkit to provide its own version of UI dialogs.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13215
diff changeset
77 "", # Default file name
0f8ff98929b2 Allow a toolkit to provide its own version of UI dialogs.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13215
diff changeset
78 [240, 120], # Dialog Position (pixel x/y)
0f8ff98929b2 Allow a toolkit to provide its own version of UI dialogs.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13215
diff changeset
79 "off", # MultiSelect on/off
0f8ff98929b2 Allow a toolkit to provide its own version of UI dialogs.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13215
diff changeset
80 pwd}; # Default directory
12522
33bbae85769a Add uimenu, uigetdir, uigetfile, and uiputfile to documentation.
Rik <octave@nomad.inbox5.com>
parents: 12183
diff changeset
81
13697
0f8ff98929b2 Allow a toolkit to provide its own version of UI dialogs.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13215
diff changeset
82 outargs = cell (6, 1);
0f8ff98929b2 Allow a toolkit to provide its own version of UI dialogs.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13215
diff changeset
83 for i = 1 : 6
12522
33bbae85769a Add uimenu, uigetdir, uigetfile, and uiputfile to documentation.
Rik <octave@nomad.inbox5.com>
parents: 12183
diff changeset
84 outargs{i} = defaultvals{i};
33bbae85769a Add uimenu, uigetdir, uigetfile, and uiputfile to documentation.
Rik <octave@nomad.inbox5.com>
parents: 12183
diff changeset
85 endfor
33bbae85769a Add uimenu, uigetdir, uigetfile, and uiputfile to documentation.
Rik <octave@nomad.inbox5.com>
parents: 12183
diff changeset
86
33bbae85769a Add uimenu, uigetdir, uigetfile, and uiputfile to documentation.
Rik <octave@nomad.inbox5.com>
parents: 12183
diff changeset
87 idx1 = idx2 = [];
33bbae85769a Add uimenu, uigetdir, uigetfile, and uiputfile to documentation.
Rik <octave@nomad.inbox5.com>
parents: 12183
diff changeset
88 if (length (varargin) > 0)
33bbae85769a Add uimenu, uigetdir, uigetfile, and uiputfile to documentation.
Rik <octave@nomad.inbox5.com>
parents: 12183
diff changeset
89 for i = 1 : length (varargin)
33bbae85769a Add uimenu, uigetdir, uigetfile, and uiputfile to documentation.
Rik <octave@nomad.inbox5.com>
parents: 12183
diff changeset
90 val = varargin{i};
33bbae85769a Add uimenu, uigetdir, uigetfile, and uiputfile to documentation.
Rik <octave@nomad.inbox5.com>
parents: 12183
diff changeset
91 if (ischar (val))
14225
f0d903879eaa Replace unnecessary strcmpi calls with strcmp.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
92 val = tolower (val);
17405
3f0ed69d21c6 Replace unnecessary instances of strncmp with strcmp.
Rik <rik@octave.org>
parents: 17281
diff changeset
93 if (strcmp (val, "multiselect"))
12522
33bbae85769a Add uimenu, uigetdir, uigetfile, and uiputfile to documentation.
Rik <octave@nomad.inbox5.com>
parents: 12183
diff changeset
94 idx1 = i;
17405
3f0ed69d21c6 Replace unnecessary instances of strncmp with strcmp.
Rik <rik@octave.org>
parents: 17281
diff changeset
95 elseif (strcmp (val, "position"))
12522
33bbae85769a Add uimenu, uigetdir, uigetfile, and uiputfile to documentation.
Rik <octave@nomad.inbox5.com>
parents: 12183
diff changeset
96 idx2 = i;
33bbae85769a Add uimenu, uigetdir, uigetfile, and uiputfile to documentation.
Rik <octave@nomad.inbox5.com>
parents: 12183
diff changeset
97 endif
33bbae85769a Add uimenu, uigetdir, uigetfile, and uiputfile to documentation.
Rik <octave@nomad.inbox5.com>
parents: 12183
diff changeset
98 endif
33bbae85769a Add uimenu, uigetdir, uigetfile, and uiputfile to documentation.
Rik <octave@nomad.inbox5.com>
parents: 12183
diff changeset
99 endfor
33bbae85769a Add uimenu, uigetdir, uigetfile, and uiputfile to documentation.
Rik <octave@nomad.inbox5.com>
parents: 12183
diff changeset
100 endif
33bbae85769a Add uimenu, uigetdir, uigetfile, and uiputfile to documentation.
Rik <octave@nomad.inbox5.com>
parents: 12183
diff changeset
101
33bbae85769a Add uimenu, uigetdir, uigetfile, and uiputfile to documentation.
Rik <octave@nomad.inbox5.com>
parents: 12183
diff changeset
102 stridx = [idx1, idx2, 0];
33bbae85769a Add uimenu, uigetdir, uigetfile, and uiputfile to documentation.
Rik <octave@nomad.inbox5.com>
parents: 12183
diff changeset
103 if (length (stridx) > 1)
33bbae85769a Add uimenu, uigetdir, uigetfile, and uiputfile to documentation.
Rik <octave@nomad.inbox5.com>
parents: 12183
diff changeset
104 stridx = min (stridx(1 : end - 1));
33bbae85769a Add uimenu, uigetdir, uigetfile, and uiputfile to documentation.
Rik <octave@nomad.inbox5.com>
parents: 12183
diff changeset
105 endif
33bbae85769a Add uimenu, uigetdir, uigetfile, and uiputfile to documentation.
Rik <octave@nomad.inbox5.com>
parents: 12183
diff changeset
106
33bbae85769a Add uimenu, uigetdir, uigetfile, and uiputfile to documentation.
Rik <octave@nomad.inbox5.com>
parents: 12183
diff changeset
107 args = varargin;
33bbae85769a Add uimenu, uigetdir, uigetfile, and uiputfile to documentation.
Rik <octave@nomad.inbox5.com>
parents: 12183
diff changeset
108 if (stridx)
33bbae85769a Add uimenu, uigetdir, uigetfile, and uiputfile to documentation.
Rik <octave@nomad.inbox5.com>
parents: 12183
diff changeset
109 args = varargin(1 : stridx - 1);
11283
58f175d39a7a GUI file functions
Kai Habel <kai.habel@gmx.de>
parents:
diff changeset
110 endif
58f175d39a7a GUI file functions
Kai Habel <kai.habel@gmx.de>
parents:
diff changeset
111
12522
33bbae85769a Add uimenu, uigetdir, uigetfile, and uiputfile to documentation.
Rik <octave@nomad.inbox5.com>
parents: 12183
diff changeset
112 len = length (args);
33bbae85769a Add uimenu, uigetdir, uigetfile, and uiputfile to documentation.
Rik <octave@nomad.inbox5.com>
parents: 12183
diff changeset
113 if (len > 0)
33bbae85769a Add uimenu, uigetdir, uigetfile, and uiputfile to documentation.
Rik <octave@nomad.inbox5.com>
parents: 12183
diff changeset
114 file_filter = args{1};
13697
0f8ff98929b2 Allow a toolkit to provide its own version of UI dialogs.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13215
diff changeset
115 [outargs{1}, outargs{3}, defdir] = __file_filter__ (file_filter);
0f8ff98929b2 Allow a toolkit to provide its own version of UI dialogs.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13215
diff changeset
116 if (length (defdir) > 0)
0f8ff98929b2 Allow a toolkit to provide its own version of UI dialogs.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13215
diff changeset
117 outargs{6} = defdir;
0f8ff98929b2 Allow a toolkit to provide its own version of UI dialogs.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13215
diff changeset
118 endif
0f8ff98929b2 Allow a toolkit to provide its own version of UI dialogs.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13215
diff changeset
119 else
0f8ff98929b2 Allow a toolkit to provide its own version of UI dialogs.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13215
diff changeset
120 outargs{1} = __file_filter__ (outargs{1});
0f8ff98929b2 Allow a toolkit to provide its own version of UI dialogs.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13215
diff changeset
121 endif
0f8ff98929b2 Allow a toolkit to provide its own version of UI dialogs.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13215
diff changeset
122
0f8ff98929b2 Allow a toolkit to provide its own version of UI dialogs.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13215
diff changeset
123 if (len > 1)
0f8ff98929b2 Allow a toolkit to provide its own version of UI dialogs.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13215
diff changeset
124 if (ischar (args{2}))
0f8ff98929b2 Allow a toolkit to provide its own version of UI dialogs.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13215
diff changeset
125 if (length (args{2}) > 0)
0f8ff98929b2 Allow a toolkit to provide its own version of UI dialogs.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13215
diff changeset
126 outargs{2} = args{2};
0f8ff98929b2 Allow a toolkit to provide its own version of UI dialogs.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13215
diff changeset
127 endif
0f8ff98929b2 Allow a toolkit to provide its own version of UI dialogs.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13215
diff changeset
128 elseif (! isempty (args{2}))
0f8ff98929b2 Allow a toolkit to provide its own version of UI dialogs.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13215
diff changeset
129 print_usage ();
12522
33bbae85769a Add uimenu, uigetdir, uigetfile, and uiputfile to documentation.
Rik <octave@nomad.inbox5.com>
parents: 12183
diff changeset
130 endif
33bbae85769a Add uimenu, uigetdir, uigetfile, and uiputfile to documentation.
Rik <octave@nomad.inbox5.com>
parents: 12183
diff changeset
131 endif
33bbae85769a Add uimenu, uigetdir, uigetfile, and uiputfile to documentation.
Rik <octave@nomad.inbox5.com>
parents: 12183
diff changeset
132
33bbae85769a Add uimenu, uigetdir, uigetfile, and uiputfile to documentation.
Rik <octave@nomad.inbox5.com>
parents: 12183
diff changeset
133 if (len > 2)
13697
0f8ff98929b2 Allow a toolkit to provide its own version of UI dialogs.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13215
diff changeset
134 if (ischar (args{3}))
0f8ff98929b2 Allow a toolkit to provide its own version of UI dialogs.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13215
diff changeset
135 [fdir, fname, fext] = fileparts (args{3});
0f8ff98929b2 Allow a toolkit to provide its own version of UI dialogs.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13215
diff changeset
136 if (length (fdir) > 0)
0f8ff98929b2 Allow a toolkit to provide its own version of UI dialogs.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13215
diff changeset
137 outargs{6} = fdir;
0f8ff98929b2 Allow a toolkit to provide its own version of UI dialogs.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13215
diff changeset
138 endif
0f8ff98929b2 Allow a toolkit to provide its own version of UI dialogs.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13215
diff changeset
139 if (length (fname) > 0 || length (fext) > 0)
0f8ff98929b2 Allow a toolkit to provide its own version of UI dialogs.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13215
diff changeset
140 outargs{3} = strcat (fname, fext);
0f8ff98929b2 Allow a toolkit to provide its own version of UI dialogs.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13215
diff changeset
141 endif
0f8ff98929b2 Allow a toolkit to provide its own version of UI dialogs.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13215
diff changeset
142 elseif (! isempty (args{3}))
0f8ff98929b2 Allow a toolkit to provide its own version of UI dialogs.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13215
diff changeset
143 print_usage ();
0f8ff98929b2 Allow a toolkit to provide its own version of UI dialogs.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13215
diff changeset
144 endif
12522
33bbae85769a Add uimenu, uigetdir, uigetfile, and uiputfile to documentation.
Rik <octave@nomad.inbox5.com>
parents: 12183
diff changeset
145 endif
33bbae85769a Add uimenu, uigetdir, uigetfile, and uiputfile to documentation.
Rik <octave@nomad.inbox5.com>
parents: 12183
diff changeset
146
33bbae85769a Add uimenu, uigetdir, uigetfile, and uiputfile to documentation.
Rik <octave@nomad.inbox5.com>
parents: 12183
diff changeset
147 if (stridx)
33bbae85769a Add uimenu, uigetdir, uigetfile, and uiputfile to documentation.
Rik <octave@nomad.inbox5.com>
parents: 12183
diff changeset
148 ## we have string arguments ("position" or "multiselect")
33bbae85769a Add uimenu, uigetdir, uigetfile, and uiputfile to documentation.
Rik <octave@nomad.inbox5.com>
parents: 12183
diff changeset
149
33bbae85769a Add uimenu, uigetdir, uigetfile, and uiputfile to documentation.
Rik <octave@nomad.inbox5.com>
parents: 12183
diff changeset
150 ## check for even number of remaining arguments, prop/value pair(s)
33bbae85769a Add uimenu, uigetdir, uigetfile, and uiputfile to documentation.
Rik <octave@nomad.inbox5.com>
parents: 12183
diff changeset
151 if (rem (nargin - stridx + 1, 2))
33bbae85769a Add uimenu, uigetdir, uigetfile, and uiputfile to documentation.
Rik <octave@nomad.inbox5.com>
parents: 12183
diff changeset
152 error ("uigetfile: expecting property/value pairs");
33bbae85769a Add uimenu, uigetdir, uigetfile, and uiputfile to documentation.
Rik <octave@nomad.inbox5.com>
parents: 12183
diff changeset
153 endif
33bbae85769a Add uimenu, uigetdir, uigetfile, and uiputfile to documentation.
Rik <octave@nomad.inbox5.com>
parents: 12183
diff changeset
154
33bbae85769a Add uimenu, uigetdir, uigetfile, and uiputfile to documentation.
Rik <octave@nomad.inbox5.com>
parents: 12183
diff changeset
155 for i = stridx : 2 : nargin
33bbae85769a Add uimenu, uigetdir, uigetfile, and uiputfile to documentation.
Rik <octave@nomad.inbox5.com>
parents: 12183
diff changeset
156 prop = varargin{i};
33bbae85769a Add uimenu, uigetdir, uigetfile, and uiputfile to documentation.
Rik <octave@nomad.inbox5.com>
parents: 12183
diff changeset
157 val = varargin{i + 1};
17405
3f0ed69d21c6 Replace unnecessary instances of strncmp with strcmp.
Rik <rik@octave.org>
parents: 17281
diff changeset
158 if (strcmpi (prop, "position"))
14868
5d3a684236b0 maint: Use Octave coding conventions for cuddling parentheses in scripts directory
Rik <octave@nomad.inbox5.com>
parents: 14363
diff changeset
159 if (ismatrix (val) && length (val) == 2)
12522
33bbae85769a Add uimenu, uigetdir, uigetfile, and uiputfile to documentation.
Rik <octave@nomad.inbox5.com>
parents: 12183
diff changeset
160 outargs{4} = val;
33bbae85769a Add uimenu, uigetdir, uigetfile, and uiputfile to documentation.
Rik <octave@nomad.inbox5.com>
parents: 12183
diff changeset
161 else
33bbae85769a Add uimenu, uigetdir, uigetfile, and uiputfile to documentation.
Rik <octave@nomad.inbox5.com>
parents: 12183
diff changeset
162 error ("uigetfile: expecting 2-element vector for position argument");
33bbae85769a Add uimenu, uigetdir, uigetfile, and uiputfile to documentation.
Rik <octave@nomad.inbox5.com>
parents: 12183
diff changeset
163 endif
17408
266fafd1ffc1 fix 2 strcmp<->strncmp issues from 3f0ed69d21c6
Andreas Weber <andreas.weber@hs-offenburg.de>
parents: 17405
diff changeset
164 elseif (strcmpi (prop, "multiselect"))
12522
33bbae85769a Add uimenu, uigetdir, uigetfile, and uiputfile to documentation.
Rik <octave@nomad.inbox5.com>
parents: 12183
diff changeset
165 if (ischar (val))
33bbae85769a Add uimenu, uigetdir, uigetfile, and uiputfile to documentation.
Rik <octave@nomad.inbox5.com>
parents: 12183
diff changeset
166 outargs{5} = tolower (val);
33bbae85769a Add uimenu, uigetdir, uigetfile, and uiputfile to documentation.
Rik <octave@nomad.inbox5.com>
parents: 12183
diff changeset
167 else
33bbae85769a Add uimenu, uigetdir, uigetfile, and uiputfile to documentation.
Rik <octave@nomad.inbox5.com>
parents: 12183
diff changeset
168 error ("uigetfile: expecting string argument (on/off) for multiselect");
33bbae85769a Add uimenu, uigetdir, uigetfile, and uiputfile to documentation.
Rik <octave@nomad.inbox5.com>
parents: 12183
diff changeset
169 endif
33bbae85769a Add uimenu, uigetdir, uigetfile, and uiputfile to documentation.
Rik <octave@nomad.inbox5.com>
parents: 12183
diff changeset
170 else
33bbae85769a Add uimenu, uigetdir, uigetfile, and uiputfile to documentation.
Rik <octave@nomad.inbox5.com>
parents: 12183
diff changeset
171 error ("uigetfile: unknown argument");
33bbae85769a Add uimenu, uigetdir, uigetfile, and uiputfile to documentation.
Rik <octave@nomad.inbox5.com>
parents: 12183
diff changeset
172 endif
33bbae85769a Add uimenu, uigetdir, uigetfile, and uiputfile to documentation.
Rik <octave@nomad.inbox5.com>
parents: 12183
diff changeset
173 endfor
33bbae85769a Add uimenu, uigetdir, uigetfile, and uiputfile to documentation.
Rik <octave@nomad.inbox5.com>
parents: 12183
diff changeset
174 endif
33bbae85769a Add uimenu, uigetdir, uigetfile, and uiputfile to documentation.
Rik <octave@nomad.inbox5.com>
parents: 12183
diff changeset
175
16579
7f8db1942dc0 Add Qt link uigetfile dialog implementation.
John Donoghue <john.donoghue@ieee.org>
parents: 15532
diff changeset
176 if (__octave_link_enabled__ ())
7f8db1942dc0 Add Qt link uigetfile dialog implementation.
John Donoghue <john.donoghue@ieee.org>
parents: 15532
diff changeset
177 [retfile, retpath, retindex] = __octave_link_file_dialog__ (outargs{:});
7f8db1942dc0 Add Qt link uigetfile dialog implementation.
John Donoghue <john.donoghue@ieee.org>
parents: 15532
diff changeset
178 else
7f8db1942dc0 Add Qt link uigetfile dialog implementation.
John Donoghue <john.donoghue@ieee.org>
parents: 15532
diff changeset
179 [retfile, retpath, retindex] = feval (funcname, outargs{:});
7f8db1942dc0 Add Qt link uigetfile dialog implementation.
John Donoghue <john.donoghue@ieee.org>
parents: 15532
diff changeset
180 endif
12522
33bbae85769a Add uimenu, uigetdir, uigetfile, and uiputfile to documentation.
Rik <octave@nomad.inbox5.com>
parents: 12183
diff changeset
181
11283
58f175d39a7a GUI file functions
Kai Habel <kai.habel@gmx.de>
parents:
diff changeset
182 endfunction
58f175d39a7a GUI file functions
Kai Habel <kai.habel@gmx.de>
parents:
diff changeset
183
14237
11949c9795a0 Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents: 14225
diff changeset
184
11587
c792872f8942 all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents: 11583
diff changeset
185 %!demo
14245
4506eade9f04 Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents: 14237
diff changeset
186 %! uigetfile ({'*.gif;*.png;*.jpg', 'Supported Picture Formats'});
13215
cb8fd692b600 Add tests for scripts/plot
Kai Habel <kai.habel@gmx.de>
parents: 12642
diff changeset
187
cb8fd692b600 Add tests for scripts/plot
Kai Habel <kai.habel@gmx.de>
parents: 12642
diff changeset
188 ## Remove from test statistics. No real tests possible.
14363
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14245
diff changeset
189 %!assert (1)
14237
11949c9795a0 Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents: 14225
diff changeset
190