annotate scripts/gui/inputdlg.m @ 21630:b5d9b95d1e1a

Removing Java dialog boxes. * scripts/gui/module.mk: removed message_dialog.m entry. * scripts/gui/private/message_dialog.m: merged code to msgbox. * scripts/gui/errordlg.m: function now redirects to msgbox. New tests. * scripts/gui/helpdlg.m: function now redirects to msgbox. New tests. * scripts/gui/warndlg.m: function now redirects to msgbox. New tests. * scripts/gui/msgbox.m: merged code from message_dialog. Stripped Java dialog boxes. New tests. * scripts/gui/inputdlg.m: stripped Java dialog boxes. Improved doc. New tests. * scripts/gui/listdlg.m: stripped Java dialog boxes. Improved doc. New tests. * scripts/gui/questdlg.m: stripped Java dialog boxes. Improved doc. New tests. * scripts/miscellaneous/menu.m: stripped Java dialog boxes. Improved doc. * scripts/java/module.mk: removed entries of deleted files. * scripts/java/org/octave/DlgListener.java: removed Java dialog box Listener. * scripts/java/org/octave/images/error.png: removed unused image. * scripts/java/org/octave/images/information.png: removed unused image. * scripts/java/org/octave/images/octave.png: removed unused image. * scripts/java/org/octave/images/question.png: removed unused image. * scripts/java/org/octave/images/warning.png: removed unused image. * scripts/java/org/octave/JDialogBox.java: removed Java dialog box class. * scripts/java/org/octave/TeXcode.java: removed class used by Java dialogs. * scripts/java/org/octave/TeXtranslator.java: removed class used by Java dialogs. * doc/module.mk: removed unused java images and java.txi. * doc/interpreter/java.txi: merged content as minor sections to following files. * doc/interpreter/bugs.txi: moved Java distinguish section here. * doc/interpreter/external.txi: moved Java Interface description here. * doc/interpreter/gui.txi: moved dialog box docstrings here. * doc/interpreter/octave.texi: corrected TOC. * doc/interpreter/java-images/image001.png: removed unused image. * doc/interpreter/java-images/image002.png: removed unused image. * doc/interpreter/java-images/image003.png: removed unused image. * doc/interpreter/java-images/image004.png: removed unused image. * doc/interpreter/java-images/image005.png: removed unused image. * doc/interpreter/java-images/image006.png: removed unused image. * doc/interpreter/java-images/image007.png: removed unused image. * doc/interpreter/java-images/image008.png: removed unused image. * doc/interpreter/java-images/image009.png: removed unused image. * NEWS: Announced changes.
author Kai T. Ohlhus <k.ohlhus@gmail.com>
date Tue, 19 Apr 2016 15:27:19 +0200
parents 3be6a07e8bad
children 59ebef9680ef
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: 17700
diff changeset
1 ## Copyright (C) 2010, 2013 Martin Hepperle
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2 ##
15746
da26f72408a7 update copyright statements in newly added java files
John W. Eaton <jwe@octave.org>
parents: 15709
diff changeset
3 ## This file is part of Octave.
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
4 ##
15746
da26f72408a7 update copyright statements in newly added java files
John W. Eaton <jwe@octave.org>
parents: 15709
diff changeset
5 ## Octave is free software; you can redistribute it and/or modify it
da26f72408a7 update copyright statements in newly added java files
John W. Eaton <jwe@octave.org>
parents: 15709
diff changeset
6 ## under the terms of the GNU General Public License as published by
da26f72408a7 update copyright statements in newly added java files
John W. Eaton <jwe@octave.org>
parents: 15709
diff changeset
7 ## the Free Software Foundation; either version 3 of the License, or (at
da26f72408a7 update copyright statements in newly added java files
John W. Eaton <jwe@octave.org>
parents: 15709
diff changeset
8 ## your option) any later version.
da26f72408a7 update copyright statements in newly added java files
John W. Eaton <jwe@octave.org>
parents: 15709
diff changeset
9 ##
da26f72408a7 update copyright statements in newly added java files
John W. Eaton <jwe@octave.org>
parents: 15709
diff changeset
10 ## Octave is distributed in the hope that it will be useful, but
da26f72408a7 update copyright statements in newly added java files
John W. Eaton <jwe@octave.org>
parents: 15709
diff changeset
11 ## WITHOUT ANY WARRANTY; without even the implied warranty of
da26f72408a7 update copyright statements in newly added java files
John W. Eaton <jwe@octave.org>
parents: 15709
diff changeset
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
da26f72408a7 update copyright statements in newly added java files
John W. Eaton <jwe@octave.org>
parents: 15709
diff changeset
13 ## General Public License for more details.
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
14 ##
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
15 ## You should have received a copy of the GNU General Public License
15746
da26f72408a7 update copyright statements in newly added java files
John W. Eaton <jwe@octave.org>
parents: 15709
diff changeset
16 ## along with Octave; see the file COPYING. If not, see
da26f72408a7 update copyright statements in newly added java files
John W. Eaton <jwe@octave.org>
parents: 15709
diff changeset
17 ## <http://www.gnu.org/licenses/>.
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
18
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
19 ## -*- texinfo -*-
20852
516bb87ea72e 2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents: 20173
diff changeset
20 ## @deftypefn {} {@var{cstr} =} inputdlg (@var{prompt})
516bb87ea72e 2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents: 20173
diff changeset
21 ## @deftypefnx {} {@var{cstr} =} inputdlg (@var{prompt}, @var{title})
516bb87ea72e 2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents: 20173
diff changeset
22 ## @deftypefnx {} {@var{cstr} =} inputdlg (@var{prompt}, @var{title}, @var{rowscols})
516bb87ea72e 2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents: 20173
diff changeset
23 ## @deftypefnx {} {@var{cstr} =} inputdlg (@var{prompt}, @var{title}, @var{rowscols}, @var{defaults})
20173
777f26aa8e3e doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19952
diff changeset
24 ## Return user input from a multi-textfield dialog box in a cell array of
777f26aa8e3e doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19952
diff changeset
25 ## strings, or an empty cell array if the dialog is closed by the Cancel
777f26aa8e3e doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19952
diff changeset
26 ## button.
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
27 ##
15772
0f1a143e5002 Overhaul scripts/java directory to conform to Octave core.
Rik <rik@octave.org>
parents: 15750
diff changeset
28 ## Inputs:
0f1a143e5002 Overhaul scripts/java directory to conform to Octave core.
Rik <rik@octave.org>
parents: 15750
diff changeset
29 ##
15748
54e8c2527a9e style and doc fixes for newly imported Java package .m files
John W. Eaton <jwe@octave.org>
parents: 15746
diff changeset
30 ## @table @var
54e8c2527a9e style and doc fixes for newly imported Java package .m files
John W. Eaton <jwe@octave.org>
parents: 15746
diff changeset
31 ## @item prompt
19593
446c46af4b42 strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents: 17744
diff changeset
32 ## A cell array with strings labeling each text field. This input is required.
15772
0f1a143e5002 Overhaul scripts/java directory to conform to Octave core.
Rik <rik@octave.org>
parents: 15750
diff changeset
33 ##
15748
54e8c2527a9e style and doc fixes for newly imported Java package .m files
John W. Eaton <jwe@octave.org>
parents: 15746
diff changeset
34 ## @item title
20173
777f26aa8e3e doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19952
diff changeset
35 ## String to use for the caption of the dialog. The default is
777f26aa8e3e doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19952
diff changeset
36 ## @qcode{"Input Dialog"}.
15772
0f1a143e5002 Overhaul scripts/java directory to conform to Octave core.
Rik <rik@octave.org>
parents: 15750
diff changeset
37 ##
15748
54e8c2527a9e style and doc fixes for newly imported Java package .m files
John W. Eaton <jwe@octave.org>
parents: 15746
diff changeset
38 ## @item rowscols
15772
0f1a143e5002 Overhaul scripts/java directory to conform to Octave core.
Rik <rik@octave.org>
parents: 15750
diff changeset
39 ## Specifies the size of the text fields and can take three forms:
0f1a143e5002 Overhaul scripts/java directory to conform to Octave core.
Rik <rik@octave.org>
parents: 15750
diff changeset
40 ##
15748
54e8c2527a9e style and doc fixes for newly imported Java package .m files
John W. Eaton <jwe@octave.org>
parents: 15746
diff changeset
41 ## @enumerate
20173
777f26aa8e3e doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19952
diff changeset
42 ## @item a scalar value which defines the number of rows used for each text field.
15772
0f1a143e5002 Overhaul scripts/java directory to conform to Octave core.
Rik <rik@octave.org>
parents: 15750
diff changeset
43 ##
20173
777f26aa8e3e doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19952
diff changeset
44 ## @item a vector which defines the individual number of rows used for each text field.
15772
0f1a143e5002 Overhaul scripts/java directory to conform to Octave core.
Rik <rik@octave.org>
parents: 15750
diff changeset
45 ##
20173
777f26aa8e3e doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19952
diff changeset
46 ## @item a matrix which defines the individual number of rows and columns used for each text field. In the matrix each row describes a single text field. The first column specifies the number of input rows to use and the second column specifies the text field width.
15748
54e8c2527a9e style and doc fixes for newly imported Java package .m files
John W. Eaton <jwe@octave.org>
parents: 15746
diff changeset
47 ## @end enumerate
15772
0f1a143e5002 Overhaul scripts/java directory to conform to Octave core.
Rik <rik@octave.org>
parents: 15750
diff changeset
48 ##
15748
54e8c2527a9e style and doc fixes for newly imported Java package .m files
John W. Eaton <jwe@octave.org>
parents: 15746
diff changeset
49 ## @item defaults
20173
777f26aa8e3e doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19952
diff changeset
50 ## A list of default values to place in each text fields. It must be a cell
777f26aa8e3e doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19952
diff changeset
51 ## array of strings with the same size as @var{prompt}.
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
52 ## @end table
21630
b5d9b95d1e1a Removing Java dialog boxes.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 21178
diff changeset
53 ##
b5d9b95d1e1a Removing Java dialog boxes.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 21178
diff changeset
54 ## Example:
b5d9b95d1e1a Removing Java dialog boxes.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 21178
diff changeset
55 ##
b5d9b95d1e1a Removing Java dialog boxes.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 21178
diff changeset
56 ## @example
b5d9b95d1e1a Removing Java dialog boxes.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 21178
diff changeset
57 ## @group
b5d9b95d1e1a Removing Java dialog boxes.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 21178
diff changeset
58 ## prompt = @{"Width", "Height", "Depth"@};
b5d9b95d1e1a Removing Java dialog boxes.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 21178
diff changeset
59 ## defaults = @{"1.10", "2.20", "3.30"@};
b5d9b95d1e1a Removing Java dialog boxes.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 21178
diff changeset
60 ## rowscols = [1,10; 2,20; 3,30];
b5d9b95d1e1a Removing Java dialog boxes.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 21178
diff changeset
61 ## dims = inputdlg (prompt, "Enter Box Dimensions", rowscols, defaults);
b5d9b95d1e1a Removing Java dialog boxes.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 21178
diff changeset
62 ## @end group
b5d9b95d1e1a Removing Java dialog boxes.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 21178
diff changeset
63 ## @end example
b5d9b95d1e1a Removing Java dialog boxes.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 21178
diff changeset
64 ##
15772
0f1a143e5002 Overhaul scripts/java directory to conform to Octave core.
Rik <rik@octave.org>
parents: 15750
diff changeset
65 ## @seealso{errordlg, helpdlg, listdlg, msgbox, questdlg, warndlg}
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
66 ## @end deftypefn
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
67
21630
b5d9b95d1e1a Removing Java dialog boxes.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 21178
diff changeset
68 function cstr = inputdlg (prompt, varargin)
15772
0f1a143e5002 Overhaul scripts/java directory to conform to Octave core.
Rik <rik@octave.org>
parents: 15750
diff changeset
69
21630
b5d9b95d1e1a Removing Java dialog boxes.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 21178
diff changeset
70 narginchk (1, 4);
15709
9fee0b741de6 Update Java dialog scrips to latest octave-forge status
Philip Nienhuis <prnienhuis@users.sf.net>
parents: 15625
diff changeset
71
9fee0b741de6 Update Java dialog scrips to latest octave-forge status
Philip Nienhuis <prnienhuis@users.sf.net>
parents: 15625
diff changeset
72 if (iscell (prompt))
15748
54e8c2527a9e style and doc fixes for newly imported Java package .m files
John W. Eaton <jwe@octave.org>
parents: 15746
diff changeset
73 ## Silently extract only char elements
17386
6dbc866379e2 Replace cellfun() occurrences with faster code where possible.
Rik <rik@octave.org>
parents: 17281
diff changeset
74 prompt = prompt(cellfun ("isclass", prompt, "char"));
15709
9fee0b741de6 Update Java dialog scrips to latest octave-forge status
Philip Nienhuis <prnienhuis@users.sf.net>
parents: 15625
diff changeset
75 elseif (ischar (prompt))
9fee0b741de6 Update Java dialog scrips to latest octave-forge status
Philip Nienhuis <prnienhuis@users.sf.net>
parents: 15625
diff changeset
76 prompt = {prompt};
9fee0b741de6 Update Java dialog scrips to latest octave-forge status
Philip Nienhuis <prnienhuis@users.sf.net>
parents: 15625
diff changeset
77 else
21630
b5d9b95d1e1a Removing Java dialog boxes.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 21178
diff changeset
78 error ("PROMPT must be a character string or cellstr array");
15709
9fee0b741de6 Update Java dialog scrips to latest octave-forge status
Philip Nienhuis <prnienhuis@users.sf.net>
parents: 15625
diff changeset
79 endif
9fee0b741de6 Update Java dialog scrips to latest octave-forge status
Philip Nienhuis <prnienhuis@users.sf.net>
parents: 15625
diff changeset
80
21630
b5d9b95d1e1a Removing Java dialog boxes.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 21178
diff changeset
81 dlg_title = "Input Dialog";
b5d9b95d1e1a Removing Java dialog boxes.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 21178
diff changeset
82 if (nargin > 1)
b5d9b95d1e1a Removing Java dialog boxes.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 21178
diff changeset
83 dlg_title = varargin{1};
b5d9b95d1e1a Removing Java dialog boxes.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 21178
diff changeset
84 if (! ischar (dlg_title))
b5d9b95d1e1a Removing Java dialog boxes.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 21178
diff changeset
85 error ("TITLE must be a character string");
b5d9b95d1e1a Removing Java dialog boxes.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 21178
diff changeset
86 endif
b5d9b95d1e1a Removing Java dialog boxes.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 21178
diff changeset
87 endif
15748
54e8c2527a9e style and doc fixes for newly imported Java package .m files
John W. Eaton <jwe@octave.org>
parents: 15746
diff changeset
88
21630
b5d9b95d1e1a Removing Java dialog boxes.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 21178
diff changeset
89 linespec = 1;
b5d9b95d1e1a Removing Java dialog boxes.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 21178
diff changeset
90 if (nargin > 2)
b5d9b95d1e1a Removing Java dialog boxes.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 21178
diff changeset
91 linespec = varargin{2};
b5d9b95d1e1a Removing Java dialog boxes.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 21178
diff changeset
92 endif
15748
54e8c2527a9e style and doc fixes for newly imported Java package .m files
John W. Eaton <jwe@octave.org>
parents: 15746
diff changeset
93
21630
b5d9b95d1e1a Removing Java dialog boxes.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 21178
diff changeset
94 defaults = cellstr (cell (size (prompt)));
b5d9b95d1e1a Removing Java dialog boxes.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 21178
diff changeset
95 if (nargin > 3)
b5d9b95d1e1a Removing Java dialog boxes.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 21178
diff changeset
96 defaults = varargin{3};
b5d9b95d1e1a Removing Java dialog boxes.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 21178
diff changeset
97 endif
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
98
19593
446c46af4b42 strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents: 17744
diff changeset
99 ## specification of text field sizes as in Matlab
15772
0f1a143e5002 Overhaul scripts/java directory to conform to Octave core.
Rik <rik@octave.org>
parents: 15750
diff changeset
100 ## Matlab requires a matrix for linespec, not a cell array...
15748
54e8c2527a9e style and doc fixes for newly imported Java package .m files
John W. Eaton <jwe@octave.org>
parents: 15746
diff changeset
101 ## rc = [1,10; 2,20; 3,30];
54e8c2527a9e style and doc fixes for newly imported Java package .m files
John W. Eaton <jwe@octave.org>
parents: 15746
diff changeset
102 ## c1 c2
54e8c2527a9e style and doc fixes for newly imported Java package .m files
John W. Eaton <jwe@octave.org>
parents: 15746
diff changeset
103 ## r1 1 10 first text field is 1x10
54e8c2527a9e style and doc fixes for newly imported Java package .m files
John W. Eaton <jwe@octave.org>
parents: 15746
diff changeset
104 ## r2 2 20 second text field is 2x20
54e8c2527a9e style and doc fixes for newly imported Java package .m files
John W. Eaton <jwe@octave.org>
parents: 15746
diff changeset
105 ## r3 3 30 third text field is 3x30
21171
2935d56203a4 Fix regressions caused by ismatrix definition change (partial fix bug #47036).
Rik <rik@octave.org>
parents: 20173
diff changeset
106 if (! isnumeric (linespec))
21630
b5d9b95d1e1a Removing Java dialog boxes.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 21178
diff changeset
107 error ("ROWSCOLS must be numeric");
21171
2935d56203a4 Fix regressions caused by ismatrix definition change (partial fix bug #47036).
Rik <rik@octave.org>
parents: 20173
diff changeset
108 endif
2935d56203a4 Fix regressions caused by ismatrix definition change (partial fix bug #47036).
Rik <rik@octave.org>
parents: 20173
diff changeset
109
15772
0f1a143e5002 Overhaul scripts/java directory to conform to Octave core.
Rik <rik@octave.org>
parents: 15750
diff changeset
110 if (isscalar (linespec))
0f1a143e5002 Overhaul scripts/java directory to conform to Octave core.
Rik <rik@octave.org>
parents: 15750
diff changeset
111 ## only scalar value in lineTo, copy from linespec and add defaults
19952
028b2302f940 inputdlg: allow input prompts of varied size, return answer as column vector (Bug 44552)
John Donoghue <john.donoghue@ieee.org>
parents: 19848
diff changeset
112 rowscols = zeros (numel (prompt), 2);
15748
54e8c2527a9e style and doc fixes for newly imported Java package .m files
John W. Eaton <jwe@octave.org>
parents: 15746
diff changeset
113 ## cols
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
114 rowscols(:,2) = 25;
15772
0f1a143e5002 Overhaul scripts/java directory to conform to Octave core.
Rik <rik@octave.org>
parents: 15750
diff changeset
115 rowscols(:,1) = linespec;
0f1a143e5002 Overhaul scripts/java directory to conform to Octave core.
Rik <rik@octave.org>
parents: 15750
diff changeset
116 elseif (isvector (linespec))
19952
028b2302f940 inputdlg: allow input prompts of varied size, return answer as column vector (Bug 44552)
John Donoghue <john.donoghue@ieee.org>
parents: 19848
diff changeset
117 if (numel (linespec) == numel (prompt))
15772
0f1a143e5002 Overhaul scripts/java directory to conform to Octave core.
Rik <rik@octave.org>
parents: 15750
diff changeset
118 ## only one column in lineTo, copy from vector linespec and add defaults
19952
028b2302f940 inputdlg: allow input prompts of varied size, return answer as column vector (Bug 44552)
John Donoghue <john.donoghue@ieee.org>
parents: 19848
diff changeset
119 rowscols = zeros (numel (prompt), 2);
15772
0f1a143e5002 Overhaul scripts/java directory to conform to Octave core.
Rik <rik@octave.org>
parents: 15750
diff changeset
120 ## rows from colum vector linespec, columns are set to default
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
121 rowscols(:,2) = 25;
15772
0f1a143e5002 Overhaul scripts/java directory to conform to Octave core.
Rik <rik@octave.org>
parents: 15750
diff changeset
122 rowscols(:,1) = linespec(:);
19952
028b2302f940 inputdlg: allow input prompts of varied size, return answer as column vector (Bug 44552)
John Donoghue <john.donoghue@ieee.org>
parents: 19848
diff changeset
123 else
21630
b5d9b95d1e1a Removing Java dialog boxes.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 21178
diff changeset
124 error ("ROWSCOLS vector does not match size of PROMPT");
19952
028b2302f940 inputdlg: allow input prompts of varied size, return answer as column vector (Bug 44552)
John Donoghue <john.donoghue@ieee.org>
parents: 19848
diff changeset
125 endif
15772
0f1a143e5002 Overhaul scripts/java directory to conform to Octave core.
Rik <rik@octave.org>
parents: 15750
diff changeset
126 elseif (ismatrix (linespec))
0f1a143e5002 Overhaul scripts/java directory to conform to Octave core.
Rik <rik@octave.org>
parents: 15750
diff changeset
127 if (rows (linespec) == columns (prompt) && columns (linespec) == 2)
0f1a143e5002 Overhaul scripts/java directory to conform to Octave core.
Rik <rik@octave.org>
parents: 15750
diff changeset
128 ## (rows x columns) match, copy array linespec
0f1a143e5002 Overhaul scripts/java directory to conform to Octave core.
Rik <rik@octave.org>
parents: 15750
diff changeset
129 rowscols = linespec;
0f1a143e5002 Overhaul scripts/java directory to conform to Octave core.
Rik <rik@octave.org>
parents: 15750
diff changeset
130 else
21630
b5d9b95d1e1a Removing Java dialog boxes.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 21178
diff changeset
131 error ("ROWSCOLS matrix does not match size of PROMPT");
15748
54e8c2527a9e style and doc fixes for newly imported Java package .m files
John W. Eaton <jwe@octave.org>
parents: 15746
diff changeset
132 endif
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
133 else
15748
54e8c2527a9e style and doc fixes for newly imported Java package .m files
John W. Eaton <jwe@octave.org>
parents: 15746
diff changeset
134 ## dunno
21630
b5d9b95d1e1a Removing Java dialog boxes.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 21178
diff changeset
135 error ("unknown form of ROWSCOLS argument");
15748
54e8c2527a9e style and doc fixes for newly imported Java package .m files
John W. Eaton <jwe@octave.org>
parents: 15746
diff changeset
136 endif
16551
6ae555fc8c43 Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 16512
diff changeset
137 rowscols = ceil (rowscols);
19593
446c46af4b42 strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents: 17744
diff changeset
138
15748
54e8c2527a9e style and doc fixes for newly imported Java package .m files
John W. Eaton <jwe@octave.org>
parents: 15746
diff changeset
139 ## convert numeric values in defaults cell array to strings
54e8c2527a9e style and doc fixes for newly imported Java package .m files
John W. Eaton <jwe@octave.org>
parents: 15746
diff changeset
140 defs = cellfun (@num2str, defaults, "UniformOutput", false);
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
141
19848
9b7ca334a104 Backout cset a9952a647d52 and use __octave_link_enabled__ rather than isguirunning.
Rik <rik@octave.org>
parents: 19799
diff changeset
142 if (__octave_link_enabled__ ())
21630
b5d9b95d1e1a Removing Java dialog boxes.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 21178
diff changeset
143 cstr = __octave_link_input_dialog__ (prompt, dlg_title, rowscols, defs);
16551
6ae555fc8c43 Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 16512
diff changeset
144 else
6ae555fc8c43 Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 16512
diff changeset
145 error ("inputdlg is not available in this version of Octave");
16512
7f2395651a1c dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents: 16505
diff changeset
146 endif
7f2395651a1c dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents: 16505
diff changeset
147
15748
54e8c2527a9e style and doc fixes for newly imported Java package .m files
John W. Eaton <jwe@octave.org>
parents: 15746
diff changeset
148 endfunction
16512
7f2395651a1c dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents: 16505
diff changeset
149
7f2395651a1c dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents: 16505
diff changeset
150
7f2395651a1c dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents: 16505
diff changeset
151 %!demo
16933
e39f00a32dc7 maint: Use parentheses around condition for switch(),while(),if() statements.
Rik <rik@octave.org>
parents: 16551
diff changeset
152 %! disp ('- test inputdlg with prompt and caption only.');
e39f00a32dc7 maint: Use parentheses around condition for switch(),while(),if() statements.
Rik <rik@octave.org>
parents: 16551
diff changeset
153 %! prompt = {'Width','Height','Depth'};
e39f00a32dc7 maint: Use parentheses around condition for switch(),while(),if() statements.
Rik <rik@octave.org>
parents: 16551
diff changeset
154 %! dims = inputdlg (prompt, 'Enter Box Dimensions');
e39f00a32dc7 maint: Use parentheses around condition for switch(),while(),if() statements.
Rik <rik@octave.org>
parents: 16551
diff changeset
155 %! if (isempty (dims))
e39f00a32dc7 maint: Use parentheses around condition for switch(),while(),if() statements.
Rik <rik@octave.org>
parents: 16551
diff changeset
156 %! helpdlg ('Canceled by user', 'Information');
e39f00a32dc7 maint: Use parentheses around condition for switch(),while(),if() statements.
Rik <rik@octave.org>
parents: 16551
diff changeset
157 %! else
e39f00a32dc7 maint: Use parentheses around condition for switch(),while(),if() statements.
Rik <rik@octave.org>
parents: 16551
diff changeset
158 %! volume = str2num (dims{1}) * str2num (dims{2}) * str2num (dims{3});
e39f00a32dc7 maint: Use parentheses around condition for switch(),while(),if() statements.
Rik <rik@octave.org>
parents: 16551
diff changeset
159 %! surface = 2 * (str2num (dims{1}) * str2num (dims{2}) + ...
e39f00a32dc7 maint: Use parentheses around condition for switch(),while(),if() statements.
Rik <rik@octave.org>
parents: 16551
diff changeset
160 %! str2num (dims{2}) * str2num (dims{3}) + ...
e39f00a32dc7 maint: Use parentheses around condition for switch(),while(),if() statements.
Rik <rik@octave.org>
parents: 16551
diff changeset
161 %! str2num (dims{1}) * str2num (dims{3}));
e39f00a32dc7 maint: Use parentheses around condition for switch(),while(),if() statements.
Rik <rik@octave.org>
parents: 16551
diff changeset
162 %! helpdlg (sprintf ('Results:\nVolume = %.3f\nSurface = %.3f', volume, surface), 'Box Dimensions');
e39f00a32dc7 maint: Use parentheses around condition for switch(),while(),if() statements.
Rik <rik@octave.org>
parents: 16551
diff changeset
163 %! end
e39f00a32dc7 maint: Use parentheses around condition for switch(),while(),if() statements.
Rik <rik@octave.org>
parents: 16551
diff changeset
164
e39f00a32dc7 maint: Use parentheses around condition for switch(),while(),if() statements.
Rik <rik@octave.org>
parents: 16551
diff changeset
165 %!demo
e39f00a32dc7 maint: Use parentheses around condition for switch(),while(),if() statements.
Rik <rik@octave.org>
parents: 16551
diff changeset
166 %! disp ('- test inputdlg with prescribed scalar (2 lines per text field) and defaults.');
e39f00a32dc7 maint: Use parentheses around condition for switch(),while(),if() statements.
Rik <rik@octave.org>
parents: 16551
diff changeset
167 %! prompt = {'Width','Height','Depth'};
e39f00a32dc7 maint: Use parentheses around condition for switch(),while(),if() statements.
Rik <rik@octave.org>
parents: 16551
diff changeset
168 %! default = {'1.1','2.2','3.3'};
e39f00a32dc7 maint: Use parentheses around condition for switch(),while(),if() statements.
Rik <rik@octave.org>
parents: 16551
diff changeset
169 %! rc = 2;
e39f00a32dc7 maint: Use parentheses around condition for switch(),while(),if() statements.
Rik <rik@octave.org>
parents: 16551
diff changeset
170 %! dims = inputdlg (prompt, 'Enter Box Dimensions',rc,default);
e39f00a32dc7 maint: Use parentheses around condition for switch(),while(),if() statements.
Rik <rik@octave.org>
parents: 16551
diff changeset
171 %! if (isempty (dims))
e39f00a32dc7 maint: Use parentheses around condition for switch(),while(),if() statements.
Rik <rik@octave.org>
parents: 16551
diff changeset
172 %! helpdlg ('Canceled by user', 'Information');
e39f00a32dc7 maint: Use parentheses around condition for switch(),while(),if() statements.
Rik <rik@octave.org>
parents: 16551
diff changeset
173 %! else
e39f00a32dc7 maint: Use parentheses around condition for switch(),while(),if() statements.
Rik <rik@octave.org>
parents: 16551
diff changeset
174 %! volume = str2num (dims{1}) * str2num (dims{2}) * str2num (dims{3});
e39f00a32dc7 maint: Use parentheses around condition for switch(),while(),if() statements.
Rik <rik@octave.org>
parents: 16551
diff changeset
175 %! surface = 2 * (str2num (dims{1}) * str2num (dims{2}) + ...
e39f00a32dc7 maint: Use parentheses around condition for switch(),while(),if() statements.
Rik <rik@octave.org>
parents: 16551
diff changeset
176 %! str2num (dims{2}) * str2num (dims{3}) + ...
e39f00a32dc7 maint: Use parentheses around condition for switch(),while(),if() statements.
Rik <rik@octave.org>
parents: 16551
diff changeset
177 %! str2num (dims{1}) * str2num (dims{3}));
e39f00a32dc7 maint: Use parentheses around condition for switch(),while(),if() statements.
Rik <rik@octave.org>
parents: 16551
diff changeset
178 %! helpdlg (sprintf ('Results:\nVolume = %.3f\nSurface = %.3f', volume, surface), 'Box Dimensions');
e39f00a32dc7 maint: Use parentheses around condition for switch(),while(),if() statements.
Rik <rik@octave.org>
parents: 16551
diff changeset
179 %! end
16512
7f2395651a1c dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents: 16505
diff changeset
180
7f2395651a1c dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents: 16505
diff changeset
181 %!demo
16933
e39f00a32dc7 maint: Use parentheses around condition for switch(),while(),if() statements.
Rik <rik@octave.org>
parents: 16551
diff changeset
182 %! disp ('- test inputdlg with prescribed vector [1,2,3] for # of lines per text field and defaults.');
e39f00a32dc7 maint: Use parentheses around condition for switch(),while(),if() statements.
Rik <rik@octave.org>
parents: 16551
diff changeset
183 %! prompt = {'Width','Height','Depth'};
e39f00a32dc7 maint: Use parentheses around condition for switch(),while(),if() statements.
Rik <rik@octave.org>
parents: 16551
diff changeset
184 %! default = {'1.10', '2.10', '3.10'};
e39f00a32dc7 maint: Use parentheses around condition for switch(),while(),if() statements.
Rik <rik@octave.org>
parents: 16551
diff changeset
185 %! rc = [1,2,3]; % NOTE: must be an array
e39f00a32dc7 maint: Use parentheses around condition for switch(),while(),if() statements.
Rik <rik@octave.org>
parents: 16551
diff changeset
186 %! dims = inputdlg (prompt, 'Enter Box Dimensions',rc,default);
e39f00a32dc7 maint: Use parentheses around condition for switch(),while(),if() statements.
Rik <rik@octave.org>
parents: 16551
diff changeset
187 %! if (isempty (dims))
e39f00a32dc7 maint: Use parentheses around condition for switch(),while(),if() statements.
Rik <rik@octave.org>
parents: 16551
diff changeset
188 %! helpdlg ('Canceled by user', 'Information');
e39f00a32dc7 maint: Use parentheses around condition for switch(),while(),if() statements.
Rik <rik@octave.org>
parents: 16551
diff changeset
189 %! else
e39f00a32dc7 maint: Use parentheses around condition for switch(),while(),if() statements.
Rik <rik@octave.org>
parents: 16551
diff changeset
190 %! volume = str2num (dims{1}) * str2num (dims{2}) * str2num (dims{3});
e39f00a32dc7 maint: Use parentheses around condition for switch(),while(),if() statements.
Rik <rik@octave.org>
parents: 16551
diff changeset
191 %! surface = 2 * (str2num (dims{1}) * str2num (dims{2}) + ...
e39f00a32dc7 maint: Use parentheses around condition for switch(),while(),if() statements.
Rik <rik@octave.org>
parents: 16551
diff changeset
192 %! str2num (dims{2}) * str2num (dims{3}) + ...
e39f00a32dc7 maint: Use parentheses around condition for switch(),while(),if() statements.
Rik <rik@octave.org>
parents: 16551
diff changeset
193 %! str2num (dims{1}) * str2num (dims{3}));
e39f00a32dc7 maint: Use parentheses around condition for switch(),while(),if() statements.
Rik <rik@octave.org>
parents: 16551
diff changeset
194 %! helpdlg (sprintf ('Results:\nVolume = %.3f\nSurface = %.3f', volume, surface), 'Box Dimensions');
e39f00a32dc7 maint: Use parentheses around condition for switch(),while(),if() statements.
Rik <rik@octave.org>
parents: 16551
diff changeset
195 %! end
16512
7f2395651a1c dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents: 16505
diff changeset
196
7f2395651a1c dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents: 16505
diff changeset
197 %!demo
16933
e39f00a32dc7 maint: Use parentheses around condition for switch(),while(),if() statements.
Rik <rik@octave.org>
parents: 16551
diff changeset
198 %! disp ('- test inputdlg with prescribed row by column sizes and defaults.');
e39f00a32dc7 maint: Use parentheses around condition for switch(),while(),if() statements.
Rik <rik@octave.org>
parents: 16551
diff changeset
199 %! prompt = {'Width','Height','Depth'};
e39f00a32dc7 maint: Use parentheses around condition for switch(),while(),if() statements.
Rik <rik@octave.org>
parents: 16551
diff changeset
200 %! default = {'1.10', '2.20', '3.30'};
e39f00a32dc7 maint: Use parentheses around condition for switch(),while(),if() statements.
Rik <rik@octave.org>
parents: 16551
diff changeset
201 %! rc = [1,10; 2,20; 3,30]; % NOTE: must be an array
e39f00a32dc7 maint: Use parentheses around condition for switch(),while(),if() statements.
Rik <rik@octave.org>
parents: 16551
diff changeset
202 %! dims = inputdlg (prompt, 'Enter Box Dimensions',rc,default);
e39f00a32dc7 maint: Use parentheses around condition for switch(),while(),if() statements.
Rik <rik@octave.org>
parents: 16551
diff changeset
203 %! if (isempty (dims))
e39f00a32dc7 maint: Use parentheses around condition for switch(),while(),if() statements.
Rik <rik@octave.org>
parents: 16551
diff changeset
204 %! helpdlg ('Canceled by user', 'Information');
e39f00a32dc7 maint: Use parentheses around condition for switch(),while(),if() statements.
Rik <rik@octave.org>
parents: 16551
diff changeset
205 %! else
e39f00a32dc7 maint: Use parentheses around condition for switch(),while(),if() statements.
Rik <rik@octave.org>
parents: 16551
diff changeset
206 %! volume = str2num (dims{1}) * str2num (dims{2}) * str2num (dims{3});
e39f00a32dc7 maint: Use parentheses around condition for switch(),while(),if() statements.
Rik <rik@octave.org>
parents: 16551
diff changeset
207 %! surface = 2 * (str2num (dims{1}) * str2num (dims{2}) + ...
e39f00a32dc7 maint: Use parentheses around condition for switch(),while(),if() statements.
Rik <rik@octave.org>
parents: 16551
diff changeset
208 %! str2num (dims{2}) * str2num (dims{3}) + ...
e39f00a32dc7 maint: Use parentheses around condition for switch(),while(),if() statements.
Rik <rik@octave.org>
parents: 16551
diff changeset
209 %! str2num (dims{1}) * str2num (dims{3}));
e39f00a32dc7 maint: Use parentheses around condition for switch(),while(),if() statements.
Rik <rik@octave.org>
parents: 16551
diff changeset
210 %! helpdlg (sprintf ('Results:\nVolume = %.3f\nSurface = %.3f', volume, surface), 'Box Dimensions');
e39f00a32dc7 maint: Use parentheses around condition for switch(),while(),if() statements.
Rik <rik@octave.org>
parents: 16551
diff changeset
211 %! end
e39f00a32dc7 maint: Use parentheses around condition for switch(),while(),if() statements.
Rik <rik@octave.org>
parents: 16551
diff changeset
212
21630
b5d9b95d1e1a Removing Java dialog boxes.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 21178
diff changeset
213 %!error<narginchk> inputdlg (1, 2, 3, 4, 5)
b5d9b95d1e1a Removing Java dialog boxes.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 21178
diff changeset
214 %!error<PROMPT must be a character string> inputdlg (1)
b5d9b95d1e1a Removing Java dialog boxes.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 21178
diff changeset
215 %!error<TITLE must be a character string> inputdlg ("msg", 1)
b5d9b95d1e1a Removing Java dialog boxes.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 21178
diff changeset
216 %!error<ROWSCOLS must be numeric> inputdlg ("msg", "title", "1")
b5d9b95d1e1a Removing Java dialog boxes.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 21178
diff changeset
217 %!error<ROWSCOLS vector does not match size>
b5d9b95d1e1a Removing Java dialog boxes.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 21178
diff changeset
218 %! inputdlg ({"a1", "a2"}, "title", [1, 2, 3])