comparison scripts/java/questdlg.m @ 15748:54e8c2527a9e

style and doc fixes for newly imported Java package .m files * java/cell2mlstr.m, java/errordlg.m, java/helpdlg.m, java/inputdlg.m, java/javaArray.m, java/javaaddpath.m, java/javaclasspath.m, java/javafields.m, java/javamem.m, java/javamethods.m, java/javarmpath.m, java/listdlg.m, java/msgbox.m java/questdlg.m, java/warndlg.m: Style and doc fixes.
author John W. Eaton <jwe@octave.org>
date Fri, 07 Dec 2012 17:21:27 -0500
parents da26f72408a7
children 0f1a143e5002
comparison
equal deleted inserted replaced
15747:4be890c5527c 15748:54e8c2527a9e
15 ## You should have received a copy of the GNU General Public License 15 ## You should have received a copy of the GNU General Public License
16 ## along with Octave; see the file COPYING. If not, see 16 ## along with Octave; see the file COPYING. If not, see
17 ## <http://www.gnu.org/licenses/>. 17 ## <http://www.gnu.org/licenses/>.
18 18
19 ## -*- texinfo -*- 19 ## -*- texinfo -*-
20 ## @deftypefn {Function file} {@var{P} =} questdlg (@var{MESSAGE}, @var{TITLE}) 20 ## @deftypefn {Function file} {@var{p} =} questdlg (@var{msg}, @var{title})
21 ## @deftypefnx {Function file} @var{P} = questdlg (@var{MESSAGE}, @var{TITLE}, @var{DEFAULT}) 21 ## @deftypefnx {Function file} @var{p} = questdlg (@var{msg}, @var{title}, @var{default})
22 ## @deftypefnx {Function file} @var{P} = questdlg (@var{MESSAGE}, @var{TITLE}, @var{BTN1}, @var{BTN2}, @var{DEFAULT}) 22 ## @deftypefnx {Function file} @var{p} = questdlg (@var{msg}, @var{title}, @var{btn1}, @var{btn2}, @var{default})
23 ## @deftypefnx {Function file} @var{P} = questdlg (@var{MESSAGE}, @var{TITLE}, @var{BTN1}, @var{BTN2}, @var{BTN3}, @var{DEFAULT}) 23 ## @deftypefnx {Function file} @var{p} = questdlg (@var{msg}, @var{title}, @var{btn1}, @var{btn2}, @var{btn3}, @var{default})
24 ## Display @var{msg} using a question dialog box and return the caption
25 ## of the activated button.
24 ## 26 ##
25 ## Displays the @var{MESSAGE} using a question dialog box. 27 ## The dialog may contain two or three buttons which all close the dialog.
26 ## The dialog contains two or three buttons which all close the dialog.
27 ## It returns the caption of the activated button.
28 ## 28 ##
29 ## @var{message} can have multiple lines separated by newline characters 29 ## The message may have multiple lines separated by newline characters
30 ## ("\n"), or it can be a cellstr array (one element for each line). 30 ## (@code{"\n"}), or it may be a cellstr array with one element for each
31 ## The optional @var{TITLE} (character string) can be used to decorate the 31 ## line. The optional @var{title} (character string) can be used to
32 ## dialog caption. 32 ## decorate the dialog caption.
33 ## The string @var{DEFAULT} identifies the default button, 33 ##
34 ## The string @var{default} identifies the default button,
34 ## which is activated by pressing the ENTER key. 35 ## which is activated by pressing the ENTER key.
35 ## It must match one of the strings given in @var{BTN1}, @var{BTN2} or @var{BTN3}. 36 ## It must match one of the strings given in @var{btn1}, @var{btn2} or
37 ## @var{btn3}.
36 ## 38 ##
37 ## If only @var{MESSAGE} and @var{TITLE} are specified, three buttons with 39 ## If only @var{msg} and @var{title} are specified, three buttons with
38 ## the default captions "Yes", "No", "Cancel" are used. 40 ## the default captions @code{"Yes"}, @code{"No"}, and @code{"Cancel"}
41 ## are used.
39 ## 42 ##
40 ## If only two button captions @var{BTN1} and @var{BTN2} are specified, 43 ## If only two button captions @var{btn1} and @var{btn2} are specified,
41 ## the dialog will have only these two buttons. 44 ## the dialog will have only these two buttons.
42 ## 45 ##
46 ## @seealso{errordlg, helpdlg, inputdlg, listdlg, warndlg}
43 ## @end deftypefn 47 ## @end deftypefn
44 ## @seealso{errordlg, helpdlg, inputdlg, listdlg, warndlg}
45 48
46 function ret = questdlg (question, varargin) 49 function ret = questdlg (question, varargin)
47 50
48 if length (varargin) < 1 51 if (numel (varargin) < 1)
49 print_usage(); 52 print_usage ();
50 end 53 endif
51 54
52 options{1} = 'Yes'; % button1 55 options{1} = "Yes"; ## button1
53 options{2} = 'No'; % button2 56 options{2} = "No"; ## button2
54 options{3} = 'Cancel'; % button3 57 options{3} = "Cancel"; ## button3
55 options{4} = 'Yes'; % default 58 options{4} = "Yes"; ## default
56 59
57 if (! ischar (question)) 60 if (! ischar (question))
58 if (iscell (question)) 61 if (iscell (question))
59 question = cell2mlstr (question); 62 question = cell2mlstr (question);
60 else 63 else
61 error ("questdlg: character string or cellstr array expected for message"); 64 error ("questdlg: character string or cellstr array expected for message");
62 endif 65 endif
63 endif 66 endif
64 67
65 switch length (varargin) 68 switch (numel (varargin))
66 case 1 69 case 1
67 % title was given 70 ## title was given
68 title = varargin{1}; 71 title = varargin{1};
69 case 2 72
70 % title and default button string 73 case 2
71 title = varargin{1}; 74 ## title and default button string
72 options{4} = varargin{2}; % default 75 title = varargin{1};
73 case 4 76 options{4} = varargin{2}; ## default
74 % title, two buttons and default button string 77
75 title = varargin{1}; 78 case 4
76 options{1} = varargin{2}; % button1 79 ## title, two buttons and default button string
77 options{2} = ''; % not used, no middle button 80 title = varargin{1};
78 options{3} = varargin{3}; % button3 81 options{1} = varargin{2}; ## button1
79 options{4} = varargin{4}; % default 82 options{2} = ""; ## not used, no middle button
80 case 5 83 options{3} = varargin{3}; ## button3
81 % title, three buttons and default button string 84 options{4} = varargin{4}; ## default
82 title = varargin{1}; 85
83 options{1} = varargin{2}; % button1 86 case 5
84 options{2} = varargin{3}; % button2 87 ## title, three buttons and default button string
85 options{3} = varargin{4}; % button3 88 title = varargin{1};
86 options{4} = varargin{5}; % default 89 options{1} = varargin{2}; ## button1
87 otherwise 90 options{2} = varargin{3}; ## button2
88 print_usage(); 91 options{3} = varargin{4}; ## button3
89 end 92 options{4} = varargin{5}; ## default
93
94 otherwise
95 print_usage ();
96 endswitch
90 97
91 if (! ischar (title)) 98 if (! ischar (title))
92 error ("questdlg: character string expected for title"); 99 error ("questdlg: character string expected for title");
93 endif 100 endif
94 101
95 ret = java_invoke ('org.octave.JDialogBox', 'questdlg', question, title, options); 102 ret = java_invoke ("org.octave.JDialogBox", "questdlg", question,
103 title, options);
96 104
97 end 105 endfunction
106