Mercurial > hg > octave-lyh
diff 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 |
line wrap: on
line diff
--- a/scripts/java/questdlg.m +++ b/scripts/java/questdlg.m @@ -17,42 +17,45 @@ ## <http://www.gnu.org/licenses/>. ## -*- texinfo -*- -## @deftypefn {Function file} {@var{P} =} questdlg (@var{MESSAGE}, @var{TITLE}) -## @deftypefnx {Function file} @var{P} = questdlg (@var{MESSAGE}, @var{TITLE}, @var{DEFAULT}) -## @deftypefnx {Function file} @var{P} = questdlg (@var{MESSAGE}, @var{TITLE}, @var{BTN1}, @var{BTN2}, @var{DEFAULT}) -## @deftypefnx {Function file} @var{P} = questdlg (@var{MESSAGE}, @var{TITLE}, @var{BTN1}, @var{BTN2}, @var{BTN3}, @var{DEFAULT}) +## @deftypefn {Function file} {@var{p} =} questdlg (@var{msg}, @var{title}) +## @deftypefnx {Function file} @var{p} = questdlg (@var{msg}, @var{title}, @var{default}) +## @deftypefnx {Function file} @var{p} = questdlg (@var{msg}, @var{title}, @var{btn1}, @var{btn2}, @var{default}) +## @deftypefnx {Function file} @var{p} = questdlg (@var{msg}, @var{title}, @var{btn1}, @var{btn2}, @var{btn3}, @var{default}) +## Display @var{msg} using a question dialog box and return the caption +## of the activated button. ## -## Displays the @var{MESSAGE} using a question dialog box. -## The dialog contains two or three buttons which all close the dialog. -## It returns the caption of the activated button. +## The dialog may contain two or three buttons which all close the dialog. ## -## @var{message} can have multiple lines separated by newline characters -## ("\n"), or it can be a cellstr array (one element for each line). -## The optional @var{TITLE} (character string) can be used to decorate the -## dialog caption. -## The string @var{DEFAULT} identifies the default button, +## The message may have multiple lines separated by newline characters +## (@code{"\n"}), or it may be a cellstr array with one element for each +## line. The optional @var{title} (character string) can be used to +## decorate the dialog caption. +## +## The string @var{default} identifies the default button, ## which is activated by pressing the ENTER key. -## It must match one of the strings given in @var{BTN1}, @var{BTN2} or @var{BTN3}. +## It must match one of the strings given in @var{btn1}, @var{btn2} or +## @var{btn3}. ## -## If only @var{MESSAGE} and @var{TITLE} are specified, three buttons with -## the default captions "Yes", "No", "Cancel" are used. +## If only @var{msg} and @var{title} are specified, three buttons with +## the default captions @code{"Yes"}, @code{"No"}, and @code{"Cancel"} +## are used. ## -## If only two button captions @var{BTN1} and @var{BTN2} are specified, +## If only two button captions @var{btn1} and @var{btn2} are specified, ## the dialog will have only these two buttons. ## +## @seealso{errordlg, helpdlg, inputdlg, listdlg, warndlg} ## @end deftypefn -## @seealso{errordlg, helpdlg, inputdlg, listdlg, warndlg} function ret = questdlg (question, varargin) - if length (varargin) < 1 - print_usage(); - end + if (numel (varargin) < 1) + print_usage (); + endif - options{1} = 'Yes'; % button1 - options{2} = 'No'; % button2 - options{3} = 'Cancel'; % button3 - options{4} = 'Yes'; % default + options{1} = "Yes"; ## button1 + options{2} = "No"; ## button2 + options{3} = "Cancel"; ## button3 + options{4} = "Yes"; ## default if (! ischar (question)) if (iscell (question)) @@ -62,36 +65,42 @@ endif endif - switch length (varargin) - case 1 - % title was given - title = varargin{1}; - case 2 - % title and default button string - title = varargin{1}; - options{4} = varargin{2}; % default - case 4 - % title, two buttons and default button string - title = varargin{1}; - options{1} = varargin{2}; % button1 - options{2} = ''; % not used, no middle button - options{3} = varargin{3}; % button3 - options{4} = varargin{4}; % default - case 5 - % title, three buttons and default button string - title = varargin{1}; - options{1} = varargin{2}; % button1 - options{2} = varargin{3}; % button2 - options{3} = varargin{4}; % button3 - options{4} = varargin{5}; % default - otherwise - print_usage(); - end + switch (numel (varargin)) + case 1 + ## title was given + title = varargin{1}; + + case 2 + ## title and default button string + title = varargin{1}; + options{4} = varargin{2}; ## default + + case 4 + ## title, two buttons and default button string + title = varargin{1}; + options{1} = varargin{2}; ## button1 + options{2} = ""; ## not used, no middle button + options{3} = varargin{3}; ## button3 + options{4} = varargin{4}; ## default + + case 5 + ## title, three buttons and default button string + title = varargin{1}; + options{1} = varargin{2}; ## button1 + options{2} = varargin{3}; ## button2 + options{3} = varargin{4}; ## button3 + options{4} = varargin{5}; ## default + + otherwise + print_usage (); + endswitch if (! ischar (title)) error ("questdlg: character string expected for title"); endif - ret = java_invoke ('org.octave.JDialogBox', 'questdlg', question, title, options); + ret = java_invoke ("org.octave.JDialogBox", "questdlg", question, + title, options); -end +endfunction +