changeset 16505:ff061068a66c

move dialog files to separate directory * scripts/ui/errordlg.m, scripts/ui/helpdlg.m, scripts/ui/inputdlg.m, scripts/ui/listdlg.m, scripts/ui/msgbox.m, scripts/ui/questdlg.m, scripts/ui/warndlg.m: Move here from scripts/java. * scripts/java/module.mk (java_FCN_FILES): Update list. * scripts/ui/module.mk: New file. * scripts/Makefile.am: Include it. (ui/PKG_ADD, $(ui_GEN_FCN_FILES), ui/$(octave_dirstamp)): New targets.
author John W. Eaton <jwe@octave.org>
date Fri, 12 Apr 2013 14:51:51 -0400
parents 49b059bf27c7
children 8a4960f2c7c3
files scripts/Makefile.am scripts/java/errordlg.m scripts/java/helpdlg.m scripts/java/inputdlg.m scripts/java/listdlg.m scripts/java/module.mk scripts/java/msgbox.m scripts/java/questdlg.m scripts/java/warndlg.m scripts/ui/errordlg.m scripts/ui/helpdlg.m scripts/ui/inputdlg.m scripts/ui/listdlg.m scripts/ui/module.mk scripts/ui/msgbox.m scripts/ui/questdlg.m scripts/ui/warndlg.m
diffstat 17 files changed, 647 insertions(+), 630 deletions(-) [+]
line wrap: on
line diff
--- a/scripts/Makefile.am	Fri Apr 12 14:51:47 2013 -0400
+++ b/scripts/Makefile.am	Fri Apr 12 14:51:51 2013 -0400
@@ -74,6 +74,7 @@
 include strings/module.mk
 include testfun/module.mk
 include time/module.mk
+include ui/module.mk
 
 nobase_fcnfile_DATA = $(FCN_FILES) $(GEN_FCN_FILES) $(JAR_FILES)
 
@@ -213,6 +214,10 @@
 	$(srcdir)/mk-pkg-add $(srcdir) $(time_FCN_FILES) -- $(time_GEN_FCN_FILES) > $@-t
 	mv $@-t $@
 
+ui/PKG_ADD: $(ui_FCN_FILES) $(ui_GEN_FCN_FILES) ui/$(octave_dirstamp) mk-pkg-add
+	$(srcdir)/mk-pkg-add $(srcdir) $(ui_FCN_FILES) -- $(ui_GEN_FCN_FILES) > $@-t
+	mv $@-t $@
+
 $(@ftp_GEN_FCN_FILES): @ftp/$(octave_dirstamp)
 $(audio_GEN_FCN_FILES): audio/$(octave_dirstamp)
 $(deprecated_GEN_FCN_FILES): deprecated/$(octave_dirstamp)
@@ -244,6 +249,7 @@
 $(strings_GEN_FCN_FILES): strings/$(octave_dirstamp)
 $(testfun_GEN_FCN_FILES): testfun/$(octave_dirstamp)
 $(time_GEN_FCN_FILES): time/$(octave_dirstamp)
+$(ui_GEN_FCN_FILES): ui/$(octave_dirstamp)
 
 @ftp/$(octave_dirstamp):
 	$(MKDIR_P) @ftp
@@ -338,6 +344,9 @@
 time/$(octave_dirstamp):
 	$(MKDIR_P) time
 	: > time/$(octave_dirstamp)
+ui/$(octave_dirstamp):
+	$(MKDIR_P) ui
+	: > ui/$(octave_dirstamp)
 
 if AMCOND_BUILD_DOCS
 
@@ -464,4 +473,3 @@
 	if [ "x$(srcdir)" != "x." ]; then \
 	  rm $(java_JAVA_IMAGES); \
 	fi
