Mercurial > octave-libtiff
annotate scripts/gui/listdlg.m @ 30195:a7981aa5822b
event-manager: Add function to signal valid implementation of GUI dialogs (bug #60980).
The event-manager is also enabled when starting with --no-gui-libs. But not all
implementations of the event-manager have dialogs (only Qt at the moment which
isn't used when starting with --no-gui-libs). Add functions that return if the
event-manager has implemented dialogs.
* libinterp/corefcn/event-manager.h (interpreter_events::have_dialogs,
event_manager::have_dialogs): Add new function "have_dialogs".
(event_manager::file_dialog, event_manager::input_dialog,
event_manager::list_dialog, event_manager::question_dialog): Guard with
"have_dialogs".
* libinterp/corefcn/event-manager.cc (F__event_manager_have_dialogs__): Add new
function.
* libgui/src/qt-interpreter-events.h (qt_interpreter_events::have_dialogs): Add
new function.
* scripts/gui/inputdlg.m, scripts/gui/listdlg.m, scripts/gui/msgbox.m,
scripts/gui/questdlg.m, scripts/gui/uigetdir.m, scripts/gui/uigetfile.m,
scripts/gui/uiputfile.m: Check "____event_manager_have_dialogs__" instead of
"__event_manager_enabled__".
* scripts/gui/private/__get_funcname__.m: Try to use dialog functions specific
to the current graphics toolkit if the event-manager doesn't have implemented
dialogs.
author | Markus Mützel <markus.muetzel@gmx.de> |
---|---|
date | Sun, 19 Sep 2021 15:36:19 +0200 |
parents | 7854d5752dd2 |
children | 796f54d4ddbf |
rev | line source |
---|---|
27923
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
1 ######################################################################## |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
2 ## |
29358
0a5b15007766
update Octave Project Developers copyright for the new year
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
3 ## Copyright (C) 2010-2021 The Octave Project Developers |
27918
b442ec6dda5c
use centralized file for copyright info for individual contributors
John W. Eaton <jwe@octave.org>
parents:
27263
diff
changeset
|
4 ## |
27923
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
5 ## See the file COPYRIGHT.md in the top-level directory of this |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
6 ## distribution or <https://octave.org/copyright/>. |
15625
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
7 ## |
15746
da26f72408a7
update copyright statements in newly added java files
John W. Eaton <jwe@octave.org>
parents:
15709
diff
changeset
|
8 ## 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
|
9 ## |
24534
194eb4bd202b
maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
10 ## Octave is free software: you can redistribute it and/or modify it |
15746
da26f72408a7
update copyright statements in newly added java files
John W. Eaton <jwe@octave.org>
parents:
15709
diff
changeset
|
11 ## under the terms of the GNU General Public License as published by |
24534
194eb4bd202b
maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
12 ## the Free Software Foundation, either version 3 of the License, or |
22755
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
13 ## (at your option) any later version. |
15746
da26f72408a7
update copyright statements in newly added java files
John W. Eaton <jwe@octave.org>
parents:
15709
diff
changeset
|
14 ## |
da26f72408a7
update copyright statements in newly added java files
John W. Eaton <jwe@octave.org>
parents:
15709
diff
changeset
|
15 ## 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
|
16 ## WITHOUT ANY WARRANTY; without even the implied warranty of |
22755
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
17 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
18 ## GNU 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
|
19 ## |
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
20 ## 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
|
21 ## along with Octave; see the file COPYING. If not, see |
24534
194eb4bd202b
maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
22 ## <https://www.gnu.org/licenses/>. |
27923
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
23 ## |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
24 ######################################################################## |
15625
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
25 |
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
26 ## -*- texinfo -*- |
20852
516bb87ea72e
2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents:
20363
diff
changeset
|
27 ## @deftypefn {} {[@var{sel}, @var{ok}] =} listdlg (@var{key}, @var{value}, @dots{}) |
20173
777f26aa8e3e
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
20081
diff
changeset
|
28 ## Return user inputs from a list dialog box in a vector of selection indices |
21637
59ebef9680ef
More cleanup associated with removing Java dialog boxes (cset b5d9b95d1e1a).
Rik <rik@octave.org>
parents:
21630
diff
changeset
|
29 ## (@var{sel}) and a flag indicating how the user closed the dialog box |
59ebef9680ef
More cleanup associated with removing Java dialog boxes (cset b5d9b95d1e1a).
Rik <rik@octave.org>
parents:
21630
diff
changeset
|
30 ## (@var{ok}). |
59ebef9680ef
More cleanup associated with removing Java dialog boxes (cset b5d9b95d1e1a).
Rik <rik@octave.org>
parents:
21630
diff
changeset
|
31 ## |
59ebef9680ef
More cleanup associated with removing Java dialog boxes (cset b5d9b95d1e1a).
Rik <rik@octave.org>
parents:
21630
diff
changeset
|
32 ## The indices in @var{sel} are 1-based. |
20173
777f26aa8e3e
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
20081
diff
changeset
|
33 ## |
777f26aa8e3e
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
20081
diff
changeset
|
34 ## 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:
20081
diff
changeset
|
35 ## 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
|
36 ## |
21637
59ebef9680ef
More cleanup associated with removing Java dialog boxes (cset b5d9b95d1e1a).
Rik <rik@octave.org>
parents:
21630
diff
changeset
|
37 ## Input arguments are specified in form of @var{key}, @var{value} pairs. |
26014 | 38 ## The @qcode{"ListString"} argument pair @strong{must} be specified. |
15625
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
39 ## |
15748
54e8c2527a9e
style and doc fixes for newly imported Java package .m files
John W. Eaton <jwe@octave.org>
parents:
15746
diff
changeset
|
40 ## 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
|
41 ## |
16392
801297f14e4b
doc: Improve documentation for Java chapter and java functions.
Rik <rik@octave.org>
parents:
15806
diff
changeset
|
42 ## @table @asis |
17281
bc924baa2c4e
doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents:
16933
diff
changeset
|
43 ## @item @qcode{"ListString"} |
26014 | 44 ## a cell array of strings specifying the items to list in the dialog. |
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{"SelectionMode"} |
26014 | 47 ## can be either @qcode{"Single"} (only one item may be selected at a time) or |
48 ## @qcode{"Multiple"} (default). | |
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{"ListSize"} |
26035
0a39db17170c
doc: Clean up docstrings for XXXdlg.m functions
Rik <rik@octave.org>
parents:
26014
diff
changeset
|
51 ## a two-element vector @code{[@var{width}, @var{height}]} specifying the size |
26014 | 52 ## of the list field in pixels. The default is [160, 300]. |
15772
0f1a143e5002
Overhaul scripts/java directory to conform to Octave core.
Rik <rik@octave.org>
parents:
15750
diff
changeset
|
53 ## |
17281
bc924baa2c4e
doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents:
16933
diff
changeset
|
54 ## @item @qcode{"InitialValue"} |
26014 | 55 ## a vector containing 1-based indices of elements which will be pre-selected |
56 ## when the list dialog is first displayed. | |
57 ## The default is 1 (first item). | |
15772
0f1a143e5002
Overhaul scripts/java directory to conform to Octave core.
Rik <rik@octave.org>
parents:
15750
diff
changeset
|
58 ## |
17281
bc924baa2c4e
doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents:
16933
diff
changeset
|
59 ## @item @qcode{"Name"} |
16392
801297f14e4b
doc: Improve documentation for Java chapter and java functions.
Rik <rik@octave.org>
parents:
15806
diff
changeset
|
60 ## 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
|
61 ## |
17281
bc924baa2c4e
doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents:
16933
diff
changeset
|
62 ## @item @qcode{"PromptString"} |
26014 | 63 ## a cell array of strings to be displayed above the list of items. |
20173
777f26aa8e3e
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
20081
diff
changeset
|
64 ## Default is @{@}. |
15772
0f1a143e5002
Overhaul scripts/java directory to conform to Octave core.
Rik <rik@octave.org>
parents:
15750
diff
changeset
|
65 ## |
17281
bc924baa2c4e
doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents:
16933
diff
changeset
|
66 ## @item @qcode{"OKString"} |
bc924baa2c4e
doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents:
16933
diff
changeset
|
67 ## 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
|
68 ## |
17281
bc924baa2c4e
doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents:
16933
diff
changeset
|
69 ## @item @qcode{"CancelString"} |
bc924baa2c4e
doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents:
16933
diff
changeset
|
70 ## 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
|
71 ## @end table |
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
72 ## |
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
73 ## Example: |
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
74 ## |
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
75 ## @example |
15772
0f1a143e5002
Overhaul scripts/java directory to conform to Octave core.
Rik <rik@octave.org>
parents:
15750
diff
changeset
|
76 ## @group |
21630
b5d9b95d1e1a
Removing Java dialog boxes.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
20852
diff
changeset
|
77 ## my_options = @{"An item", "another", "yet another"@}; |
b5d9b95d1e1a
Removing Java dialog boxes.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
20852
diff
changeset
|
78 ## [sel, ok] = listdlg ("ListString", my_options, |
15806
01d4f742d75d
doc: Re-organize and improve Java Interface documentation.
Rik <rik@octave.org>
parents:
15790
diff
changeset
|
79 ## "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
|
80 ## if (ok == 1) |
21630
b5d9b95d1e1a
Removing Java dialog boxes.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
20852
diff
changeset
|
81 ## disp ("You selected:"); |
15806
01d4f742d75d
doc: Re-organize and improve Java Interface documentation.
Rik <rik@octave.org>
parents:
15790
diff
changeset
|
82 ## for i = 1:numel (sel) |
21630
b5d9b95d1e1a
Removing Java dialog boxes.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
20852
diff
changeset
|
83 ## disp (sprintf ("\t%s", my_options@{sel(i)@})); |
15772
0f1a143e5002
Overhaul scripts/java directory to conform to Octave core.
Rik <rik@octave.org>
parents:
15750
diff
changeset
|
84 ## endfor |
21630
b5d9b95d1e1a
Removing Java dialog boxes.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
20852
diff
changeset
|
85 ## else |
b5d9b95d1e1a
Removing Java dialog boxes.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
20852
diff
changeset
|
86 ## disp ("You cancelled."); |
15772
0f1a143e5002
Overhaul scripts/java directory to conform to Octave core.
Rik <rik@octave.org>
parents:
15750
diff
changeset
|
87 ## endif |
0f1a143e5002
Overhaul scripts/java directory to conform to Octave core.
Rik <rik@octave.org>
parents:
15750
diff
changeset
|
88 ## @end group |
15625
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
89 ## @end example |
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
90 ## |
18674
7bccc182e2f7
doc: Update pause documentation and add seealso links between related functions.
Rik <rik@octave.org>
parents:
18583
diff
changeset
|
91 ## @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
|
92 ## @end deftypefn |
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
93 |
16512
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
16505
diff
changeset
|
94 function [sel, ok] = listdlg (varargin) |
15625
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
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 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
|
97 print_usage (); |
6ae555fc8c43
Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
16512
diff
changeset
|
98 endif |
6ae555fc8c43
Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
16512
diff
changeset
|
99 |
21637
59ebef9680ef
More cleanup associated with removing Java dialog boxes (cset b5d9b95d1e1a).
Rik <rik@octave.org>
parents:
21630
diff
changeset
|
100 if (mod (nargin, 2) != 0) |
59ebef9680ef
More cleanup associated with removing Java dialog boxes (cset b5d9b95d1e1a).
Rik <rik@octave.org>
parents:
21630
diff
changeset
|
101 error ("listdlg: KEY/VALUE inputs must occur in pairs"); |
59ebef9680ef
More cleanup associated with removing Java dialog boxes (cset b5d9b95d1e1a).
Rik <rik@octave.org>
parents:
21630
diff
changeset
|
102 endif |
59ebef9680ef
More cleanup associated with removing Java dialog boxes (cset b5d9b95d1e1a).
Rik <rik@octave.org>
parents:
21630
diff
changeset
|
103 |
16551
6ae555fc8c43
Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
16512
diff
changeset
|
104 listcell = {""}; |
20363
63736167fb78
Fix listdlg() when used without selection mode under Qt (Bug #45545).
Rik <rik@octave.org>
parents:
20181
diff
changeset
|
105 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
|
106 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
|
107 initialvalue = 1; |
6ae555fc8c43
Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
16512
diff
changeset
|
108 name = ""; |
6ae555fc8c43
Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
16512
diff
changeset
|
109 prompt = {}; |
6ae555fc8c43
Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
16512
diff
changeset
|
110 okstring = "OK"; |
6ae555fc8c43
Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
16512
diff
changeset
|
111 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
|
112 |
16551
6ae555fc8c43
Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
16512
diff
changeset
|
113 ## 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
|
114 for i = 1:2:nargin-1 |
18583
51a0d1c1023c
listdlg.m: return Octave value rather than Java int object.(bug #41931).
Philip Nienhuis <prnienhuis@users.sf.net>
parents:
17744
diff
changeset
|
115 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
|
116 listcell = varargin{i+1}; |
18583
51a0d1c1023c
listdlg.m: return Octave value rather than Java int object.(bug #41931).
Philip Nienhuis <prnienhuis@users.sf.net>
parents:
17744
diff
changeset
|
117 elseif (strcmpi (varargin{i}, "SelectionMode")) |
20081
8bfadb26afcd
Allow case-insensitive SelectionMode value in listdlg (bug #44822).
Rik <rik@octave.org>
parents:
19926
diff
changeset
|
118 selmode = tolower (varargin{i+1}); |
18583
51a0d1c1023c
listdlg.m: return Octave value rather than Java int object.(bug #41931).
Philip Nienhuis <prnienhuis@users.sf.net>
parents:
17744
diff
changeset
|
119 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
|
120 listsize = varargin{i+1}; |
18583
51a0d1c1023c
listdlg.m: return Octave value rather than Java int object.(bug #41931).
Philip Nienhuis <prnienhuis@users.sf.net>
parents:
17744
diff
changeset
|
121 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
|
122 initialvalue = varargin{i+1}; |
18583
51a0d1c1023c
listdlg.m: return Octave value rather than Java int object.(bug #41931).
Philip Nienhuis <prnienhuis@users.sf.net>
parents:
17744
diff
changeset
|
123 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
|
124 name = varargin{i+1}; |
18583
51a0d1c1023c
listdlg.m: return Octave value rather than Java int object.(bug #41931).
Philip Nienhuis <prnienhuis@users.sf.net>
parents:
17744
diff
changeset
|
125 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
|
126 prompt = varargin{i+1}; |
18583
51a0d1c1023c
listdlg.m: return Octave value rather than Java int object.(bug #41931).
Philip Nienhuis <prnienhuis@users.sf.net>
parents:
17744
diff
changeset
|
127 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
|
128 okstring = varargin{i+1}; |
18583
51a0d1c1023c
listdlg.m: return Octave value rather than Java int object.(bug #41931).
Philip Nienhuis <prnienhuis@users.sf.net>
parents:
17744
diff
changeset
|
129 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
|
130 cancelstring = varargin{i+1}; |
21637
59ebef9680ef
More cleanup associated with removing Java dialog boxes (cset b5d9b95d1e1a).
Rik <rik@octave.org>
parents:
21630
diff
changeset
|
131 else |
59ebef9680ef
More cleanup associated with removing Java dialog boxes (cset b5d9b95d1e1a).
Rik <rik@octave.org>
parents:
21630
diff
changeset
|
132 error ("listdlg: invalid KEY <%s>", varargin{i}); |
16551
6ae555fc8c43
Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
16512
diff
changeset
|
133 endif |
6ae555fc8c43
Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
16512
diff
changeset
|
134 endfor |
15625
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
135 |
21637
59ebef9680ef
More cleanup associated with removing Java dialog boxes (cset b5d9b95d1e1a).
Rik <rik@octave.org>
parents:
21630
diff
changeset
|
136 if (isempty (listcell)) |
26014 | 137 error ('listdlg: "ListString" property must not be empty'); |
16551
6ae555fc8c43
Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
16512
diff
changeset
|
138 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
|
139 |
16551
6ae555fc8c43
Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
16512
diff
changeset
|
140 ## 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
|
141 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
|
142 listcell = {listcell}; |
20181
aa36fb998a4d
maint: Remove unnecessary whitespace at end of lines.
Rik <rik@octave.org>
parents:
20173
diff
changeset
|
143 elseif (iscellstr (listcell{1})) |
19926
501cbbaafc56
listdlg.m: Accept cell array with single cellstr entry from menu for Matlab compatibility (bug #44501).
Rik <rik@octave.org>
parents:
19848
diff
changeset
|
144 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
|
145 endif |
6ae555fc8c43
Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
16512
diff
changeset
|
146 |
21637
59ebef9680ef
More cleanup associated with removing Java dialog boxes (cset b5d9b95d1e1a).
Rik <rik@octave.org>
parents:
21630
diff
changeset
|
147 ## make sure prompt strings are a cell array |
59ebef9680ef
More cleanup associated with removing Java dialog boxes (cset b5d9b95d1e1a).
Rik <rik@octave.org>
parents:
21630
diff
changeset
|
148 if (! iscell (prompt)) |
59ebef9680ef
More cleanup associated with removing Java dialog boxes (cset b5d9b95d1e1a).
Rik <rik@octave.org>
parents:
21630
diff
changeset
|
149 prompt = {prompt}; |
59ebef9680ef
More cleanup associated with removing Java dialog boxes (cset b5d9b95d1e1a).
Rik <rik@octave.org>
parents:
21630
diff
changeset
|
150 endif |
59ebef9680ef
More cleanup associated with removing Java dialog boxes (cset b5d9b95d1e1a).
Rik <rik@octave.org>
parents:
21630
diff
changeset
|
151 |
59ebef9680ef
More cleanup associated with removing Java dialog boxes (cset b5d9b95d1e1a).
Rik <rik@octave.org>
parents:
21630
diff
changeset
|
152 ## validate selection mode |
20363
63736167fb78
Fix listdlg() when used without selection mode under Qt (Bug #45545).
Rik <rik@octave.org>
parents:
20181
diff
changeset
|
153 if (! strcmp (selmode, "multiple") && ! strcmp (selmode, "single")) |
26014 | 154 error ('listdlg: "SelectionMode" must be "single" or "multiple"'); |
16551
6ae555fc8c43
Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
16512
diff
changeset
|
155 endif |
6ae555fc8c43
Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
16512
diff
changeset
|
156 |
30195
a7981aa5822b
event-manager: Add function to signal valid implementation of GUI dialogs (bug #60980).
Markus Mützel <markus.muetzel@gmx.de>
parents:
29359
diff
changeset
|
157 if (! __event_manager_have_dialogs__ ()) |
16551
6ae555fc8c43
Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
16512
diff
changeset
|
158 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
|
159 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
|
160 |
27263
99aa1bcb8848
rename octave_link and octave_link_events classes, move inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
161 [sel, ok] = __event_manager_list_dialog__ (listcell, selmode, listsize, |
30195
a7981aa5822b
event-manager: Add function to signal valid implementation of GUI dialogs (bug #60980).
Markus Mützel <markus.muetzel@gmx.de>
parents:
29359
diff
changeset
|
162 initialvalue, name, prompt, |
a7981aa5822b
event-manager: Add function to signal valid implementation of GUI dialogs (bug #60980).
Markus Mützel <markus.muetzel@gmx.de>
parents:
29359
diff
changeset
|
163 okstring, cancelstring); |
26014 | 164 |
15748
54e8c2527a9e
style and doc fixes for newly imported Java package .m files
John W. Eaton <jwe@octave.org>
parents:
15746
diff
changeset
|
165 endfunction |
15772
0f1a143e5002
Overhaul scripts/java directory to conform to Octave core.
Rik <rik@octave.org>
parents:
15750
diff
changeset
|
166 |
16933
e39f00a32dc7
maint: Use parentheses around condition for switch(),while(),if() statements.
Rik <rik@octave.org>
parents:
16551
diff
changeset
|
167 |
16512
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
16505
diff
changeset
|
168 %!demo |
26014 | 169 %! disp ('- test listdlg with "SelectionMode"="single". No caption, no prompt.'); |
170 %! itemlist = {"An item", "another", "yet another"}; | |
18898
310fd62e9d4b
listdlg.m: convert SQ strings to DQ, fix num2str call in %!demos.
Philip Nienhuis <prnienhuis@users.sf.net>
parents:
18674
diff
changeset
|
171 %! 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
|
172 %! imax = numel (s); |
e39f00a32dc7
maint: Use parentheses around condition for switch(),while(),if() statements.
Rik <rik@octave.org>
parents:
16551
diff
changeset
|
173 %! for i=1:1:imax |
26014 | 174 %! disp (["Selection #", num2str(i), ": ", itemlist{s(i)}]); |
22302
1c4cd12987f5
Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents:
21637
diff
changeset
|
175 %! endfor |
16512
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
16505
diff
changeset
|
176 |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
16505
diff
changeset
|
177 %!demo |
26014 | 178 %! disp ('- test listdlg with "SelectionMode"="multiple" and pre-selection. Has caption and two prompt lines.'); |
179 %! itemlist = {"An item", "another", "yet another"}; | |
18898
310fd62e9d4b
listdlg.m: convert SQ strings to DQ, fix num2str call in %!demos.
Philip Nienhuis <prnienhuis@users.sf.net>
parents:
18674
diff
changeset
|
180 %! s = listdlg ("ListString", itemlist, ... |
310fd62e9d4b
listdlg.m: convert SQ strings to DQ, fix num2str call in %!demos.
Philip Nienhuis <prnienhuis@users.sf.net>
parents:
18674
diff
changeset
|
181 %! "SelectionMode", "Multiple", ... |
310fd62e9d4b
listdlg.m: convert SQ strings to DQ, fix num2str call in %!demos.
Philip Nienhuis <prnienhuis@users.sf.net>
parents:
18674
diff
changeset
|
182 %! "Name", "Selection Dialog", ... |
26014 | 183 %! "InitialValue", [1,2,3], |
184 %! "PromptString", {"Select <b>an</b> item...", | |
185 %! "...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 |
26014 | 188 %! disp (["Selection #", num2str(i), ": ", itemlist{s(i)}]); |
22302
1c4cd12987f5
Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents:
21637
diff
changeset
|
189 %! endfor |
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 |
26014 | 192 %! disp ("- test listdlg with ListSize."); |
18898
310fd62e9d4b
listdlg.m: convert SQ strings to DQ, fix num2str call in %!demos.
Philip Nienhuis <prnienhuis@users.sf.net>
parents:
18674
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:
18674
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:
18674
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:
18674
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 |
26014 | 199 %! disp (["Selection #", num2str(i), ": ", itemlist{s(i)}]); |
22302
1c4cd12987f5
Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents:
21637
diff
changeset
|
200 %! endfor |
21637
59ebef9680ef
More cleanup associated with removing Java dialog boxes (cset b5d9b95d1e1a).
Rik <rik@octave.org>
parents:
21630
diff
changeset
|
201 |
59ebef9680ef
More cleanup associated with removing Java dialog boxes (cset b5d9b95d1e1a).
Rik <rik@octave.org>
parents:
21630
diff
changeset
|
202 ## Test input validation |
28896
90fea9cc9caa
test: Add expected error message <Invalid call> to BIST tests for nargin.
Rik <rik@octave.org>
parents:
27923
diff
changeset
|
203 %!error <Invalid call> listdlg () |
90fea9cc9caa
test: Add expected error message <Invalid call> to BIST tests for nargin.
Rik <rik@octave.org>
parents:
27923
diff
changeset
|
204 %!error <Invalid call> listdlg (1) |
21637
59ebef9680ef
More cleanup associated with removing Java dialog boxes (cset b5d9b95d1e1a).
Rik <rik@octave.org>
parents:
21630
diff
changeset
|
205 %!error listdlg ("SelectionMode") |
59ebef9680ef
More cleanup associated with removing Java dialog boxes (cset b5d9b95d1e1a).
Rik <rik@octave.org>
parents:
21630
diff
changeset
|
206 %!error <must occur in pairs> listdlg ("SelectionMode", "multiple", "Name") |
59ebef9680ef
More cleanup associated with removing Java dialog boxes (cset b5d9b95d1e1a).
Rik <rik@octave.org>
parents:
21630
diff
changeset
|
207 %!error <invalid KEY .FooBar.> listdlg ("FooBar", 1) |
26014 | 208 %!error <"ListString" property must not be empty> listdlg ("ListString", {}) |
209 %!error <"SelectionMode" must be "single" or "multiple"> | |
21637
59ebef9680ef
More cleanup associated with removing Java dialog boxes (cset b5d9b95d1e1a).
Rik <rik@octave.org>
parents:
21630
diff
changeset
|
210 %! listdlg ("ListString", {"A"}, "SelectionMode", "foobar"); |