Mercurial > hg > octave-nkf
comparison scripts/ui/private/message_dialog.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 | |
children | 7f2395651a1c |
comparison
equal
deleted
inserted
replaced
16507:8cb12cf9ca32 | 16508:f19e24c97b20 |
---|---|
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} =} message_dialog (@var{caller}, @var{msg}, @var{title}, @var{icon}) | |
21 ## Undocumented internal function. | |
22 ## @end deftypefn | |
23 | |
24 function retval = message_dialog (caller, msg, title = "", icon) | |
25 | |
26 if (! ischar (msg)) | |
27 if (iscell (msg)) | |
28 msg = sprintf ("%s\n", msg{:}); | |
29 msg(end) = ""; | |
30 else | |
31 error ("%s: MSG must be a character string or cellstr array", caller); | |
32 endif | |
33 endif | |
34 | |
35 if (! ischar (title)) | |
36 error ("%s: TITLE must be a character string", caller); | |
37 endif | |
38 | |
39 dlg = "emptydlg"; | |
40 if (nargin == 4) | |
41 switch (icon) | |
42 case "error" | |
43 dlg = "errordlg"; | |
44 case "help" | |
45 dlg = "helpdlg"; | |
46 case "warn" | |
47 dlg = "warndlg"; | |
48 case "none" | |
49 dlg = "emptydlg"; | |
50 otherwise | |
51 error ("%s: ICON is not a valid type", caller); | |
52 endswitch | |
53 endif | |
54 | |
55 if (__have_feature__ ("JAVA")) | |
56 retval = javaMethod (dlg, "org.octave.JDialogBox", msg, title); | |
57 if (retval) | |
58 return; | |
59 endif | |
60 endif | |
61 | |
62 ## FIXME -- provide terminal-based implementation here? | |
63 | |
64 if (! retval) | |
65 error ("%s is not available in this version of Octave", dlg); | |
66 endif | |
67 | |
68 endfunction |