-	
--- a/scripts/java/errordlg.m	Fri Apr 12 14:51:47 2013 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,55 +0,0 @@
-## Copyright (C) 2010 Martin Hepperle
-##
-## This file is part of Octave.
-##
-## Octave is free software; you can redistribute it and/or modify it
-## under the terms of the GNU General Public License as published by
-## the Free Software Foundation; either version 3 of the License, or (at
-## your option) any later version.
-##
-## Octave is distributed in the hope that it will be useful, but
-## WITHOUT ANY WARRANTY; without even the implied warranty of
-## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-## General Public License for more details.
-##
-## You should have received a copy of the GNU General Public License
-## along with Octave; see the file COPYING.  If not, see
-## <http://www.gnu.org/licenses/>.
-
-## -*- texinfo -*-
-## @deftypefn  {Function File} {@var{h} =} errordlg (@var{msg})
-## @deftypefnx {Function File} {@var{h} =} errordlg (@var{msg}, @var{title})
-## Display @var{msg} using an error dialog box.
-##
-## The message may have multiple lines separated by newline characters
-## ("\n"), or it may be a cellstr array with one element for each
-## line.  The optional input @var{title} (character string) can be used to
-## set the dialog caption.  The default title is "Error Dialog".
-##
-## The return value is always 1.
-## @seealso{helpdlg, inputdlg, listdlg, msgbox, questdlg, warndlg}
-## @end deftypefn
-
-function h = errordlg (msg, title = "Error Dialog")
-
-  if (nargin < 1 || nargin > 2)
-    print_usage ();
-  endif
-
-  if (! ischar (msg))
-    if (iscell (msg))
-      msg = sprintf ("%s\n", msg{:});
-      msg(end) = "";
-    else
-      error ("errordlg: MSG must be a string or cellstr array");
-    endif
-  endif
-
-  if (! ischar (title))
-    error ("errordlg: TITLE must be a character string");
-  endif
-
-  h = javaMethod ("errordlg", "org.octave.JDialogBox", msg, title);
-
-endfunction
-
--- a/scripts/java/helpdlg.m	Fri Apr 12 14:51:47 2013 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,55 +0,0 @@
-## Copyright (C) 2010 Martin Hepperle
-##
-## This file is part of Octave.
-##
-## Octave is free software; you can redistribute it and/or modify it
-## under the terms of the GNU General Public License as published by
-## the Free Software Foundation; either version 3 of the License, or (at
-## your option) any later version.
-##
-## Octave is distributed in the hope that it will be useful, but
-## WITHOUT ANY WARRANTY; without even the implied warranty of
-## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-## General Public License for more details.
-##
-## You should have received a copy of the GNU General Public License
-## along with Octave; see the file COPYING.  If not, see
-## <http://www.gnu.org/licenses/>.
-
-## -*- texinfo -*-
-## @deftypefn  {Function File} {@var{h} =} helpdlg (@var{msg})
-## @deftypefnx {Function File} {@var{h} =} helpdlg (@var{msg}, @var{title})
-## Display @var{msg} in a help dialog box.
-##
-## The message may have multiple lines separated by newline characters
-## ("\n"), or it may be a cellstr array with one element for each
-## line.  The optional input @var{title} (character string) can be used to
-## set the dialog caption.  The default title is "Help Dialog".
-##
-## The return value is always 1.
-## @seealso{errordlg, inputdlg, listdlg, msgbox, questdlg, warndlg}
-## @end deftypefn
-
-function h = helpdlg (msg, title = "Help Dialog")
-
-  if (nargin < 1 || nargin > 2)
-    print_usage ();
-  endif
-
-  if (! ischar (msg))
-    if (iscell (msg))
-      msg = sprintf ("%s\n", msg{:});
-      msg(end) = "";
-    else
-      error ("helpdlg: MSG must be a string or cellstr array");
-    endif
-  endif
-
-  if (! ischar (title))
-    error ("helpdlg: TITLE must be a character string");
-  endif
-
-  h = javaMethod ("helpdlg", "org.octave.JDialogBox", msg, title);
-
-endfunction
-
--- a/scripts/java/inputdlg.m	Fri Apr 12 14:51:47 2013 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,138 +0,0 @@
-## Copyright (C) 2010 Martin Hepperle
-##
-## This file is part of Octave.
-##
-## Octave is free software; you can redistribute it and/or modify it
-## under the terms of the GNU General Public License as published by
-## the Free Software Foundation; either version 3 of the License, or (at
-## your option) any later version.
-##
-## Octave is distributed in the hope that it will be useful, but
-## WITHOUT ANY WARRANTY; without even the implied warranty of
-## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-## General Public License for more details.
-##
-## You should have received a copy of the GNU General Public License
-## along with Octave; see the file COPYING.  If not, see
-## <http://www.gnu.org/licenses/>.
-
-## -*- texinfo -*-
-## @deftypefn  {Function File} {@var{cstr} =} inputdlg (@var{prompt})
-## @deftypefnx {Function File} {@var{cstr} =} inputdlg (@var{prompt}, @var{title})
-## @deftypefnx {Function File} {@var{cstr} =} inputdlg (@var{prompt}, @var{title}, @var{rowscols})
-## @deftypefnx {Function File} {@var{cstr} =} inputdlg (@var{prompt}, @var{title}, @var{rowscols}, @var{defaults})
-## Return user input from a multi-textfield dialog box in a cell array
-## of strings, or an empty cell array if the dialog is closed by the
-## Cancel button.
-##
-## Inputs:
-##
-## @table @var
-## @item prompt
-## A cell array with strings labeling each text field.  This input is required. 
-##
-## @item title
-## String to use for the caption of the dialog.  The default is "Input Dialog".
-##
-## @item rowscols
-## Specifies the size of the text fields and can take three forms:
-##
-## @enumerate
-## @item a scalar value which defines the number of rows used for each
-## text field.
-##
-## @item a vector which defines the individual number of rows
-## used for each text field. 
-##
-## @item a matrix which defines the individual number of rows and
-## columns used for each text field.  In the matrix each row describes
-## a single text field.  The first column specifies the number of input
-## rows to use and the second column specifies the text field width.
-## @end enumerate
-##
-## @item defaults
-## A list of default values to place in each text fields.  It must be
-## a cell array of strings with the same size as @var{prompt}.
-## @end table
-## @seealso{errordlg, helpdlg, listdlg, msgbox, questdlg, warndlg}
-## @end deftypefn
-
-function cstr = inputdlg (prompt, title = "Input Dialog", varargin)
-
-  if (nargin < 1 || nargin > 4)
-    print_usage ();
-  endif
-
-  if (iscell (prompt))
-    ## Silently extract only char elements
-    prompt = prompt(cellfun ("ischar", prompt));
-  elseif (ischar (prompt))
-    prompt = {prompt};
-  else
-    error ("inputdlg: PROMPT must be a character string or cellstr array");
-  endif
-
-  if (! ischar (title))
-    error ("inputdlg: TITLE must be a character string");
-  endif
-
-  switch (numel (varargin))
-    case 0
-      linespec = 1;
-      defaults = cellstr (cell (size (prompt)));
-
-    case 1
-      linespec = varargin{1};
-      defaults = cellstr (cell (size (prompt)));
-
-    case 2
-      linespec = varargin{1};
-      defaults = varargin{2};
-  endswitch
-
-  ## specification of text field sizes as in Matlab 
-  ## Matlab requires a matrix for linespec, not a cell array...
-  ## rc = [1,10; 2,20; 3,30];
-  ##     c1  c2
-  ## r1  1   10   first  text field is 1x10
-  ## r2  2   20   second text field is 2x20
-  ## r3  3   30   third  text field is 3x30
-  if (isscalar (linespec))
-    ## only scalar value in lineTo, copy from linespec and add defaults
-    rowscols = zeros (columns (prompt), 2);
-    ## cols
-    rowscols(:,2) = 25;
-    rowscols(:,1) = linespec;
-  elseif (isvector (linespec))
-      ## only one column in lineTo, copy from vector linespec and add defaults
-      rowscols = zeros (columns (prompt), 2);
-      ## rows from colum vector linespec, columns are set to default
-      rowscols(:,2) = 25;
-      rowscols(:,1) = linespec(:);
-  elseif (ismatrix (linespec))
-    if (rows (linespec) == columns (prompt) && columns (linespec) == 2)
-      ## (rows x columns) match, copy array linespec
-      rowscols = linespec;
-    else
-      error ("inputdlg: ROWSCOLS matrix does not match size of PROMPT");
-    endif
-
-  else
-    ## dunno
-    error ("inputdlg: unknown form of ROWSCOLS argument");
-  endif
-  
-  ## convert numeric values in defaults cell array to strings
-  defs = cellfun (@num2str, defaults, "UniformOutput", false);
-  rc = arrayfun (@num2str, rowscols, "UniformOutput", false);
-
-  user_inputs = javaMethod ("inputdlg", "org.octave.JDialogBox",
-                             prompt, title, rc, defs);
-  
-   if (isempty (user_inputs))
-     cstr = {};
-   else
-     cstr = cellstr (user_inputs);
-   endif
-
-endfunction
--- a/scripts/java/listdlg.m	Fri Apr 12 14:51:47 2013 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,142 +0,0 @@
-## Copyright (C) 2010 Martin Hepperle
-##
-## This file is part of Octave.
-##
-## Octave is free software; you can redistribute it and/or modify it
-## under the terms of the GNU General Public License as published by
-## the Free Software Foundation; either version 3 of the License, or (at
-## your option) any later version.
-##
-## Octave is distributed in the hope that it will be useful, but
-## WITHOUT ANY WARRANTY; without even the implied warranty of
-## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-## General Public License for more details.
-##
-## You should have received a copy of the GNU General Public License
-## along with Octave; see the file COPYING.  If not, see
-## <http://www.gnu.org/licenses/>.
-
-## -*- texinfo -*-
-## @deftypefn {Function File} {[@var{sel}, @var{ok}] =} listdlg (@var{key}, @var{value}, @dots{})
-## Return user inputs from a list dialog box in a vector of 
-## selection indices @var{sel} and a flag @var{ok} indicating how the
-## user closed the dialog box.  The value of @var{ok} is 1 if the user
-## closed the box with the OK button, otherwise it is 0 and @var{sel} is
-## empty.
-##
-## The indices in @var{sel} are 1-based.
-##
-## The arguments are specified in form of @var{key}, @var{value} pairs. 
-## The "ListString" argument pair must be specified.
-##
-## Valid @var{key} and @var{value} pairs are:
-##
-## @table @asis
-## @item "ListString"
-## a cell array of strings comprising the content of the list.
-##
-## @item "SelectionMode"
-## can be either "Single" or "Multiple" (default).
-##
-## @item "ListSize"
-## a vector with two elements @var{width} and @var{height} defining
-## the size of the list field in pixels.  Default is [160 300].
-##
-## @item "InitialValue"
-## a vector containing 1-based indices of preselected elements.  Default
-## is 1 (first item).
-##
-## @item "Name"
-## a string to be used as the dialog caption.  Default is "".
-##
-## @item "PromptString"
-## a cell array of strings to be displayed above the list field.  Default
-## is @{@}.
-##
-## @item "OKString"
-## a string used to label the OK button.  Default is "OK".
-##
-## @item "CancelString"
-## a string used to label the Cancel button.  Default is "Cancel".
-## @end table
-##
-## Example:
-##
-## @example
-## @group
-## [sel, ok] = listdlg ("ListString", @{"An item", "another", "yet another"@},
-##                      "SelectionMode", "Multiple");
-## if (ok == 1)
-##   for i = 1:numel (sel)
-##     disp (sel(i));
-##   endfor
-## endif
-## @end group
-## @end example
-##
-## @seealso{errordlg, helpdlg, inputdlg, msgbox, questdlg, warndlg}
-## @end deftypefn
-
-function varargout = listdlg (varargin)
-
-   if (nargin < 2)
-     print_usage ();
-   endif
-   
-   listcell = {""};
-   selmode = "multiple";
-   listsize = [160, 300];
-   initialvalue = 1;
-   name = "";
-   prompt = {""};
-   okstring = "OK";
-   cancelstring = "Cancel";
-   
-   ## handle key, value pairs
-   for i = 1:2:nargin-1
-     if strcmp (varargin{i}, "ListString")
-       listcell = varargin{i+1};
-     elseif strcmp (varargin{i}, "SelectionMode")
-       selmode = varargin{i+1};
-     elseif strcmp (varargin{i}, "ListSize")
-       listsize = varargin{i+1};
-     elseif strcmp (varargin{i}, "InitialValue")
-       initialvalue = varargin{i+1};
-     elseif strcmp (varargin{i}, "Name")
-       name = varargin{i+1};
-     elseif strcmp (varargin{i}, "PromptString")
-       prompt = varargin{i+1};
-     elseif strcmp (varargin{i}, "OKString")
-       okstring = varargin{i+1};
-     elseif strcmp (varargin{i}, "CancelString")
-       cancelstring = varargin{i+1};
-     endif
-   endfor
-
-   ## make sure prompt strings are a cell array
-   if (! iscell (prompt))
-     prompt = {prompt};
-   endif
-
-   ## make sure listcell strings are a cell array
-   if (! iscell (listcell))
-     listcell = {listcell};
-   endif
-   
-   ## transform matrices to cell arrays of strings
-   ## swap width and height to correct calling format for JDialogBox
-   listsize = {num2str(listsize(2)), num2str(listsize(1))};
-   initialvalue = arrayfun (@num2str, initialvalue, "UniformOutput", false);
-   
-   ret = javaMethod ("listdlg", "org.octave.JDialogBox", listcell,
-                      selmode, listsize, initialvalue, name, prompt,
-                      okstring, cancelstring);
-
-   if (numel (ret) > 0)
-     varargout = {ret, 1};
-   else
-     varargout = {{}, 0};
-   endif
-
-endfunction
-
--- a/scripts/java/module.mk	Fri Apr 12 14:51:47 2013 -0400
+++ b/scripts/java/module.mk	Fri Apr 12 14:51:51 2013 -0400
@@ -2,19 +2,12 @@
 
 java_FCN_FILES = \
   java/dlgtest.m \
