1 ## Copyright (C) 2010 Martin Hepperle
3 ## This program is free software; you can redistribute it and/or modify
4 ## it under the terms of the GNU General Public License as published by
5 ## the Free Software Foundation; either version 2 of the License, or
6 ## (at your option) any later version.
8 ## This program is distributed in the hope that it will be useful,
9 ## but WITHOUT ANY WARRANTY; without even the implied warranty of
10 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 ## GNU General Public License for more details.
13 ## You should have received a copy of the GNU General Public License
14 ## along with this program; If not, see <http://www.gnu.org/licenses/>.
17 ## @deftypefn {Function file} {@var{P} =} questdlg (@var{MESSAGE}, @var{TITLE})
18 ## @deftypefnx {Function file} @var{P} = questdlg (@var{MESSAGE}, @var{TITLE}, @var{DEFAULT})
19 ## @deftypefnx {Function file} @var{P} = questdlg (@var{MESSAGE}, @var{TITLE}, @var{BTN1}, @var{BTN2}, @var{DEFAULT})
20 ## @deftypefnx {Function file} @var{P} = questdlg (@var{MESSAGE}, @var{TITLE}, @var{BTN1}, @var{BTN2}, @var{BTN3}, @var{DEFAULT})
22 ## Displays the @var{MESSAGE} using a question dialog box.
23 ## The dialog contains two or three buttons which all close the dialog.
24 ## It returns the caption of the activated button.
26 ## The @var{TITLE} can be used optionally to decorate the dialog caption.
27 ## The string @var{DEFAULT} identifies the default button,
28 ## which is activated by pressing the ENTER key.
29 ## It must match one of the strings given in @var{BTN1}, @var{BTN2} or @var{BTN3}.
31 ## If only @var{MESSAGE} and @var{TITLE} are specified, three buttons with
32 ## the default captions "Yes", "No", "Cancel" are used.
34 ## If only two button captions @var{BTN1} and @var{BTN2} are specified,
35 ## the dialog will have only these two buttons.
38 ## @seealso{errordlg, helpdlg, inputdlg, listdlg, warndlg}
40 function ret = questdlg(question,varargin)
42 if length(varargin) < 1
46 options{1} = 'Yes'; % button1
47 options{2} = 'No'; % button2
48 options{3} = 'Cancel'; % button3
49 options{4} = 'Yes'; % default
52 switch length(varargin)
57 % title and default button string
59 options{4} = varargin{2}; % default
61 % title, two buttons and default button string
63 options{1} = varargin{2}; % button1
64 options{2} = ''; % not used, no middle button
65 options{3} = varargin{3}; % button3
66 options{4} = varargin{4}; % default
68 % title, three buttons and default button string
70 options{1} = varargin{2}; % button1
71 options{2} = varargin{3}; % button2
72 options{3} = varargin{4}; % button3
73 options{4} = varargin{5}; % default
79 ret = java_invoke ('org.octave.JDialogBox', 'questdlg', question, title, options);