]> Creatis software - CreaPhase.git/blob - octave_packages/java-1.2.8/questdlg.m
Add a useful package (from Source forge) for octave
[CreaPhase.git] / octave_packages / java-1.2.8 / questdlg.m
1 ## Copyright (C) 2010 Martin Hepperle
2 ##
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.
7 ##
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.
12 ##
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/>.
15
16 ## -*- texinfo -*-
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})
21 ##
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.
25 ##
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}.
30 ##
31 ## If only @var{MESSAGE} and @var{TITLE} are specified, three buttons with
32 ## the default captions "Yes", "No", "Cancel" are used.
33 ##
34 ## If only two button captions @var{BTN1} and @var{BTN2} are specified, 
35 ## the dialog will have only these two buttons.
36 ##
37 ## @end deftypefn
38 ## @seealso{errordlg, helpdlg, inputdlg, listdlg, warndlg}
39
40 function ret = questdlg(question,varargin)
41
42   if length(varargin) < 1
43     print_usage();
44   end
45   
46   options{1} = 'Yes';      % button1
47   options{2} = 'No';       % button2
48   options{3} = 'Cancel';   % button3
49   options{4} = 'Yes';      % default
50
51
52   switch length(varargin)
53   case 1
54      % title was given
55      title = varargin{1};
56   case 2
57      % title and default button string
58      title      = varargin{1};
59      options{4} = varargin{2}; % default
60   case 4
61      % title, two buttons and default button string
62      title      = varargin{1};
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
67   case 5
68      % title, three buttons and default button string
69      title      = varargin{1};
70      options{1} = varargin{2}; % button1
71      options{2} = varargin{3}; % button2
72      options{3} = varargin{4}; % button3
73      options{4} = varargin{5}; % default
74   otherwise
75      print_usage();
76   end
77
78
79   ret = java_invoke ('org.octave.JDialogBox', 'questdlg', question, title, options);
80
81 end