comparison scripts/ui/listdlg.m @ 16512:7f2395651a1c

dialog boxes with Qt widgets * dialog.h, dialog.cc: New files. * libgui/src/module.mk: Update file lists. * main-window.h, main-window.ccmain_window::connect_uiwidget_links, main_window::handle_create_dialog, main_window::handle_create_listview, main_window::handle_create_inputlayout): New functions. (main_window::construct): Call connect_uiwidget_links. * octave-link.h, octave-link.cc (octave_link::message_dialog, octave_link::do_message_dialog, octave_link::list_dialog, octave_link::do_list_dialog, octave_link::input_dialog, octave_link::do_input_dialog): New functions. * octave-qt-link.h, octave-qt-link.cc (octave_qt_link::message_dialog, octave_qt_link::do_message_dialog, octave_qt_link::list_dialog, octave_qt_link::do_list_dialog, octave_qt_link::input_dialog, octave_qt_link::do_input_dialog, make_qstring_list): New functions. * octave-link.cc (F__octave_link_edit_file__): Call flush_octave_stdout before running the edit file action. (F__octave_link_message_dialog__, F__octave_link_list_dialog__, __octave_link_input_dialog__): New functions. * errordlg.m, helpdlg.m, inputdlg.m, listdlg.m, msgbox.m, warndlg.m: New demos adapted from dlgtest.m * dlgtest.m: Delete. * scripts/java/module.mk: Remove it from the list of files. * inputdlg.m: Try __octave_link_input_dialog__ first. Only try java method if JAVA feature is available. * listdlg.m: Likwise, for __octave_link_list_dialog__. * private/message_dialog.m: Likewise, for __octave_link_message_dialog__.
author Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
date Sat, 13 Apr 2013 15:22:34 -0400
parents ff061068a66c
children 6ae555fc8c43
comparison
equal deleted inserted replaced
16511:eee1b78d031f 16512:7f2395651a1c
75 ## @end example 75 ## @end example
76 ## 76 ##
77 ## @seealso{errordlg, helpdlg, inputdlg, msgbox, questdlg, warndlg} 77 ## @seealso{errordlg, helpdlg, inputdlg, msgbox, questdlg, warndlg}
78 ## @end deftypefn 78 ## @end deftypefn
79 79
80 function varargout = listdlg (varargin) 80 function [sel, ok] = listdlg (varargin)
81 81
82 if (nargin < 2) 82 if (nargin < 2)
83 print_usage (); 83 print_usage ();
84 endif 84 endif
85 85
120 120
121 ## make sure listcell strings are a cell array 121 ## make sure listcell strings are a cell array
122 if (! iscell (listcell)) 122 if (! iscell (listcell))
123 listcell = {listcell}; 123 listcell = {listcell};
124 endif 124 endif
125
126 ## transform matrices to cell arrays of strings
127 ## swap width and height to correct calling format for JDialogBox
128 listsize = {num2str(listsize(2)), num2str(listsize(1))};
129 initialvalue = arrayfun (@num2str, initialvalue, "UniformOutput", false);
130
131 ret = javaMethod ("listdlg", "org.octave.JDialogBox", listcell,
132 selmode, listsize, initialvalue, name, prompt,
133 okstring, cancelstring);
134 125
135 if (numel (ret) > 0) 126 [sel, ok] = __octave_link_list_dialog__ (listcell, selmode, listsize,
136 varargout = {ret, 1}; 127 initialvalue, name, prompt,
137 else 128 okstring, cancelstring);
138 varargout = {{}, 0}; 129 if (ok > 0)
130 return;
139 endif 131 endif
132
133 if (__have_feature__ ("JAVA"))
134 ## transform matrices to cell arrays of strings
135 ## swap width and height to correct calling format for JDialogBox
136 listsize = {num2str(listsize(2)), num2str(listsize(1))};
137 initialvalue = arrayfun (@num2str, initialvalue, "UniformOutput", false);
138
139 ret = javaMethod ("listdlg", "org.octave.JDialogBox", listcell,
140 selmode, listsize, initialvalue, name, prompt,
141 okstring, cancelstring);
142
143 if (numel (ret) > 0)
144 sel = ret;
145 ok = 1;
146 else
147 sel = {};
148 ok = 0;
149 endif
150
151 return;
152
153 endif
154
155 ## FIXME -- provide terminal-based implementation here?
156
157 error ("listdlg is not available in this version of Octave");
140 158
141 endfunction 159 endfunction
142 160
161 %!demo
162 %! disp('- test listdlg with selectionmode single. No caption, no prompt.');
163 %! itemlist = {'An item \\alpha', 'another', 'yet another'};
164 %! s = listdlg ( 'ListString',itemlist, 'SelectionMode','Single' );
165 %! imax = numel (s);
166 %! for i=1:1:imax
167 %! disp(['Selected: ',num2str(i),': ', itemlist{s(i)}]);
168 %! end
169
170 %!demo
171 %! disp('- test listdlg with selectionmode and preselection. Has caption and two lines prompt.');
172 %! itemlist = {'An item \\alpha', 'another', 'yet another'};
173 %! s = listdlg ( 'ListString',itemlist, ...
174 %! 'SelectionMode','Multiple', ...
175 %! 'Name','Selection Dialog', ...
176 %! 'InitialValue',[1,2,3,4],
177 %! 'PromptString',{'Select an item...', '...or multiple items'} );
178 %! imax = numel (s);
179 %! for i=1:1:imax
180 %! disp(['Selected: ',num2str(i),': ', itemlist{s(i)}]);
181 %! end