# HG changeset patch # User Rik # Date 1428765522 25200 # Node ID 98d10871018ac1fbfd03ff757bc3ecbca5949e78 # Parent d7f7ce99532b2b15170bf0fbd824c58e7c5dd007 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. diff -r d7f7ce99532b -r 98d10871018a scripts/gui/errordlg.m --- 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 diff -r d7f7ce99532b -r 98d10871018a scripts/gui/msgbox.m --- 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 diff -r d7f7ce99532b -r 98d10871018a scripts/gui/private/message_dialog.m --- 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 @@ ## . ## -*- 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")) diff -r d7f7ce99532b -r 98d10871018a scripts/gui/warndlg.m --- 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