-  java/errordlg.m \
-  java/helpdlg.m \
-  java/inputdlg.m \
   java/javaArray.m \
   java/javaaddpath.m \
   java/javaclasspath.m \
   java/javamem.m \
   java/javarmpath.m \
-  java/listdlg.m \
-  java/msgbox.m \
-  java/questdlg.m \
-  java/usejava.m \
-  java/warndlg.m
+  java/usejava.m
 
 FCN_FILES += $(java_FCN_FILES)
 
--- a/scripts/java/msgbox.m	Fri Apr 12 14:51:47 2013 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,76 +0,0 @@
-## Copyright (C) 2010 Martin Hepperle
-##
-## This file is part of Octave.
-##
-## Octave is free software; you can redistribute it and/or modify it
-## under the terms of the GNU General Public License as published by
-## the Free Software Foundation; either version 3 of the License, or (at
-## your option) any later version.
-##
-## Octave is distributed in the hope that it will be useful, but
-## WITHOUT ANY WARRANTY; without even the implied warranty of
-## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-## General Public License for more details.
-##
-## You should have received a copy of the GNU General Public License
-## along with Octave; see the file COPYING.  If not, see
-## <http://www.gnu.org/licenses/>.
-
-## -*- texinfo -*-
-## @deftypefn  {Function File} {@var{h} =} msgbox (@var{msg})
-## @deftypefnx {Function File} {@var{h} =} msgbox (@var{msg}, @var{title})
-## @deftypefnx {Function File} {@var{h} =} msgbox (@var{msg}, @var{title}, @var{icon})
-## Display @var{msg} using a message dialog box. 
-##
-## 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 input @var{title} (character string) can be used to
-## decorate the dialog caption.
-##
-## The optional argument @var{icon} selects a dialog icon. 
-## It can be one of @code{"none"} (default), @code{"error"}, @code{"help"}, or
-## @code{"warn"}.
-##
-## The return value is always 1.
-## @seealso{errordlg, helpdlg, inputdlg, listdlg, questdlg, warndlg}
-## @end deftypefn
-
-function h = msgbox (msg, title = "", icon)
-
-  if (nargin < 1 || nargin > 3)
-    print_usage ();
-  endif
-
-  if (! ischar (msg))
-    if (iscell (msg))
-      msg = sprintf ("%s\n", msg{:});
-      msg(end) = "";
-    else
-      error ("msgbox: MSG must be a character string or cellstr array");
-    endif
-  endif
-
-  if (! ischar (title))
-    error ("msgbox: TITLE must be a character string");
-  endif
-  
-  dlg = "emptydlg";
-  if (nargin == 3)
-    switch (icon)
-      case "error"
-        dlg = "errordlg";
-      case "help"
-        dlg = "helpdlg";
-      case "warn"
-        dlg = "warndlg";
-      case "none"
-        dlg = "emptydlg";
-      otherwise
-        error ("msgbox: ICON is not a valid type");
-    endswitch
-  endif
-
-  h = javaMethod (dlg, "org.octave.JDialogBox", msg, title);
-
-endfunction
-
--- a/scripts/java/questdlg.m	Fri Apr 12 14:51:47 2013 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,101 +0,0 @@
-## Copyright (C) 2010 Martin Hepperle
-##
-## This file is part of Octave.
-##
-## Octave is free software; you can redistribute it and/or modify it
-## under the terms of the GNU General Public License as published by
-## the Free Software Foundation; either version 3 of the License, or (at
-## your option) any later version.
-##
-## Octave is distributed in the hope that it will be useful, but
-## WITHOUT ANY WARRANTY; without even the implied warranty of
-## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-## General Public License for more details.
-##
-## You should have received a copy of the GNU General Public License
-## along with Octave; see the file COPYING.  If not, see
-## <http://www.gnu.org/licenses/>.
-
-## -*- texinfo -*-
-## @deftypefn  {Function File} {@var{btn} =} questdlg (@var{msg})
-## @deftypefnx {Function File} {@var{btn} =} questdlg (@var{msg}, @var{title})
-## @deftypefnx {Function File} {@var{btn} =} questdlg (@var{msg}, @var{title}, @var{default})
-## @deftypefnx {Function File} {@var{btn} =} questdlg (@var{msg}, @var{title}, @var{btn1}, @var{btn2}, @var{default})
-## @deftypefnx {Function File} {@var{btn} =} 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.
-##
-## The dialog may contain two or three buttons which will all close the dialog.
-##
-## The message may have multiple lines separated by newline characters
-## ("\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 @key{ENTER} key.
-## It must match one of the strings given in @var{btn1}, @var{btn2}, or
-## @var{btn3}.
-##
-## If only @var{msg} and @var{title} are specified, three buttons with
-## the default captions "Yes", "No", and "Cancel" are used.
-##
-## 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
-
-function btn = questdlg (msg, title = "Question Dialog", varargin)
-
-  if (nargin < 1 || nargin > 6)
-    print_usage ();
-  endif
-  
-  if (! ischar (msg))
-    if (iscell (msg))
-      msg = sprintf ("%s\n", msg{:});
-      msg(end) = "";
-    else
-      error ("questdlg: MSG must be a character string or cellstr array");
-    endif
-  endif
-
-  if (! ischar (title))
-    error ("questdlg: TITLES must be a character string");
-  endif
-
-  options{1} = "Yes";      # button1
-  options{2} = "No";       # button2
-  options{3} = "Cancel";   # button3
-  options{4} = "Yes";      # default
-
-  switch (numel (varargin))
-    case 1
-      ## default button string
-      options{4} = varargin{1};  # default
-
-    case 3
-      ## two buttons and default button string
-      options{1} = varargin{1};  # button1
-      options{2} = "";           # not used, no middle button
-      options{3} = varargin{2};  # button3
-      options{4} = varargin{3};  # default
-
-    case 4
-      ## three buttons and default button string
-      options{1} = varargin{1};  # button1
-      options{2} = varargin{2};  # button2
-      options{3} = varargin{3};  # button3
-      options{4} = varargin{4};  # default
-
-    otherwise
-      print_usage ();
-
-  endswitch
-
-  btn = javaMethod ("questdlg", "org.octave.JDialogBox", msg,
-                     title, options);
-
-endfunction
-
--- a/scripts/java/warndlg.m	Fri Apr 12 14:51:47 2013 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,54 +0,0 @@
-## Copyright (C) 2010 Martin Hepperle
-##
-## This file is part of Octave.
-##
-## Octave is free software; you can redistribute it and/or modify it
-## under the terms of the GNU General Public License as published by
-## the Free Software Foundation; either version 3 of the License, or (at
-## your option) any later version.
-##
-## Octave is distributed in the hope that it will be useful, but
-## WITHOUT ANY WARRANTY; without even the implied warranty of
-## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-## General Public License for more details.
-##
-## You should have received a copy of the GNU General Public License
-## along with Octave; see the file COPYING.  If not, see
-## <http://www.gnu.org/licenses/>.
-
-## -*- texinfo -*-
-## @deftypefn  {Function File} {@var{h} =} warndlg (@var{msg})
-## @deftypefnx {Function File} {@var{h} =} warndlg (@var{msg}, @var{title})
-## Display @var{msg} using a warning dialog box. 
-##
-## The message may have multiple lines separated by newline characters
-## ("\n"), or it may be a cellstr array with one element for each
-## line.  The optional input @var{title} (character string) can be used to
-## set the dialog caption.  The default title is "Warning Dialog".
-##
-## @seealso{helpdlg, inputdlg, listdlg, questdlg}
-## @end deftypefn
-
-function retval = warndlg (msg, title = "Warning Dialog")
-
-  if (nargin < 1 || nargin > 2)
-    print_usage ();
-  endif
-
-  if (! ischar (msg))
-    if (iscell (msg))
-      msg = sprintf ("%s\n", msg{:});
-      msg(end) = "";
-    else
-      error ("warndlg: MSG must be a string or cellstr array");
-    endif
-  endif
-
-  if (! ischar (title))
-    error ("warndlg: TITLE must be a character string");
-  endif
-
-  retval = javaMethod ("warndlg", "org.octave.JDialogBox", msg, title);
-
-endfunction
-
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/scripts/ui/errordlg.m	Fri Apr 12 14:51:51 2013 -0400
@@ -0,0 +1,55 @@
+## Copyright (C) 2010 Martin Hepperle
+##
+## This file is part of Octave.
+##
+## Octave is free software; you can redistribute it and/or modify it
+## under the terms of the GNU General Public License as published by
+## the Free Software Foundation; either version 3 of the License, or (at
+## your option) any later version.
+##
+## Octave is distributed in the hope that it will be useful, but
+## WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+## General Public License for more details.
+##
+## You should have received a copy of the GNU General Public License
+## along with Octave; see the file COPYING.  If not, see
+## <http://www.gnu.org/licenses/>.
+
+## -*- texinfo -*-
+## @deftypefn  {Function File} {@var{h} =} errordlg (@var{msg})
+## @deftypefnx {Function File} {@var{h} =} errordlg (@var{msg}, @var{title})
+## Display @var{msg} using an error dialog box.
+##
+## The message may have multiple lines separated by newline characters
+## ("\n"), or it may be a cellstr array with one element for each
+## line.  The optional input @var{title} (character string) can be used to
+## set the dialog caption.  The default title is "Error Dialog".
+##
+## The return value is always 1.
+## @seealso{helpdlg, inputdlg, listdlg, msgbox, questdlg, warndlg}
+## @end deftypefn
+
+function h = errordlg (msg, title = "Error Dialog")
+
+  if (nargin < 1 || nargin > 2)
+    print_usage ();
+  endif
+
+  if (! ischar (msg))
+    if (iscell (msg))
+      msg = sprintf ("%s\n", msg{:});
+      msg(end) = "";
+    else
+      error ("errordlg: MSG must be a string or cellstr array");
+    endif
+  endif
+
+  if (! ischar (title))
+    error ("errordlg: TITLE must be a character string");
+  endif
+
+  h = javaMethod ("errordlg", "org.octave.JDialogBox", msg, title);
+
+endfunction
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/scripts/ui/helpdlg.m	Fri Apr 12 14:51:51 2013 -0400
@@ -0,0 +1,55 @@
+## Copyright (C) 2010 Martin Hepperle
+##
+## This file is part of Octave.
+##
+## Octave is free software; you can redistribute it and/or modify it
+## under the terms of the GNU General Public License as published by
+## the Free Software Foundation; either version 3 of the License, or (at
+## your option) any later version.
+##
+## Octave is distributed in the hope that it will be useful, but
+## WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+## General Public License for more details.
+##
+## You should have received a copy of the GNU General Public License
+## along with Octave; see the file COPYING.  If not, see
+## <http://www.gnu.org/licenses/>.
+
+## -*- texinfo -*-
+## @deftypefn  {Function File} {@var{h} =} helpdlg (@var{msg})
+## @deftypefnx {Function File} {@var{h} =} helpdlg (@var{msg}, @var{title})
+## Display @var{msg} in a help dialog box.
+##
+## The message may have multiple lines separated by newline characters
+## ("\n"), or it may be a cellstr array with one element for each
+## line.  The optional input @var{title} (character string) can be used to
+## set the dialog caption.  The default title is "Help Dialog".
+##
+## The return value is always 1.
+## @seealso{errordlg, inputdlg, listdlg, msgbox, questdlg, warndlg}
+## @end deftypefn
+
+function h = helpdlg (msg, title = "Help Dialog")
+
+  if (nargin < 1 || nargin > 2)
+    print_usage ();
+  endif
+
+  if (! ischar (msg))
+    if (iscell (msg))
+      msg = sprintf ("%s\n", msg{:});
+      msg(end) = "";
+    else
+      error ("helpdlg: MSG must be a string or cellstr array");
+    endif
+  endif
+
+  if (! ischar (title))
+    error ("helpdlg: TITLE must be a character string");
+  endif
+
+  h = javaMethod ("helpdlg", "org.octave.JDialogBox", msg, title);
+
+endfunction
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/scripts/ui/inputdlg.m	Fri Apr 12 14:51:51 2013 -0400
@@ -0,0 +1,138 @@
+## Copyright (C) 2010 Martin Hepperle
+##
+## This file is part of Octave.
+##
+## Octave is free software; you can redistribute it and/or modify it
+## under the terms of the GNU General Public License as published by
+## the Free Software Foundation; either version 3 of the License, or (at
+## your option) any later version.
+##
+## Octave is distributed in the hope that it will be useful, but
+## WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+## General Public License for more details.
+##
+## You should have received a copy of the GNU General Public License
+## along with Octave; see the file COPYING.  If not, see
+## <http://www.gnu.org/licenses/>.
+
+## -*- texinfo -*-
+## @deftypefn  {Function File} {@var{cstr} =} inputdlg (@var{prompt})
+## @deftypefnx {Function File} {@var{cstr} =} inputdlg (@var{prompt}, @var{title})
+## @deftypefnx {Function File} {@var{cstr} =} inputdlg (@var{prompt}, @var{title}, @var{rowscols})
+## @deftypefnx {Function File} {@var{cstr} =} inputdlg (@var{prompt}, @var{title}, @var{rowscols}, @var{defaults})
+## Return user input from a multi-textfield dialog box in a cell array
+## of strings, or an empty cell array if the dialog is closed by the
+## Cancel button.
+##
+## Inputs:
+##
+## @table @var
+## @item prompt
+## A cell array with strings labeling each text field.  This input is required. 
+##
+## @item title
+## String to use for the caption of the dialog.  The default is "Input Dialog".
+##
+## @item rowscols
+## Specifies the size of the text fields and can take three forms:
+##
+## @enumerate
+## @item a scalar value which defines the number of rows used for each
+## text field.
+##
+## @item a vector which defines the individual number of rows
+## used for each text field. 
+##
+## @item a matrix which defines the individual number of rows and
+## columns used for each text field.  In the matrix each row describes
+## a single text field.  The first column specifies the number of input
+## rows to use and the second column specifies the text field width.
+## @end enumerate
+##
+## @item defaults
+## A list of default values to place in each text fields.  It must be
+## a cell array of strings with the same size as @var{prompt}.
+## @end table
+## @seealso{errordlg, helpdlg, listdlg, msgbox, questdlg, warndlg}
+## @end deftypefn
+
+function cstr = inputdlg (prompt, title = "Input Dialog", varargin)
+
+  if (nargin < 1 || nargin > 4)
+    print_usage ();
+  endif
+
+  if (iscell (prompt))
+    ## Silently extract only char elements
+    prompt = prompt(cellfun ("ischar", prompt));
+  elseif (ischar (prompt))
+    prompt = {prompt};
+  else
+    error ("inputdlg: PROMPT must be a character string or cellstr array");
+  endif
+
+  if (! ischar (title))
+    error ("inputdlg: TITLE must be a character string");
+  endif
+
+  switch (numel (varargin))
+    case 0
+      linespec = 1;
+      defaults = cellstr (cell (size (prompt)));
+
+    case 1
+      linespec = varargin{1};
+      defaults = cellstr (cell (size (prompt)));
+
+    case 2
+      linespec = varargin{1};
+      defaults = varargin{2};
+  endswitch
+
+  ## specification of text field sizes as in Matlab 
+  ## Matlab requires a matrix for linespec, not a cell array...
+  ## rc = [1,10; 2,20; 3,30];
+  ##     c1  c2
+  ## r1  1   10   first  text field is 1x10
+  ## r2  2   20   second text field is 2x20
+  ## r3  3   30   third  text field is 3x30
+  if (isscalar (linespec))
+    ## only scalar value in lineTo, copy from linespec and add defaults
+    rowscols = zeros (columns (prompt), 2);
+    ## cols
+    rowscols(:,2) = 25;
+    rowscols(:,1) = linespec;
+  elseif (isvector (linespec))
+      ## only one column in lineTo, copy from vector linespec and add defaults
+      rowscols = zeros (columns (prompt), 2);
+      ## rows from colum vector linespec, columns are set to default
+      rowscols(:,2) = 25;
+      rowscols(:,1) = linespec(:);
+  elseif (ismatrix (linespec))
+    if (rows (linespec) == columns (prompt) && columns (linespec) == 2)
+      ## (rows x columns) match, copy array linespec
+      rowscols = linespec;
+    else
+      error ("inputdlg: ROWSCOLS matrix does not match size of PROMPT");
+    endif
+
+  else
+    ## dunno
+    error ("inputdlg: unknown form of ROWSCOLS argument");
+  endif
+  
+  ## convert numeric values in defaults cell array to strings
+  defs = cellfun (@num2str, defaults, "UniformOutput", false);
+  rc = arrayfun (@num2str, rowscols, "UniformOutput", false);
+
+  user_inputs = javaMethod ("inputdlg", "org.octave.JDialogBox",
+                             prompt, title, rc, defs);
+  
+   if (isempty (user_inputs))
+     cstr = {};
+   else
+     cstr = cellstr (user_inputs);
+   endif
+
+endfunction
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/scripts/ui/listdlg.m	Fri Apr 12 14:51:51 2013 -0400
@@ -0,0 +1,142 @@
+## Copyright (C) 2010 Martin Hepperle
+##
+## This file is part of Octave.
+##
+## Octave is free software; you can redistribute it and/or modify it
+## under the terms of the GNU General Public License as published by
+## the Free Software Foundation; either version 3 of the License, or (at
+## your option) any later version.
+##
+## Octave is distributed in the hope that it will be useful, but
+## WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+## General Public License for more details.
+##
+## You should have received a copy of the GNU General Public License
+## along with Octave; see the file COPYING.  If not, see
+## <http://www.gnu.org/licenses/>.
+
+## -*- texinfo -*-
+## @deftypefn {Function File} {[@var{sel}, @var{ok}] =} listdlg (@var{key}, @var{value}, @dots{})
+## Return user inputs from a list dialog box in a vector of 
+## selection indices @var{sel} and a flag @var{ok} indicating how the
+## user closed the dialog box.  The value of @var{ok} is 1 if the user
+## closed the box with the OK button, otherwise it is 0 and @var{sel} is
+## empty.
+##
+## The indices in @var{sel} are 1-based.
+##
+## The arguments are specified in form of @var{key}, @var{value} pairs. 
+## The "ListString" argument pair must be specified.
+##
+## Valid @var{key} and @var{value} pairs are:
+##
+## @table @asis
+## @item "ListString"
+## a cell array of strings comprising the content of the list.
+##
+## @item "SelectionMode"
+## can be either "Single" or "Multiple" (default).
+##
+## @item "ListSize"
+## a vector with two elements @var{width} and @var{height} defining
+## the size of the list field in pixels.  Default is [160 300].
+##
+## @item "InitialValue"
+## a vector containing 1-based indices of preselected elements.  Default
+## is 1 (first item).
+##
+## @item "Name"
+## a string to be used as the dialog caption.  Default is "".
+##
+## @item "PromptString"
+## a cell array of strings to be displayed above the list field.  Default
+## is @{@}.
+##
+## @item "OKString"
+## a string used to label the OK button.  Default is "OK".
+##
+## @item "CancelString"
+## a string used to label the Cancel button.  Default is "Cancel".
+## @end table
+##
+## Example:
+##
+## @example
+## @group
+## [sel, ok] = listdlg ("ListString", @{"An item", "another", "yet another"@},
+##                      "SelectionMode", "Multiple");
+## if (ok == 1)
+##   for i = 1:numel (sel)
+##     disp (sel(i));
+##   endfor
+## endif
+## @end group
+## @end example
+##
+## @seealso{errordlg, helpdlg, inputdlg, msgbox, questdlg, warndlg}
+## @end deftypefn
+
+function varargout = listdlg (varargin)
+
+   if (nargin < 2)
+     print_usage ();
+   endif
+   
+   listcell = {""};
+   selmode = "multiple";
+   listsize = [160, 300];
+   initialvalue = 1;
+   name = "";
+   prompt = {""};
+   okstring = "OK";
+   cancelstring = "Cancel";
+   
+   ## handle key, value pairs
+   for i = 1:2:nargin-1
+     if strcmp (varargin{i}, "ListString")
+       listcell = varargin{i+1};
+     elseif strcmp (varargin{i}, "SelectionMode")
+       selmode = varargin{i+1};
+     elseif strcmp (varargin{i}, "ListSize")
+       listsize = varargin{i+1};
+     elseif strcmp (varargin{i}, "InitialValue")
+       initialvalue = varargin{i+1};
+     elseif strcmp (varargin{i}, "Name")
+       name = varargin{i+1};
+     elseif strcmp (varargin{i}, "PromptString")
+       prompt = varargin{i+1};
+     elseif strcmp (varargin{i}, "OKString")
+       okstring = varargin{i+1};
+     elseif strcmp (varargin{i}, "CancelString")
+       cancelstring = varargin{i+1};
+     endif
+   endfor
+
+   ## make sure prompt strings are a cell array
+   if (! iscell (prompt))
+     prompt = {prompt};
+   endif
+
+   ## make sure listcell strings are a cell array
+   if (! iscell (listcell))
+     listcell = {listcell};
+   endif
+   
+   ## transform matrices to cell arrays of strings
+   ## swap width and height to correct calling format for JDialogBox
+   listsize = {num2str(listsize(2)), num2str(listsize(1))};
+   initialvalue = arrayfun (@num2str, initialvalue, "UniformOutput", false);
+   
+   ret = javaMethod ("listdlg", "org.octave.JDialogBox", listcell,
+                      selmode, listsize, initialvalue, name, prompt,
+                      okstring, cancelstring);
+
+   if (numel (ret) > 0)
+     varargout = {ret, 1};
+   else
+     varargout = {{}, 0};
+   endif
+
+endfunction
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/scripts/ui/module.mk	Fri Apr 12 14:51:51 2013 -0400
@@ -0,0 +1,16 @@
+FCN_FILE_DIRS += ui
+
+ui_FCN_FILES = \
+  ui/errordlg.m \
+  ui/helpdlg.m \
+  ui/inputdlg.m \
+  ui/listdlg.m \
+  ui/msgbox.m \
+  ui/questdlg.m \
+  ui/warndlg.m
+
+FCN_FILES += $(ui_FCN_FILES)
+
+PKG_ADD_FILES += ui/PKG_ADD
+
+DIRSTAMP_FILES += ui/$(octave_dirstamp)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/scripts/ui/msgbox.m	Fri Apr 12 14:51:51 2013 -0400
@@ -0,0 +1,76 @@
+## Copyright (C) 2010 Martin Hepperle
+##
+## This file is part of Octave.
+##
+## Octave is free software; you can redistribute it and/or modify it
+## under the terms of the GNU General Public License as published by
+## the Free Software Foundation; either version 3 of the License, or (at
+## your option) any later version.
+##
+## Octave is distributed in the hope that it will be useful, but
+## WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+## General Public License for more details.
+##
+## You should have received a copy of the GNU General Public License
+## along with Octave; see the file COPYING.  If not, see
+## <http://www.gnu.org/licenses/>.
+
+## -*- texinfo -*-
+## @deftypefn  {Function File} {@var{h} =} msgbox (@var{msg})
+## @deftypefnx {Function File} {@var{h} =} msgbox (@var{msg}, @var{title})
+## @deftypefnx {Function File} {@var{h} =} msgbox (@var{msg}, @var{title}, @var{icon})
+## Display @var{msg} using a message dialog box. 
+##
+## 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 input @var{title} (character string) can be used to
+## decorate the dialog caption.
+##
+## The optional argument @var{icon} selects a dialog icon. 
+## It can be one of @code{"none"} (default), @code{"error"}, @code{"help"}, or
+## @code{"warn"}.
+##
+## The return value is always 1.
+## @seealso{errordlg, helpdlg, inputdlg, listdlg, questdlg, warndlg}
+## @end deftypefn
+
+function h = msgbox (msg, title = "", icon)
+
+  if (nargin < 1 || nargin > 3)
+    print_usage ();
+  endif
+
+  if (! ischar (msg))
+    if (iscell (msg))
+      msg = sprintf ("%s\n", msg{:});
+      msg(end) = "";
+    else
+      error ("msgbox: MSG must be a character string or cellstr array");
+    endif
+  endif
+
+  if (! ischar (title))
+    error ("msgbox: TITLE must be a character string");
+  endif
+  
+  dlg = "emptydlg";
+  if (nargin == 3)
+    switch (icon)
+      case "error"
+        dlg = "errordlg";
+      case "help"
+        dlg = "helpdlg";
+      case "warn"
+        dlg = "warndlg";
+      case "none"
+        dlg = "emptydlg";
+      otherwise
+        error ("msgbox: ICON is not a valid type");
+    endswitch
+  endif
+
+  h = javaMethod (dlg, "org.octave.JDialogBox", msg, title);
+
+endfunction
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/scripts/ui/questdlg.m	Fri Apr 12 14:51:51 2013 -0400
@@ -0,0 +1,101 @@
+## Copyright (C) 2010 Martin Hepperle
+##
+## This file is part of Octave.
+##
+## Octave is free software; you can redistribute it and/or modify it
+## under the terms of the GNU General Public License as published by
+## the Free Software Foundation; either version 3 of the License, or (at
+## your option) any later version.
+##
+## Octave is distributed in the hope that it will be useful, but
+## WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+## General Public License for more details.
+##
+## You should have received a copy of the GNU General Public License
+## along with Octave; see the file COPYING.  If not, see
+## <http://www.gnu.org/licenses/>.
+
+## -*- texinfo -*-
+## @deftypefn  {Function File} {@var{btn} =} questdlg (@var{msg})
+## @deftypefnx {Function File} {@var{btn} =} questdlg (@var{msg}, @var{title})
+## @deftypefnx {Function File} {@var{btn} =} questdlg (@var{msg}, @var{title}, @var{default})
+## @deftypefnx {Function File} {@var{btn} =} questdlg (@var{msg}, @var{title}, @var{btn1}, @var{btn2}, @var{default})
+## @deftypefnx {Function File} {@var{btn} =} 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.
+##
+## The dialog may contain two or three buttons which will all close the dialog.
+##
+## The message may have multiple lines separated by newline characters
+## ("\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 @key{ENTER} key.
+## It must match one of the strings given in @var{btn1}, @var{btn2}, or
+## @var{btn3}.
+##
+## If only @var{msg} and @var{title} are specified, three buttons with
+## the default captions "Yes", "No", and "Cancel" are used.
+##
+## 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
+
+function btn = questdlg (msg, title = "Question Dialog", varargin)
+
+  if (nargin < 1 || nargin > 6)
+    print_usage ();
+  endif
+  
+  if (! ischar (msg))
+    if (iscell (msg))
+      msg = sprintf ("%s\n", msg{:});
+      msg(end) = "";
+    else
+      error ("questdlg: MSG must be a character string or cellstr array");
+    endif
+  endif
+
+  if (! ischar (title))
+    error ("questdlg: TITLES must be a character string");
+  endif
+
+  options{1} = "Yes";      # button1
+  options{2} = "No";       # button2
+  options{3} = "Cancel";   # button3
+  options{4} = "Yes";      # default
+
+  switch (numel (varargin))
+    case 1
+      ## default button string
+      options{4} = varargin{1};  # default
+
+    case 3
+      ## two buttons and default button string
+      options{1} = varargin{1};  # button1
+      options{2} = "";           # not used, no middle button
+      options{3} = varargin{2};  # button3
+      options{4} = varargin{3};  # default
+
+    case 4
+      ## three buttons and default button string
+      options{1} = varargin{1};  # button1
+      options{2} = varargin{2};  # button2
+      options{3} = varargin{3};  # button3
+      options{4} = varargin{4};  # default
+
+    otherwise
+      print_usage ();
+
+  endswitch
+
+  btn = javaMethod ("questdlg", "org.octave.JDialogBox", msg,
+                     title, options);
+
+endfunction
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/scripts/ui/warndlg.m	Fri Apr 12 14:51:51 2013 -0400
@@ -0,0 +1,54 @@
+## Copyright (C) 2010 Martin Hepperle
+##
+## This file is part of Octave.
+##
+## Octave is free software; you can redistribute it and/or modify it
+## under the terms of the GNU General Public License as published by
+## the Free Software Foundation; either version 3 of the License, or (at
+## your option) any later version.
+##
+## Octave is distributed in the hope that it will be useful, but
+## WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+## General Public License for more details.
+##
+## You should have received a copy of the GNU General Public License
+## along with Octave; see the file COPYING.  If not, see
+## <http://www.gnu.org/licenses/>.
+
+## -*- texinfo -*-
+## @deftypefn  {Function File} {@var{h} =} warndlg (@var{msg})
+## @deftypefnx {Function File} {@var{h} =} warndlg (@var{msg}, @var{title})
+## Display @var{msg} using a warning dialog box. 
+##
+## The message may have multiple lines separated by newline characters
+## ("\n"), or it may be a cellstr array with one element for each
+## line.  The optional input @var{title} (character string) can be used to
+## set the dialog caption.  The default title is "Warning Dialog".
+##
+## @seealso{helpdlg, inputdlg, listdlg, questdlg}
+## @end deftypefn
+
+function retval = warndlg (msg, title = "Warning Dialog")
+
+  if (nargin < 1 || nargin > 2)
+    print_usage ();
+  endif
+
+  if (! ischar (msg))
+    if (iscell (msg))
+      msg = sprintf ("%s\n", msg{:});
+      msg(end) = "";
+    else
+      error ("warndlg: MSG must be a string or cellstr array");
+    endif
+  endif
+
+  if (! ischar (title))
+    error ("warndlg: TITLE must be a character string");
+  endif
+
+  retval = javaMethod ("warndlg", "org.octave.JDialogBox", msg, title);
+
+endfunction
+