annotate scripts/ui/listdlg.m @ 16551:6ae555fc8c43

Add questdlg dialog function and fix variety of dialog bugs. * octave-qt-link.cc (octave_qt_link::do_message_dialog): Change initializer from QString to QString::fromStdString(dlg). (octave_qt_link::do_question_dialog): New function. Make all buttons AcceptRole. Signal dialog creation. Go to wait state. Get dialog button result when awakened. (octave_qt_link::do_list_dialog): Change std string 'prompt_string' to std list of std string 'prompt'. Use make_qstring_list(prompt). (octave_qt_link::do_input_dialog): Change 'nr' and 'nc' to std list of float. Use QFloatList::fromStdList(nc). * octave-qt-link.h (octave_qt_link : QObject, public octave_link): Add member do_question_dialog. (octave_qt_link::do_list_dialog): Use std list of std string for prompt. (octave_qt_link::do_input_dialog): Change 'nr' and 'nc' to std list of float. * octave-link.cc (__octave_link_question_dialog__): New builtin. Translate args to inputs of octave_link::question_dialog function. (__octave_link_list_dialog__): Retain prompt string cell list as a std list of std string. (__octave_link_input_dialog__): Make 'nr' and 'nc' std list of float. * octave-link.h (octave_link::question_dialog, octave_link::do_question_dialog): Add. (octave_link::list_dialog, octave_link::do_list_dialog): Change prompt to std list of std string. (octave_link::input_dialog, octave_link::do_input_dialog): Change 'nr' and 'nc' to std list of float. * errordlg.m (errordlg): Make retval return variable. Add "error" icon as message_dialog input. * helpdlg.m (helpdlg): Make retval return variable. Add "help" icon as message_dialog input. * warndlg.m (warndlg): Add "warn" icon as message_dialog input. * message_dialog.m (message_dialog): Define default icon "none". Use dlg variable with icon variable as input to __octave_link_message_dialog__. Use __octave_link_enabled__ rather than return value. * inputdlg.m (inputdlg): Round up rowscols to integer. Replace iscell(cstr) with __octave_link_enabled__. * listdlg.m (listdlg): Correct indentation. Change default selmode from "multiple" to "Multiple". Make default prompt {}. Check valid selmode entry. Use __octave_link_enabled__ rather than ok return value. Remove FIXME note. Use Rich Text in prompt of demo. Add demo using ListSize. * questdlg.m (questdlg): Add case 0 to switch. Add error message for default button not matching options. In all cases, check that default button matches an button option. Add __octave_link_question_dialog__ call conditioned under __octave_link_enabled__. Add three demos. * dialog.cc (QUIWidgetCreator::dialog_finished): Remove. (QUIWidgetCreator::dialog_button_clicked): Test that button pointer is nonzero. Move dialog_result assignment and waitcondition.wakeAll here. (MessageDialog::MessageDialog): If title "", change to " ". Reverse order that buttons are installed. Remove signal 'finished' connection. (ListDialog::ListDialog): Change prompt from QString to QStringList. Make list items noneditable. Add Rich Text support to prompt, place RT <br> between prompt list lines. Use label for prompt. Disable select_all button if not "Multiple". Remove horizontal group box. If title "", change to " ". (InputDialog::InputDialog): Change 'nr' and 'nc' to QFloatList. Define pre-processor variables, then undefine. If title "", change to " ". * dialog.h (QUIWidgetCreator::signal_listviewQUI, WidgetCreator::create_listview): Change QString 'prompt_string' to QStringList 'prompt'. (QUIWidgetCreator::signal_inputlayout, QUIWidgetCreator::create_inputlayout): Use QFloatList for 'nr' and 'nc'. (QUIWidgetCreator::dialog_finished): Remove. (MessageDialog::closeEvent): New override, emitting buttonClicked(0). (ListDialog::ListDialog): Change QString 'prompt_string' to QStringList 'prompt'. (InputDialog::InputDialog): Use QFloatList for 'nr' and 'nc'. * main_window.cc, main_window.h: Make function call changes that match dialog.h changes. (main_window::find_files_finished): Remove unused 'button' variable.
author Daniel J Sebald <daniel.sebald@ieee.org>
date Mon, 22 Apr 2013 15:07:13 -0400
parents 7f2395651a1c
children e39f00a32dc7
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1 ## Copyright (C) 2010 Martin Hepperle
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{})
15748
54e8c2527a9e style and doc fixes for newly imported Java package .m files
John W. Eaton <jwe@octave.org>
parents: 15746
diff changeset
21 ## Return user inputs from a list dialog box in a vector of
54e8c2527a9e style and doc fixes for newly imported Java package .m files
John W. Eaton <jwe@octave.org>
parents: 15746
diff changeset
22 ## selection indices @var{sel} and a flag @var{ok} indicating how the
54e8c2527a9e style and doc fixes for newly imported Java package .m files
John W. Eaton <jwe@octave.org>
parents: 15746
diff changeset
23 ## user closed the dialog box. The value of @var{ok} is 1 if the user
54e8c2527a9e style and doc fixes for newly imported Java package .m files
John W. Eaton <jwe@octave.org>
parents: 15746
diff changeset
24 ## closed the box with the OK button, otherwise it is 0 and @var{sel} is
54e8c2527a9e style and doc fixes for newly imported Java package .m files
John W. Eaton <jwe@octave.org>
parents: 15746
diff changeset
25 ## empty.
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
26 ##
16392
801297f14e4b doc: Improve documentation for Java chapter and java functions.
Rik <rik@octave.org>
parents: 15806
diff changeset
27 ## 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
28 ##
15748
54e8c2527a9e style and doc fixes for newly imported Java package .m files
John W. Eaton <jwe@octave.org>
parents: 15746
diff changeset
29 ## The arguments are specified in form of @var{key}, @var{value} pairs.
16392
801297f14e4b doc: Improve documentation for Java chapter and java functions.
Rik <rik@octave.org>
parents: 15806
diff changeset
30 ## The "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
31 ##
15748
54e8c2527a9e style and doc fixes for newly imported Java package .m files
John W. Eaton <jwe@octave.org>
parents: 15746
diff changeset
32 ## 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
33 ##
16392
801297f14e4b doc: Improve documentation for Java chapter and java functions.
Rik <rik@octave.org>
parents: 15806
diff changeset
34 ## @table @asis
15748
54e8c2527a9e style and doc fixes for newly imported Java package .m files
John W. Eaton <jwe@octave.org>
parents: 15746
diff changeset
35 ## @item "ListString"
16392
801297f14e4b doc: Improve documentation for Java chapter and java functions.
Rik <rik@octave.org>
parents: 15806
diff changeset
36 ## 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
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 "SelectionMode"
16392
801297f14e4b doc: Improve documentation for Java chapter and java functions.
Rik <rik@octave.org>
parents: 15806
diff changeset
39 ## can be either "Single" or "Multiple" (default).
15772
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 ## @item "ListSize"
16392
801297f14e4b doc: Improve documentation for Java chapter and java functions.
Rik <rik@octave.org>
parents: 15806
diff changeset
42 ## a vector with two elements @var{width} and @var{height} defining
801297f14e4b doc: Improve documentation for Java chapter and java functions.
Rik <rik@octave.org>
parents: 15806
diff changeset
43 ## the size 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
44 ##
15748
54e8c2527a9e style and doc fixes for newly imported Java package .m files
John W. Eaton <jwe@octave.org>
parents: 15746
diff changeset
45 ## @item "InitialValue"
16392
801297f14e4b doc: Improve documentation for Java chapter and java functions.
Rik <rik@octave.org>
parents: 15806
diff changeset
46 ## a vector containing 1-based indices of preselected elements. Default
801297f14e4b doc: Improve documentation for Java chapter and java functions.
Rik <rik@octave.org>
parents: 15806
diff changeset
47 ## is 1 (first item).
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 "Name"
16392
801297f14e4b doc: Improve documentation for Java chapter and java functions.
Rik <rik@octave.org>
parents: 15806
diff changeset
50 ## 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
51 ##
15748
54e8c2527a9e style and doc fixes for newly imported Java package .m files
John W. Eaton <jwe@octave.org>
parents: 15746
diff changeset
52 ## @item "PromptString"
16392
801297f14e4b doc: Improve documentation for Java chapter and java functions.
Rik <rik@octave.org>
parents: 15806
diff changeset
53 ## a cell array of strings to be displayed above the list field. Default
801297f14e4b doc: Improve documentation for Java chapter and java functions.
Rik <rik@octave.org>
parents: 15806
diff changeset
54 ## is @{@}.
15772
0f1a143e5002 Overhaul scripts/java directory to conform to Octave core.
Rik <rik@octave.org>
parents: 15750
diff changeset
55 ##
15748
54e8c2527a9e style and doc fixes for newly imported Java package .m files
John W. Eaton <jwe@octave.org>
parents: 15746
diff changeset
56 ## @item "OKString"
16392
801297f14e4b doc: Improve documentation for Java chapter and java functions.
Rik <rik@octave.org>
parents: 15806
diff changeset
57 ## a string used to label the OK button. Default is "OK".
15772
0f1a143e5002 Overhaul scripts/java directory to conform to Octave core.
Rik <rik@octave.org>
parents: 15750
diff changeset
58 ##
15748
54e8c2527a9e style and doc fixes for newly imported Java package .m files
John W. Eaton <jwe@octave.org>
parents: 15746
diff changeset
59 ## @item "CancelString"
16392
801297f14e4b doc: Improve documentation for Java chapter and java functions.
Rik <rik@octave.org>
parents: 15806
diff changeset
60 ## a string used to label the Cancel button. Default is "Cancel".
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
61 ## @end table
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
62 ##
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
63 ## Example:
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
64 ##
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
65 ## @example
15772
0f1a143e5002 Overhaul scripts/java directory to conform to Octave core.
Rik <rik@octave.org>
parents: 15750
diff changeset
66 ## @group
15806
01d4f742d75d doc: Re-organize and improve Java Interface documentation.
Rik <rik@octave.org>
parents: 15790
diff changeset
67 ## [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
68 ## "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
69 ## if (ok == 1)
15806
01d4f742d75d doc: Re-organize and improve Java Interface documentation.
Rik <rik@octave.org>
parents: 15790
diff changeset
70 ## 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
71 ## disp (sel(i));
15772
0f1a143e5002 Overhaul scripts/java directory to conform to Octave core.
Rik <rik@octave.org>
parents: 15750
diff changeset
72 ## endfor
0f1a143e5002 Overhaul scripts/java directory to conform to Octave core.
Rik <rik@octave.org>
parents: 15750
diff changeset
73 ## endif
0f1a143e5002 Overhaul scripts/java directory to conform to Octave core.
Rik <rik@octave.org>
parents: 15750
diff changeset
74 ## @end group
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
75 ## @end example
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
76 ##
15772
0f1a143e5002 Overhaul scripts/java directory to conform to Octave core.
Rik <rik@octave.org>
parents: 15750
diff changeset
77 ## @seealso{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
78 ## @end deftypefn
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
79
16512
7f2395651a1c dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents: 16505
diff changeset
80 function [sel, ok] = listdlg (varargin)
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
81
16551
6ae555fc8c43 Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 16512
diff changeset
82 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
83 print_usage ();
6ae555fc8c43 Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 16512
diff changeset
84 endif
6ae555fc8c43 Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 16512
diff changeset
85
6ae555fc8c43 Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 16512
diff changeset
86 listcell = {""};
6ae555fc8c43 Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 16512
diff changeset
87 selmode = "Multiple";
6ae555fc8c43 Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 16512
diff changeset
88 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
89 initialvalue = 1;
6ae555fc8c43 Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 16512
diff changeset
90 name = "";
6ae555fc8c43 Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 16512
diff changeset
91 prompt = {};
6ae555fc8c43 Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 16512
diff changeset
92 okstring = "OK";
6ae555fc8c43 Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 16512
diff changeset
93 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
94
16551
6ae555fc8c43 Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 16512
diff changeset
95 ## 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
96 for i = 1:2:nargin-1
6ae555fc8c43 Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 16512
diff changeset
97 if strcmp (varargin{i}, "ListString")
6ae555fc8c43 Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 16512
diff changeset
98 listcell = 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
99 elseif strcmp (varargin{i}, "SelectionMode")
6ae555fc8c43 Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 16512
diff changeset
100 selmode = 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
101 elseif strcmp (varargin{i}, "ListSize")
6ae555fc8c43 Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 16512
diff changeset
102 listsize = 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
103 elseif strcmp (varargin{i}, "InitialValue")
6ae555fc8c43 Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 16512
diff changeset
104 initialvalue = 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
105 elseif strcmp (varargin{i}, "Name")
6ae555fc8c43 Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 16512
diff changeset
106 name = 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
107 elseif strcmp (varargin{i}, "PromptString")
6ae555fc8c43 Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 16512
diff changeset
108 prompt = 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
109 elseif strcmp (varargin{i}, "OKString")
6ae555fc8c43 Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 16512
diff changeset
110 okstring = 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
111 elseif strcmp (varargin{i}, "CancelString")
6ae555fc8c43 Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 16512
diff changeset
112 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
113 endif
6ae555fc8c43 Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 16512
diff changeset
114 endfor
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
115
16551
6ae555fc8c43 Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 16512
diff changeset
116 ## 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
117 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
118 prompt = {prompt};
6ae555fc8c43 Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 16512
diff changeset
119 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
120
16551
6ae555fc8c43 Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 16512
diff changeset
121 ## 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
122 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
123 listcell = {listcell};
6ae555fc8c43 Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 16512
diff changeset
124 endif
6ae555fc8c43 Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 16512
diff changeset
125
6ae555fc8c43 Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 16512
diff changeset
126 ## make sure valid selection mode
6ae555fc8c43 Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 16512
diff changeset
127 if (! strcmp (selmode, "Multiple") && ! strcmp (selmode, "Single"))
6ae555fc8c43 Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 16512
diff changeset
128 error ("invalid SelectionMode");
6ae555fc8c43 Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 16512
diff changeset
129 endif
6ae555fc8c43 Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 16512
diff changeset
130
6ae555fc8c43 Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 16512
diff changeset
131 if (__octave_link_enabled__ ())
6ae555fc8c43 Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 16512
diff changeset
132 [sel, ok] = __octave_link_list_dialog__ (listcell, selmode, listsize,
16512
7f2395651a1c dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents: 16505
diff changeset
133 initialvalue, name, prompt,
7f2395651a1c dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents: 16505
diff changeset
134 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
135 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
136 ## 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
137 ## 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
138 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
139 initialvalue = arrayfun (@num2str, initialvalue, "UniformOutput", false);
6ae555fc8c43 Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 16512
diff changeset
140 if isempty(prompt)
6ae555fc8c43 Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 16512
diff changeset
141 prompt = {""};
6ae555fc8c43 Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 16512
diff changeset
142 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
143
16551
6ae555fc8c43 Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 16512
diff changeset
144 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
145 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
146 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
147
16551
6ae555fc8c43 Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 16512
diff changeset
148 if (numel (ret) > 0)
6ae555fc8c43 Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 16512
diff changeset
149 sel = ret;
6ae555fc8c43 Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 16512
diff changeset
150 ok = 1;
6ae555fc8c43 Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 16512
diff changeset
151 else
6ae555fc8c43 Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 16512
diff changeset
152 sel = {};
6ae555fc8c43 Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 16512
diff changeset
153 ok = 0;
6ae555fc8c43 Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 16512
diff changeset
154 endif
6ae555fc8c43 Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 16512
diff changeset
155 else
6ae555fc8c43 Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 16512
diff changeset
156 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
157 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
158
15748
54e8c2527a9e style and doc fixes for newly imported Java package .m files
John W. Eaton <jwe@octave.org>
parents: 15746
diff changeset
159 endfunction
15772
0f1a143e5002 Overhaul scripts/java directory to conform to Octave core.
Rik <rik@octave.org>
parents: 15750
diff changeset
160
16512
7f2395651a1c dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents: 16505
diff changeset
161 %!demo
7f2395651a1c dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents: 16505
diff changeset
162 %! disp('- test listdlg with selectionmode single. No caption, no prompt.');
7f2395651a1c dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents: 16505
diff changeset
163 %! itemlist = {'An item \\alpha', 'another', 'yet another'};
7f2395651a1c dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents: 16505
diff changeset
164 %! s = listdlg ( 'ListString',itemlist, 'SelectionMode','Single' );
7f2395651a1c dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents: 16505
diff changeset
165 %! imax = numel (s);
7f2395651a1c dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents: 16505
diff changeset
166 %! for i=1:1:imax
7f2395651a1c dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents: 16505
diff changeset
167 %! disp(['Selected: ',num2str(i),': ', itemlist{s(i)}]);
7f2395651a1c dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents: 16505
diff changeset
168 %! end
7f2395651a1c dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents: 16505
diff changeset
169
7f2395651a1c dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents: 16505
diff changeset
170 %!demo
7f2395651a1c dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents: 16505
diff changeset
171 %! disp('- test listdlg with selectionmode and preselection. Has caption and two lines prompt.');
7f2395651a1c dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents: 16505
diff changeset
172 %! itemlist = {'An item \\alpha', 'another', 'yet another'};
7f2395651a1c dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents: 16505
diff changeset
173 %! s = listdlg ( 'ListString',itemlist, ...
7f2395651a1c dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents: 16505
diff changeset
174 %! 'SelectionMode','Multiple', ...
7f2395651a1c dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents: 16505
diff changeset
175 %! 'Name','Selection Dialog', ...
7f2395651a1c dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents: 16505
diff changeset
176 %! 'InitialValue',[1,2,3,4],
16551
6ae555fc8c43 Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 16512
diff changeset
177 %! 'PromptString',{'Select <b>an</b> item...', '...or <b>multiple</b> items'} );
16512
7f2395651a1c dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents: 16505
diff changeset
178 %! imax = numel (s);
7f2395651a1c dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents: 16505
diff changeset
179 %! for i=1:1:imax
7f2395651a1c dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents: 16505
diff changeset
180 %! disp(['Selected: ',num2str(i),': ', itemlist{s(i)}]);
7f2395651a1c dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents: 16505
diff changeset
181 %! end
16551
6ae555fc8c43 Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 16512
diff changeset
182
6ae555fc8c43 Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 16512
diff changeset
183 %!demo
6ae555fc8c43 Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 16512
diff changeset
184 %! disp('- test listdlg with listsize.');
6ae555fc8c43 Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 16512
diff changeset
185 %! itemlist = {"Neutron","Electron","Quark","Proton","Neutrino"};
6ae555fc8c43 Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 16512
diff changeset
186 %! s = listdlg ( "ListString",itemlist,
6ae555fc8c43 Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 16512
diff changeset
187 %! "Name","Bits and Pieces",
6ae555fc8c43 Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 16512
diff changeset
188 %! "ListSize",[200 75] );
6ae555fc8c43 Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 16512
diff changeset
189 %! imax = numel (s);
6ae555fc8c43 Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 16512
diff changeset
190 %! for i=1:1:imax
6ae555fc8c43 Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 16512
diff changeset
191 %! disp(['Selected: ',num2str(i),': ', itemlist{s(i)}]);
6ae555fc8c43 Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 16512
diff changeset
192 %! end