Mercurial > hg > octave-lyh
diff scripts/ui/msgbox.m @ 16508:f19e24c97b20
move common warndlg, errordlg, helpdlg, and msgbox code to private function
* message_dialog.m: New file.
* scripts/ui/module.mk: Include it in the list of functions.
* errordlg.m, helpdlg.m, warndlg.m, msgbox.m: Call message_dialog to
do most of the work.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Fri, 12 Apr 2013 18:17:26 -0400 |
parents | ff061068a66c |
children | 7f2395651a1c |
line wrap: on
line diff
--- a/scripts/ui/msgbox.m +++ b/scripts/ui/msgbox.m @@ -35,42 +35,13 @@ ## @seealso{errordlg, helpdlg, inputdlg, listdlg, questdlg, warndlg} ## @end deftypefn -function h = msgbox (msg, title = "", icon) +function retval = msgbox (msg, title = "", varargin) if (nargin < 1 || nargin > 3) print_usage (); endif - if (! ischar (msg)) - if (iscell (msg)) - msg = sprintf ("%s\n", msg{:}); - msg(end) = ""; - else - error ("msgbox: MSG must be a character string or cellstr array"); - endif - endif - - if (! ischar (title)) - error ("msgbox: TITLE must be a character string"); - endif - - dlg = "emptydlg"; - if (nargin == 3) - switch (icon) - case "error" - dlg = "errordlg"; - case "help" - dlg = "helpdlg"; - case "warn" - dlg = "warndlg"; - case "none" - dlg = "emptydlg"; - otherwise - error ("msgbox: ICON is not a valid type"); - endswitch - endif - - h = javaMethod (dlg, "org.octave.JDialogBox", msg, title); + retval = message_dialog ("msgbox", msg, title, varargin{:}); endfunction