1########################################################################
2##
3## Copyright (C) 2010-2021 The Octave Project Developers
4##
5## See the file COPYRIGHT.md in the top-level directory of this
6## distribution or <https://octave.org/copyright/>.
7##
8## This file is part of Octave.
9##
10## Octave is free software: you can redistribute it and/or modify it
11## under the terms of the GNU General Public License as published by
12## the Free Software Foundation, either version 3 of the License, or
13## (at your option) any later version.
14##
15## Octave is distributed in the hope that it will be useful, but
16## WITHOUT ANY WARRANTY; without even the implied warranty of
17## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18## GNU General Public License for more details.
19##
20## You should have received a copy of the GNU General Public License
21## along with Octave; see the file COPYING.  If not, see
22## <https://www.gnu.org/licenses/>.
23##
24########################################################################
25
26## -*- texinfo -*-
27## @deftypefn  {} {} warndlg ()
28## @deftypefnx {} {} warndlg (@var{msg})
29## @deftypefnx {} {} warndlg (@var{msg}, @var{title})
30## @deftypefnx {} {} warndlg (@var{msg}, @var{title}, @var{opt})
31## @deftypefnx {} {@var{h} =} warndlg (@dots{})
32## Display a warning dialog box with warning message @var{msg} and caption
33## @var{title}.
34##
35## The default warning message is
36## @qcode{"This is the default warning string.@:"} and the default caption is
37## @qcode{"Warning Dialog"}.
38##
39## The warning message may have multiple lines separated by newline characters
40## ("\n"), or it may be a cellstr array with one element for each line.
41##
42## The third optional argument @var{opt} controls the behavior of the dialog.
43## See @code{msgbox} for details.
44##
45## The return value @var{h} is a handle to the figure object used for
46## building the dialog.
47##
48## Examples:
49##
50## @example
51## @group
52## warndlg ("Some warning text for the user.");
53## warndlg ("Some warning text\nwith two lines.");
54## warndlg (@{"Some warning text", "with two lines."@});
55## warndlg ("Some warning text for the user.", "Fancy caption");
56## @end group
57## @end example
58##
59## @seealso{errordlg, helpdlg, msgbox, inputdlg, listdlg, questdlg}
60## @end deftypefn
61
62function h = warndlg (varargin)
63
64  msg = "This is the default warning.";
65  tit = "Warning Dialog";
66  opt = "non-modal";
67
68  nargs = numel (varargin);
69
70  if (nargs > 3)
71    print_usage ();
72  elseif (nargs == 1)
73    msg = varargin{1};
74  elseif (nargs == 2)
75    msg = varargin{1};
76    tit = varargin{2};
77  elseif (nargs == 3)
78    msg = varargin{1};
79    tit = varargin{2};
80    opt = varargin{3};
81  endif
82
83  htmp = msgbox (msg, tit, "warn", opt);
84
85  if (nargout)
86    h = htmp;
87  endif
88
89endfunction
90
91## No BIST tests.  This function just dispatches to msgbox().
92%!assert (1)
93