comparison scripts/ui/msgbox.m @ 16505:ff061068a66c

move dialog files to separate directory * scripts/ui/errordlg.m, scripts/ui/helpdlg.m, scripts/ui/inputdlg.m, scripts/ui/listdlg.m, scripts/ui/msgbox.m, scripts/ui/questdlg.m, scripts/ui/warndlg.m: Move here from scripts/java. * scripts/java/module.mk (java_FCN_FILES): Update list. * scripts/ui/module.mk: New file. * scripts/Makefile.am: Include it. (ui/PKG_ADD, $(ui_GEN_FCN_FILES), ui/$(octave_dirstamp)): New targets.
author John W. Eaton <jwe@octave.org>
date Fri, 12 Apr 2013 14:51:51 -0400
parents scripts/java/msgbox.m@801297f14e4b
children f19e24c97b20
comparison
equal deleted inserted replaced
16504:49b059bf27c7 16505:ff061068a66c
1 ## Copyright (C) 2010 Martin Hepperle
2 ##
3 ## This file is part of Octave.
4 ##
5 ## Octave is free software; you can redistribute it and/or modify it
6 ## under the terms of the GNU General Public License as published by
7 ## the Free Software Foundation; either version 3 of the License, or (at
8 ## your option) any later version.
9 ##
10 ## Octave is distributed in the hope that it will be useful, but
11 ## WITHOUT ANY WARRANTY; without even the implied warranty of
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 ## General Public License for more details.
14 ##
15 ## You should have received a copy of the GNU General Public License
16 ## along with Octave; see the file COPYING. If not, see
17 ## <http://www.gnu.org/licenses/>.
18
19 ## -*- texinfo -*-
20 ## @deftypefn {Function File} {@var{h} =} msgbox (@var{msg})
21 ## @deftypefnx {Function File} {@var{h} =} msgbox (@var{msg}, @var{title})
22 ## @deftypefnx {Function File} {@var{h} =} msgbox (@var{msg}, @var{title}, @var{icon})
23 ## Display @var{msg} using a message dialog box.
24 ##
25 ## The message may have multiple lines separated by newline characters
26 ## (@code{"\n"}), or it may be a cellstr array with one element for each
27 ## line. The optional input @var{title} (character string) can be used to
28 ## decorate the dialog caption.
29 ##
30 ## The optional argument @var{icon} selects a dialog icon.
31 ## It can be one of @code{"none"} (default), @code{"error"}, @code{"help"}, or
32 ## @code{"warn"}.
33 ##
34 ## The return value is always 1.
35 ## @seealso{errordlg, helpdlg, inputdlg, listdlg, questdlg, warndlg}
36 ## @end deftypefn
37
38 function h = msgbox (msg, title = "", icon)
39
40 if (nargin < 1 || nargin > 3)
41 print_usage ();
42 endif
43
44 if (! ischar (msg))
45 if (iscell (msg))
46 msg = sprintf ("%s\n", msg{:});
47 msg(end) = "";
48 else
49 error ("msgbox: MSG must be a character string or cellstr array");
50 endif
51 endif
52
53 if (! ischar (title))
54 error ("msgbox: TITLE must be a character string");
55 endif
56
57 dlg = "emptydlg";
58 if (nargin == 3)
59 switch (icon)
60 case "error"
61 dlg = "errordlg";
62 case "help"
63 dlg = "helpdlg";
64 case "warn"
65 dlg = "warndlg";
66 case "none"
67 dlg = "emptydlg";
68 otherwise
69 error ("msgbox: ICON is not a valid type");
70 endswitch
71 endif
72
73 h = javaMethod (dlg, "org.octave.JDialogBox", msg, title);
74
75 endfunction
76