comparison scripts/java/msgbox.m @ 15709:9fee0b741de6

Update Java dialog scrips to latest octave-forge status * dlgtest.m: strip away all code for reinstalling Java package * cell2mlstr.m: new function * helpdlg.m, errordlg.m, inputdlg.m, listdlg.m, questdlg.m, warndlg.m, msgbox.m: Allow cellstr arrays as first argument (ML compatibilility)
author Philip Nienhuis <prnienhuis@users.sf.net>
date Sat, 01 Dec 2012 18:10:55 +0100
parents acf0addfc610
children da26f72408a7
comparison
equal deleted inserted replaced
15708:916ef285522a 15709:9fee0b741de6
15 15
16 ## -*- texinfo -*- 16 ## -*- texinfo -*-
17 ## @deftypefn {Function file} {@var{P} =} msgbox (@var{MESSAGE} [,@var{TITLE} [,@var{ICON}]]) 17 ## @deftypefn {Function file} {@var{P} =} msgbox (@var{MESSAGE} [,@var{TITLE} [,@var{ICON}]])
18 ## 18 ##
19 ## Displays the @var{MESSAGE} using a message dialog. 19 ## Displays the @var{MESSAGE} using a message dialog.
20 ## The @var{TITLE} is an optional string, which can be used to decorate the dialog caption. 20 ##
21 ## @var{message} can have multiple lines separated by newline characters
22 ## ("\n"), or it can be a cellstr array (one element for each line).
23 ## The optional @var{TITLE} (character string) can be used to decorate the
24 ## dialog caption.
21 ## The @var{ICON} can be used optionally to select a dialog icon. 25 ## The @var{ICON} can be used optionally to select a dialog icon.
22 ## It can be one of @code{'error'}, @code{'help'} or @code{'warn'}. 26 ## It can be one of @code{'error'}, @code{'help'} or @code{'warn'}.
23 ## The return value is always 1. 27 ## The return value is always 1.
24 ## 28 ##
25 ## @end deftypefn 29 ## @end deftypefn
26 ## @seealso{helpdlg, questdlg, warndlg} 30 ## @seealso{helpdlg, questdlg, warndlg}
27 31
28 function ret = msgbox(message,varargin) 32 function ret = msgbox (message, varargin)
33
34 if (! ischar (message))
35 if (iscell (message))
36 message = cell2mlstr (message);
37 else
38 error ("msgbox: character string or cellstr array expected for message");
39 endif
40 endif
29 41
30 switch length (varargin) 42 switch length (varargin)
31 case 0 43 case 0
32 title = ""; 44 title = "";
33 dlg = 'emptydlg';
34 case 1
35 title = varargin{1};
36 dlg = 'emptydlg';
37 otherwise
38 % two or more arguments
39 title = varargin{1};
40 icon = varargin{2};
41 if strcmp(icon,'error') == 1
42 dlg = 'errordlg';
43 elseif strcmp(icon,'help') == 1
44 dlg = 'helpdlg';
45 elseif strcmp(icon,'warn') == 1
46 dlg = 'warndlg';
47 else
48 dlg = 'emptydlg'; 45 dlg = 'emptydlg';
49 end 46 case 1
47 title = varargin{1};
48 dlg = 'emptydlg';
49 otherwise
50 % two or more arguments
51 title = varargin{1};
52 icon = varargin{2};
53 if strcmp (icon,'error') == 1
54 dlg = 'errordlg';
55 elseif strcmp (icon,'help') == 1
56 dlg = 'helpdlg';
57 elseif strcmp (icon,'warn') == 1
58 dlg = 'warndlg';
59 else
60 dlg = 'emptydlg';
61 end
50 endswitch 62 endswitch
63
64 if (! ischar (title))
65 error ("msgbox: character string expected for title");
66 endif
51 67
52 ret = java_invoke ('org.octave.JDialogBox', dlg, message, title ); 68 ret = java_invoke ('org.octave.JDialogBox', dlg, message, title );
53 69
54 endfunction 70 endfunction