changeset 20071:98d10871018a

Accept CREATEMODE argument for errordlg, warndlg, msgbox (bug #44775). * errordlg.m: Update docstring. Use varargin to pass extra argument to msg_box. * warndlg.m: Update docstring. Use varargin to pass extra argument to msg_box. * msgbox.m: Update docstring. * message_dialog.m: Issue warning if unimplemented CREATEMODE argument given. Issue warning if icon type "custom" is used.
author Rik <rik@octave.org>
date Sat, 11 Apr 2015 08:18:42 -0700
parents d7f7ce99532b
children 8e42898f4d73
files scripts/gui/errordlg.m scripts/gui/msgbox.m scripts/gui/private/message_dialog.m scripts/gui/warndlg.m
diffstat 4 files changed, 42 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/scripts/gui/errordlg.m	Sat Apr 11 14:07:51 2015 +0900
+++ b/scripts/gui/errordlg.m	Sat Apr 11 08:18:42 2015 -0700
@@ -19,6 +19,7 @@
 ## -*- texinfo -*-
 ## @deftypefn  {Function File} {@var{h} =} errordlg (@var{msg})
 ## @deftypefnx {Function File} {@var{h} =} errordlg (@var{msg}, @var{title})
+## @deftypefnx {Function File} {@var{h} =} errordlg (@var{msg}, @var{title}, @var{createmode})
 ## Display @var{msg} using an error dialog box.
 ##
 ## The message may have multiple lines separated by newline characters
@@ -27,16 +28,20 @@
 ## set the dialog caption.  The default title is @qcode{"Error Dialog"}.
 ##
 ## The return value is always 1.
+##
+## Compatibility Note: The optional argument @var{createmode} is accepted for
+## @sc{matlab} compatibility, but is not implemented.
+##
 ## @seealso{helpdlg, inputdlg, listdlg, msgbox, questdlg, warndlg}
 ## @end deftypefn
 
-function retval = errordlg (msg, title = "Error Dialog")
+function retval = errordlg (msg, title = "Error Dialog", varargin)
 
-  if (nargin < 1 || nargin > 2)
+  if (nargin < 1 || nargin > 3)
     print_usage ();
   endif
 
-  retval = message_dialog ("errdlg", msg, title, "error");
+  retval = message_dialog ("errordlg", msg, title, "error", varargin{:});
 
 endfunction
 
--- a/scripts/gui/msgbox.m	Sat Apr 11 14:07:51 2015 +0900
+++ b/scripts/gui/msgbox.m	Sat Apr 11 08:18:42 2015 -0700
@@ -20,10 +20,11 @@
 ## @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})
+## @deftypefnx {Function File} {@var{h} =} msgbox (@dots{}, @var{createmode})
 ## Display @var{msg} using a message dialog box.
 ##
 ## The message may have multiple lines separated by newline characters
-## (@qcode{"\n"}), or it may be a cellstr array with one element for each
+## ("\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.
 ##
@@ -32,12 +33,16 @@
 ## @qcode{"help"}, or @qcode{"warn"}.
 ##
 ## The return value is always 1.
+##
+## Compatibility Note: The optional argument @var{createmode} is accepted for
+## @sc{matlab} compatibility, but is not implemented.
+#
 ## @seealso{errordlg, helpdlg, inputdlg, listdlg, questdlg, warndlg}
 ## @end deftypefn
 
 function retval = msgbox (msg, title = "", varargin)
 
-  if (nargin < 1 || nargin > 3)
+  if (nargin < 1 || nargin > 4)
     print_usage ();
   endif
 
--- a/scripts/gui/private/message_dialog.m	Sat Apr 11 14:07:51 2015 +0900
+++ b/scripts/gui/private/message_dialog.m	Sat Apr 11 08:18:42 2015 -0700
@@ -17,11 +17,11 @@
 ## <http://www.gnu.org/licenses/>.
 
 ## -*- texinfo -*-
-## @deftypefn {Function File} {@var{h} =} message_dialog (@var{caller}, @var{msg}, @var{title}, @var{icon})
+## @deftypefn {Function File} {@var{h} =} message_dialog (@var{caller}, @var{msg}, @var{title}, @var{icon}, @var{createmode})
 ## Undocumented internal function.
 ## @end deftypefn
 
-function retval = message_dialog (caller, msg, title = "", icon)
+function retval = message_dialog (caller, msg, title = "", icon, createmode)
 
   if (! ischar (msg))
     if (iscell (msg))
@@ -37,7 +37,7 @@
   endif
 
   dlg = "emptydlg";
-  if (nargin == 4)
+  if (nargin >= 4)
     switch (icon)
       case "error"
         dlg = "errordlg";
@@ -47,6 +47,9 @@
         dlg = "warndlg";
       case "none"
         dlg = "emptydlg";
+      case "custom"
+        icon = "emptydlg";
+        warning ("%s: custom icons not yet supported", caller);
       otherwise
         error ("%s: ICON is not a valid type", caller);
     endswitch
@@ -54,6 +57,18 @@
     icon = "none";
   endif
 
+  if (nargin == 5)
+    if ((isstruct (createmode)) && (isfield (createmode, "WindowStyle")))
+      createmode = createmode.WindowStyle;
+    endif
+    switch (createmode)
+      case {"nonmodal", "non-modal", "modal", "replace"}
+        warning ("%s: %s is not yet supported", caller, createmode);
+      otherwise
+        error ("%s: CREATEMODE is not a valid type", caller);
+    endswitch
+  endif
+  
   if (__octave_link_enabled__ ())
     retval = __octave_link_message_dialog__ (icon, msg, title);
   elseif (__have_feature__ ("JAVA"))
--- a/scripts/gui/warndlg.m	Sat Apr 11 14:07:51 2015 +0900
+++ b/scripts/gui/warndlg.m	Sat Apr 11 08:18:42 2015 -0700
@@ -19,6 +19,7 @@
 ## -*- texinfo -*-
 ## @deftypefn  {Function File} {@var{h} =} warndlg (@var{msg})
 ## @deftypefnx {Function File} {@var{h} =} warndlg (@var{msg}, @var{title})
+## @deftypefnx {Function File} {@var{h} =} warndlg (@var{msg}, @var{title}, @var{createmode})
 ## Display @var{msg} using a warning dialog box.
 ##
 ## The message may have multiple lines separated by newline characters
@@ -26,16 +27,21 @@
 ## line.  The optional input @var{title} (character string) can be used to
 ## set the dialog caption.  The default title is @qcode{"Warning Dialog"}.
 ##
+## The return value is always 1.
+##
+## Compatibility Note: The optional argument @var{createmode} is accepted for
+## @sc{matlab} compatibility, but is not implemented.
+##
 ## @seealso{helpdlg, inputdlg, listdlg, questdlg}
 ## @end deftypefn
 
-function retval = warndlg (msg, title = "Warning Dialog")
+function retval = warndlg (msg, title = "Warning Dialog", varargin)
 
-  if (nargin < 1 || nargin > 2)
+  if (nargin < 1 || nargin > 3)
     print_usage ();
   endif
 
-  retval = message_dialog ("warndlg", msg, title, "warn");
+  retval = message_dialog ("warndlg", msg, title, "warn", varargin{:});
 
 endfunction