Mercurial > hg > octave-nkf
diff scripts/plot/close.m @ 6257:44c91c5dfe1d
[project @ 2007-01-30 19:16:52 by jwe]
author | jwe |
---|---|
date | Tue, 30 Jan 2007 19:16:55 +0000 |
parents | 34f96dd5441b |
children | 300fb48803e3 |
line wrap: on
line diff
--- a/scripts/plot/close.m +++ b/scripts/plot/close.m @@ -19,7 +19,9 @@ ## -*- texinfo -*- ## @deftypefn {Command} {} close +## @deftypefnx {Command} {} close (@var{n}) ## @deftypefnx {Command} {} close all +## @deftypefnx {Command} {} close all hidden ## Close the plot window(s). ## @end deftypefn @@ -29,40 +31,31 @@ function retval = close (arg1, arg2) - static warned_all = false; - static warned_name = false; - static warned_handle = false; - if (nargin == 0) - if (! warned_all) - warned_all = true; - warning ("close: unable to close only current plot window"); - endif - closeplot; + ## Close current figure. + figs = gcf (); elseif (nargin == 1) - if (ischar (arg1)) - if (strcmp (arg1, "all")) - closeplot; - else - if (! warned_name) - warned_name = true; - warning ("close: unable to close plot windows by name"); - endif - endif + if (ischar (arg1) && strcmp (arg1, "all")) + ## Close all figures. + figs = __uiobject_figures__ (); + elseif (isfigure (arg1)) + figs = arg1; else - if (! warned_handle) - warned_handle = true; - warning ("close: unable to close plot windows by handle"); - endif + error ("close: expecting argument to be \"all\" or a figure handle"); endif elseif (nargin == 2 && ischar (arg1) && strcmp (arg1, "all") && ischar (arg2) && strcmp (arg2, "hidden")) - closeplot; + figs = __uiobject_figures__ (); else print_usage (); endif + for h = figs + set (0, "currentfigure", h); + feval (get (h, "closerequestfcn")); + endfor + if (nargout > 0) retval = 1; endif