annotate scripts/gui/listdlg.m @ 20830:b65888ec820e draft default tip gccjit

dmalcom gcc jit import
author Stefan Mahr <dac922@gmx.de>
date Fri, 27 Feb 2015 16:59:36 +0100
parents 63736167fb78
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: 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 -*-
15772
0f1a143e5002 Overhaul scripts/java directory to conform to Octave core.
Rik <rik@octave.org>
parents: 15750
diff changeset
20 ## @deftypefn {Function File} {[@var{sel}, @var{ok}] =} listdlg (@var{key}, @var{value}, @dots{})
20383
777f26aa8e3e doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 20291
diff changeset
21 ## Return user inputs from a list dialog box in a vector of selection indices
777f26aa8e3e doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 20291
diff changeset
22 ## @var{sel} and a flag @var{ok} indicating how the user closed the dialog
777f26aa8e3e doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 20291
diff changeset
23 ## box.
777f26aa8e3e doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 20291
diff changeset
24 ##
777f26aa8e3e doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 20291
diff changeset
25 ## The value of @var{ok} is 1 if the user closed the box with the OK button,
777f26aa8e3e doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 20291
diff changeset
26 ## otherwise it is 0 and @var{sel} is empty.
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
27 ##
16392
801297f14e4b doc: Improve documentation for Java chapter and java functions.
Rik <rik@octave.org>
parents: 15806
diff changeset
28 ## The indices in @var{sel} are 1-based.
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
29 ##
19790
446c46af4b42 strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents: 19088
diff changeset
30 ## The arguments are specified in form of @var{key}, @var{value} pairs.
17281
bc924baa2c4e doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents: 16933
diff changeset
31 ## The @qcode{"ListString"} argument pair must be specified.
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
32 ##
15748
54e8c2527a9e style and doc fixes for newly imported Java package .m files
John W. Eaton <jwe@octave.org>
parents: 15746
diff changeset
33 ## Valid @var{key} and @var{value} pairs are:
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
34 ##
16392
801297f14e4b doc: Improve documentation for Java chapter and java functions.
Rik <rik@octave.org>
parents: 15806
diff changeset
35 ## @table @asis
17281
bc924baa2c4e doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents: 16933
diff changeset
36 ## @item @qcode{"ListString"}
16392
801297f14e4b doc: Improve documentation for Java chapter and java functions.
Rik <rik@octave.org>
parents: 15806
diff changeset
37 ## a cell array of strings comprising the content of the list.
15772
0f1a143e5002 Overhaul scripts/java directory to conform to Octave core.
Rik <rik@octave.org>
parents: 15750
diff changeset
38 ##
17281
bc924baa2c4e doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents: 16933
diff changeset
39 ## @item @qcode{"SelectionMode"}
bc924baa2c4e doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents: 16933
diff changeset
40 ## can be either @qcode{"Single"} or @qcode{"Multiple"} (default).
15772
0f1a143e5002 Overhaul scripts/java directory to conform to Octave core.
Rik <rik@octave.org>
parents: 15750
diff changeset
41 ##
17281
bc924baa2c4e doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents: 16933
diff changeset
42 ## @item @qcode{"ListSize"}
20383
777f26aa8e3e doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 20291
diff changeset
43 ## a vector with two elements @var{width} and @var{height} defining the size
777f26aa8e3e doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 20291
diff changeset
44 ## of the list field in pixels. Default is [160 300].
15772
0f1a143e5002 Overhaul scripts/java directory to conform to Octave core.
Rik <rik@octave.org>
parents: 15750
diff changeset
45 ##
17281
bc924baa2c4e doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents: 16933
diff changeset
46 ## @item @qcode{"InitialValue"}
20383
777f26aa8e3e doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 20291
diff changeset
47 ## a vector containing 1-based indices of preselected elements.
777f26aa8e3e doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 20291
diff changeset
48 ## Default is 1 (first item).
15772
0f1a143e5002 Overhaul scripts/java directory to conform to Octave core.
Rik <rik@octave.org>
parents: 15750
diff changeset
49 ##
17281
bc924baa2c4e doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents: 16933
diff changeset
50 ## @item @qcode{"Name"}
16392
801297f14e4b doc: Improve documentation for Java chapter and java functions.
Rik <rik@octave.org>
parents: 15806
diff changeset
51 ## a string to be used as the dialog caption. Default is "".
15772
0f1a143e5002 Overhaul scripts/java directory to conform to Octave core.
Rik <rik@octave.org>
parents: 15750
diff changeset
52 ##
17281
bc924baa2c4e doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents: 16933
diff changeset
53 ## @item @qcode{"PromptString"}
20383
777f26aa8e3e doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 20291
diff changeset
54 ## a cell array of strings to be displayed above the list field.
777f26aa8e3e doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 20291
diff changeset
55 ## Default is @{@}.
15772
0f1a143e5002 Overhaul scripts/java directory to conform to Octave core.
Rik <rik@octave.org>
parents: 15750
diff changeset
56 ##
17281
bc924baa2c4e doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents: 16933
diff changeset
57 ## @item @qcode{"OKString"}
bc924baa2c4e doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents: 16933
diff changeset
58 ## a string used to label the OK button. Default is @qcode{"OK"}.
15772
0f1a143e5002 Overhaul scripts/java directory to conform to Octave core.
Rik <rik@octave.org>
parents: 15750
diff changeset
59 ##
17281
bc924baa2c4e doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents: 16933
diff changeset
60 ## @item @qcode{"CancelString"}
bc924baa2c4e doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents: 16933
diff changeset
61 ## a string used to label the Cancel button. Default is @qcode{"Cancel"}.
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
62 ## @end table
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
63 ##
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
64 ## Example:
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
65 ##
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
66 ## @example
15772
0f1a143e5002 Overhaul scripts/java directory to conform to Octave core.
Rik <rik@octave.org>
parents: 15750
diff changeset
67 ## @group
15806
01d4f742d75d doc: Re-organize and improve Java Interface documentation.
Rik <rik@octave.org>
parents: 15790
diff changeset
68 ## [sel, ok] = listdlg ("ListString", @{"An item", "another", "yet another"@},
01d4f742d75d doc: Re-organize and improve Java Interface documentation.
Rik <rik@octave.org>
parents: 15790
diff changeset
69 ## "SelectionMode", "Multiple");
15748
54e8c2527a9e style and doc fixes for newly imported Java package .m files
John W. Eaton <jwe@octave.org>
parents: 15746
diff changeset
70 ## if (ok == 1)
15806
01d4f742d75d doc: Re-organize and improve Java Interface documentation.
Rik <rik@octave.org>
parents: 15790
diff changeset
71 ## for i = 1:numel (sel)
15750
05c781cca57e use numel instead of length in newly imported java functions
John W. Eaton <jwe@octave.org>
parents: 15748
diff changeset
72 ## disp (sel(i));
15772
0f1a143e5002 Overhaul scripts/java directory to conform to Octave core.
Rik <rik@octave.org>
parents: 15750
diff changeset
73 ## endfor
0f1a143e5002 Overhaul scripts/java directory to conform to Octave core.
Rik <rik@octave.org>
parents: 15750
diff changeset
74 ## endif
0f1a143e5002 Overhaul scripts/java directory to conform to Octave core.
Rik <rik@octave.org>
parents: 15750
diff changeset
75 ## @end group
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
76 ## @end example
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
77 ##
18829
7bccc182e2f7 doc: Update pause documentation and add seealso links between related functions.
Rik <rik@octave.org>
parents: 18718
diff changeset
78 ## @seealso{menu, errordlg, helpdlg, inputdlg, msgbox, questdlg, warndlg}
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
79 ## @end deftypefn
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
80
16512
7f2395651a1c dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents: 16505
diff changeset
81 function [sel, ok] = listdlg (varargin)
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
82
16551
6ae555fc8c43 Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 16512
diff changeset
83 if (nargin < 2)
6ae555fc8c43 Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 16512
diff changeset
84 print_usage ();
6ae555fc8c43 Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 16512
diff changeset
85 endif
6ae555fc8c43 Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 16512
diff changeset
86
6ae555fc8c43 Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 16512
diff changeset
87 listcell = {""};
20573
63736167fb78 Fix listdlg() when used without selection mode under Qt (Bug #45545).
Rik <rik@octave.org>
parents: 20391
diff changeset
88 selmode = "multiple";
16551
6ae555fc8c43 Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 16512
diff changeset
89 listsize = [160, 300];
6ae555fc8c43 Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 16512
diff changeset
90 initialvalue = 1;
6ae555fc8c43 Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 16512
diff changeset
91 name = "";
6ae555fc8c43 Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 16512
diff changeset
92 prompt = {};
6ae555fc8c43 Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 16512
diff changeset
93 okstring = "OK";
6ae555fc8c43 Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 16512
diff changeset
94 cancelstring = "Cancel";
15748
54e8c2527a9e style and doc fixes for newly imported Java package .m files
John W. Eaton <jwe@octave.org>
parents: 15746
diff changeset
95
16551
6ae555fc8c43 Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 16512
diff changeset
96 ## handle key, value pairs
6ae555fc8c43 Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 16512
diff changeset
97 for i = 1:2:nargin-1
18718
51a0d1c1023c listdlg.m: return Octave value rather than Java int object.(bug #41931).
Philip Nienhuis <prnienhuis@users.sf.net>
parents: 17744
diff changeset
98 if (strcmpi (varargin{i}, "ListString"))
16551
6ae555fc8c43 Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 16512
diff changeset
99 listcell = varargin{i+1};
18718
51a0d1c1023c listdlg.m: return Octave value rather than Java int object.(bug #41931).
Philip Nienhuis <prnienhuis@users.sf.net>
parents: 17744
diff changeset
100 elseif (strcmpi (varargin{i}, "SelectionMode"))
20291
8bfadb26afcd Allow case-insensitive SelectionMode value in listdlg (bug #44822).
Rik <rik@octave.org>
parents: 20135
diff changeset
101 selmode = tolower (varargin{i+1});
18718
51a0d1c1023c listdlg.m: return Octave value rather than Java int object.(bug #41931).
Philip Nienhuis <prnienhuis@users.sf.net>
parents: 17744
diff changeset
102 elseif (strcmpi (varargin{i}, "ListSize"))
16551
6ae555fc8c43 Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 16512
diff changeset
103 listsize = varargin{i+1};
18718
51a0d1c1023c listdlg.m: return Octave value rather than Java int object.(bug #41931).
Philip Nienhuis <prnienhuis@users.sf.net>
parents: 17744
diff changeset
104 elseif (strcmpi (varargin{i}, "InitialValue"))
16551
6ae555fc8c43 Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 16512
diff changeset
105 initialvalue = varargin{i+1};
18718
51a0d1c1023c listdlg.m: return Octave value rather than Java int object.(bug #41931).
Philip Nienhuis <prnienhuis@users.sf.net>
parents: 17744
diff changeset
106 elseif (strcmpi (varargin{i}, "Name"))
16551
6ae555fc8c43 Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 16512
diff changeset
107 name = varargin{i+1};
18718
51a0d1c1023c listdlg.m: return Octave value rather than Java int object.(bug #41931).
Philip Nienhuis <prnienhuis@users.sf.net>
parents: 17744
diff changeset
108 elseif (strcmpi (varargin{i}, "PromptString"))
16551
6ae555fc8c43 Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 16512
diff changeset
109 prompt = varargin{i+1};
18718
51a0d1c1023c listdlg.m: return Octave value rather than Java int object.(bug #41931).
Philip Nienhuis <prnienhuis@users.sf.net>
parents: 17744
diff changeset
110 elseif (strcmpi (varargin{i}, "OKString"))
16551
6ae555fc8c43 Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 16512
diff changeset
111 okstring = varargin{i+1};
18718
51a0d1c1023c listdlg.m: return Octave value rather than Java int object.(bug #41931).
Philip Nienhuis <prnienhuis@users.sf.net>
parents: 17744
diff changeset
112 elseif (strcmpi (varargin{i}, "CancelString"))
16551
6ae555fc8c43 Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 16512
diff changeset
113 cancelstring = varargin{i+1};
6ae555fc8c43 Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 16512
diff changeset
114 endif
6ae555fc8c43 Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 16512
diff changeset
115 endfor
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
116
16551
6ae555fc8c43 Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 16512
diff changeset
117 ## make sure prompt strings are a cell array
6ae555fc8c43 Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 16512
diff changeset
118 if (! iscell (prompt))
6ae555fc8c43 Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 16512
diff changeset
119 prompt = {prompt};
6ae555fc8c43 Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 16512
diff changeset
120 endif
16512
7f2395651a1c dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents: 16505
diff changeset
121
16551
6ae555fc8c43 Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 16512
diff changeset
122 ## make sure listcell strings are a cell array
6ae555fc8c43 Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 16512
diff changeset
123 if (! iscell (listcell))
6ae555fc8c43 Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 16512
diff changeset
124 listcell = {listcell};
20391
aa36fb998a4d maint: Remove unnecessary whitespace at end of lines.
Rik <rik@octave.org>
parents: 20383
diff changeset
125 elseif (iscellstr (listcell{1}))
20135
501cbbaafc56 listdlg.m: Accept cell array with single cellstr entry from menu for Matlab compatibility (bug #44501).
Rik <rik@octave.org>
parents: 20053
diff changeset
126 listcell = listcell{1};
16551
6ae555fc8c43 Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 16512
diff changeset
127 endif
6ae555fc8c43 Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 16512
diff changeset
128
6ae555fc8c43 Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 16512
diff changeset
129 ## make sure valid selection mode
20573
63736167fb78 Fix listdlg() when used without selection mode under Qt (Bug #45545).
Rik <rik@octave.org>
parents: 20391
diff changeset
130 if (! strcmp (selmode, "multiple") && ! strcmp (selmode, "single"))
20291
8bfadb26afcd Allow case-insensitive SelectionMode value in listdlg (bug #44822).
Rik <rik@octave.org>
parents: 20135
diff changeset
131 error ("listdlg: invalid SelectionMode");
16551
6ae555fc8c43 Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 16512
diff changeset
132 endif
6ae555fc8c43 Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 16512
diff changeset
133
20053
9b7ca334a104 Backout cset a9952a647d52 and use __octave_link_enabled__ rather than isguirunning.
Rik <rik@octave.org>
parents: 20004
diff changeset
134 if (__octave_link_enabled__ ())
16551
6ae555fc8c43 Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 16512
diff changeset
135 [sel, ok] = __octave_link_list_dialog__ (listcell, selmode, listsize,
18718
51a0d1c1023c listdlg.m: return Octave value rather than Java int object.(bug #41931).
Philip Nienhuis <prnienhuis@users.sf.net>
parents: 17744
diff changeset
136 initialvalue, name, prompt,
51a0d1c1023c listdlg.m: return Octave value rather than Java int object.(bug #41931).
Philip Nienhuis <prnienhuis@users.sf.net>
parents: 17744
diff changeset
137 okstring, cancelstring);
16551
6ae555fc8c43 Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 16512
diff changeset
138 elseif (__have_feature__ ("JAVA"))
6ae555fc8c43 Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 16512
diff changeset
139 ## transform matrices to cell arrays of strings
6ae555fc8c43 Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 16512
diff changeset
140 ## swap width and height to correct calling format for JDialogBox
6ae555fc8c43 Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 16512
diff changeset
141 listsize = {num2str(listsize(2)), num2str(listsize(1))};
6ae555fc8c43 Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 16512
diff changeset
142 initialvalue = arrayfun (@num2str, initialvalue, "UniformOutput", false);
16933
e39f00a32dc7 maint: Use parentheses around condition for switch(),while(),if() statements.
Rik <rik@octave.org>
parents: 16551
diff changeset
143 if (isempty (prompt))
16551
6ae555fc8c43 Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 16512
diff changeset
144 prompt = {""};
6ae555fc8c43 Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 16512
diff changeset
145 endif
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
16551
6ae555fc8c43 Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 16512
diff changeset
147 ret = javaMethod ("listdlg", "org.octave.JDialogBox", listcell,
6ae555fc8c43 Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 16512
diff changeset
148 selmode, listsize, initialvalue, name, prompt,
6ae555fc8c43 Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 16512
diff changeset
149 okstring, cancelstring);
16512
7f2395651a1c dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents: 16505
diff changeset
150
16551
6ae555fc8c43 Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 16512
diff changeset
151 if (numel (ret) > 0)
18718
51a0d1c1023c listdlg.m: return Octave value rather than Java int object.(bug #41931).
Philip Nienhuis <prnienhuis@users.sf.net>
parents: 17744
diff changeset
152 sel = zeros (1, numel (ret));
51a0d1c1023c listdlg.m: return Octave value rather than Java int object.(bug #41931).
Philip Nienhuis <prnienhuis@users.sf.net>
parents: 17744
diff changeset
153 ## for loop needed to convert Java array ret into Octave double sel
51a0d1c1023c listdlg.m: return Octave value rather than Java int object.(bug #41931).
Philip Nienhuis <prnienhuis@users.sf.net>
parents: 17744
diff changeset
154 for i = 1:numel (ret)
51a0d1c1023c listdlg.m: return Octave value rather than Java int object.(bug #41931).
Philip Nienhuis <prnienhuis@users.sf.net>
parents: 17744
diff changeset
155 sel(i) = ret(i);
51a0d1c1023c listdlg.m: return Octave value rather than Java int object.(bug #41931).
Philip Nienhuis <prnienhuis@users.sf.net>
parents: 17744
diff changeset
156 endfor
16551
6ae555fc8c43 Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 16512
diff changeset
157 ok = 1;
6ae555fc8c43 Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 16512
diff changeset
158 else
18718
51a0d1c1023c listdlg.m: return Octave value rather than Java int object.(bug #41931).
Philip Nienhuis <prnienhuis@users.sf.net>
parents: 17744
diff changeset
159 sel = [];
16551
6ae555fc8c43 Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 16512
diff changeset
160 ok = 0;
6ae555fc8c43 Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 16512
diff changeset
161 endif
6ae555fc8c43 Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 16512
diff changeset
162 else
6ae555fc8c43 Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 16512
diff changeset
163 error ("listdlg is not available in this version of Octave");
6ae555fc8c43 Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 16512
diff changeset
164 endif
16512
7f2395651a1c dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents: 16505
diff changeset
165
15748
54e8c2527a9e style and doc fixes for newly imported Java package .m files
John W. Eaton <jwe@octave.org>
parents: 15746
diff changeset
166 endfunction
15772
0f1a143e5002 Overhaul scripts/java directory to conform to Octave core.
Rik <rik@octave.org>
parents: 15750
diff changeset
167
16933
e39f00a32dc7 maint: Use parentheses around condition for switch(),while(),if() statements.
Rik <rik@octave.org>
parents: 16551
diff changeset
168
16512
7f2395651a1c dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents: 16505
diff changeset
169 %!demo
19088
310fd62e9d4b listdlg.m: convert SQ strings to DQ, fix num2str call in %!demos.
Philip Nienhuis <prnienhuis@users.sf.net>
parents: 18829
diff changeset
170 %! disp ("- test listdlg with selectionmode single. No caption, no prompt.");
310fd62e9d4b listdlg.m: convert SQ strings to DQ, fix num2str call in %!demos.
Philip Nienhuis <prnienhuis@users.sf.net>
parents: 18829
diff changeset
171 %! itemlist = {"An item \\alpha", "another", "yet another"};
310fd62e9d4b listdlg.m: convert SQ strings to DQ, fix num2str call in %!demos.
Philip Nienhuis <prnienhuis@users.sf.net>
parents: 18829
diff changeset
172 %! s = listdlg ("ListString", itemlist, "SelectionMode", "Single");
16933
e39f00a32dc7 maint: Use parentheses around condition for switch(),while(),if() statements.
Rik <rik@octave.org>
parents: 16551
diff changeset
173 %! imax = numel (s);
e39f00a32dc7 maint: Use parentheses around condition for switch(),while(),if() statements.
Rik <rik@octave.org>
parents: 16551
diff changeset
174 %! for i=1:1:imax
19088
310fd62e9d4b listdlg.m: convert SQ strings to DQ, fix num2str call in %!demos.
Philip Nienhuis <prnienhuis@users.sf.net>
parents: 18829
diff changeset
175 %! disp (["Selected: ", num2str(i), ": ", itemlist{s(i)}]);
16933
e39f00a32dc7 maint: Use parentheses around condition for switch(),while(),if() statements.
Rik <rik@octave.org>
parents: 16551
diff changeset
176 %! 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
177
7f2395651a1c dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents: 16505
diff changeset
178 %!demo
19088
310fd62e9d4b listdlg.m: convert SQ strings to DQ, fix num2str call in %!demos.
Philip Nienhuis <prnienhuis@users.sf.net>
parents: 18829
diff changeset
179 %! disp ("- test listdlg with selectionmode and preselection. Has caption and two lines prompt.");
310fd62e9d4b listdlg.m: convert SQ strings to DQ, fix num2str call in %!demos.
Philip Nienhuis <prnienhuis@users.sf.net>
parents: 18829
diff changeset
180 %! itemlist = {"An item \\alpha", "another", "yet another"};
310fd62e9d4b listdlg.m: convert SQ strings to DQ, fix num2str call in %!demos.
Philip Nienhuis <prnienhuis@users.sf.net>
parents: 18829
diff changeset
181 %! s = listdlg ("ListString", itemlist, ...
310fd62e9d4b listdlg.m: convert SQ strings to DQ, fix num2str call in %!demos.
Philip Nienhuis <prnienhuis@users.sf.net>
parents: 18829
diff changeset
182 %! "SelectionMode", "Multiple", ...
310fd62e9d4b listdlg.m: convert SQ strings to DQ, fix num2str call in %!demos.
Philip Nienhuis <prnienhuis@users.sf.net>
parents: 18829
diff changeset
183 %! "Name", "Selection Dialog", ...
310fd62e9d4b listdlg.m: convert SQ strings to DQ, fix num2str call in %!demos.
Philip Nienhuis <prnienhuis@users.sf.net>
parents: 18829
diff changeset
184 %! "InitialValue", [1,2,3,4],
310fd62e9d4b listdlg.m: convert SQ strings to DQ, fix num2str call in %!demos.
Philip Nienhuis <prnienhuis@users.sf.net>
parents: 18829
diff changeset
185 %! "PromptString", {"Select <b>an</b> item...", "...or <b>multiple</b> items"});
16933
e39f00a32dc7 maint: Use parentheses around condition for switch(),while(),if() statements.
Rik <rik@octave.org>
parents: 16551
diff changeset
186 %! imax = numel (s);
e39f00a32dc7 maint: Use parentheses around condition for switch(),while(),if() statements.
Rik <rik@octave.org>
parents: 16551
diff changeset
187 %! for i=1:1:imax
19088
310fd62e9d4b listdlg.m: convert SQ strings to DQ, fix num2str call in %!demos.
Philip Nienhuis <prnienhuis@users.sf.net>
parents: 18829
diff changeset
188 %! disp (["Selected: ", num2str(i), ": ", itemlist{s(i)}]);
16933
e39f00a32dc7 maint: Use parentheses around condition for switch(),while(),if() statements.
Rik <rik@octave.org>
parents: 16551
diff changeset
189 %! end
16551
6ae555fc8c43 Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 16512
diff changeset
190
6ae555fc8c43 Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 16512
diff changeset
191 %!demo
19088
310fd62e9d4b listdlg.m: convert SQ strings to DQ, fix num2str call in %!demos.
Philip Nienhuis <prnienhuis@users.sf.net>
parents: 18829
diff changeset
192 %! disp ("- test listdlg with listsize.");
310fd62e9d4b listdlg.m: convert SQ strings to DQ, fix num2str call in %!demos.
Philip Nienhuis <prnienhuis@users.sf.net>
parents: 18829
diff changeset
193 %! itemlist = {"Neutron", "Electron", "Quark", "Proton", "Neutrino"};
310fd62e9d4b listdlg.m: convert SQ strings to DQ, fix num2str call in %!demos.
Philip Nienhuis <prnienhuis@users.sf.net>
parents: 18829
diff changeset
194 %! s = listdlg ("ListString", itemlist,
310fd62e9d4b listdlg.m: convert SQ strings to DQ, fix num2str call in %!demos.
Philip Nienhuis <prnienhuis@users.sf.net>
parents: 18829
diff changeset
195 %! "Name", "Bits and Pieces",
310fd62e9d4b listdlg.m: convert SQ strings to DQ, fix num2str call in %!demos.
Philip Nienhuis <prnienhuis@users.sf.net>
parents: 18829
diff changeset
196 %! "ListSize", [200 75]);
16933
e39f00a32dc7 maint: Use parentheses around condition for switch(),while(),if() statements.
Rik <rik@octave.org>
parents: 16551
diff changeset
197 %! imax = numel (s);
e39f00a32dc7 maint: Use parentheses around condition for switch(),while(),if() statements.
Rik <rik@octave.org>
parents: 16551
diff changeset
198 %! for i=1:1:imax
19088
310fd62e9d4b listdlg.m: convert SQ strings to DQ, fix num2str call in %!demos.
Philip Nienhuis <prnienhuis@users.sf.net>
parents: 18829
diff changeset
199 %! disp (["Selected: ", num2str(i), ": ", itemlist{s(i)}]);
16933
e39f00a32dc7 maint: Use parentheses around condition for switch(),while(),if() statements.
Rik <rik@octave.org>
parents: 16551
diff changeset
200 %! end