1 ## Copyright (C) 2005-2012 John W. Eaton
3 ## This file is part of Octave.
5 ## Octave is free software; you can redistribute it and/or modify it
6 ## under the terms of the GNU General Public License as published by
7 ## the Free Software Foundation; either version 3 of the License, or (at
8 ## your option) any later version.
10 ## Octave is distributed in the hope that it will be useful, but
11 ## WITHOUT ANY WARRANTY; without even the implied warranty of
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 ## General Public License for more details.
15 ## You should have received a copy of the GNU General Public License
16 ## along with Octave; see the file COPYING. If not, see
17 ## <http://www.gnu.org/licenses/>.
20 ## @deftypefn {Function File} {} clf ()
21 ## @deftypefnx {Function File} {} clf ("reset")
22 ## @deftypefnx {Function File} {} clf (@var{hfig})
23 ## @deftypefnx {Function File} {} clf (@var{hfig}, "reset")
24 ## @deftypefnx {Function File} {@var{h} =} clf (@dots{})
25 ## Clear the current figure window. @code{clf} operates by deleting child
26 ## graphics objects with visible handles (@code{handlevisibility} = on).
27 ## If @var{hfig} is specified operate on it instead of the current figure.
28 ## If the optional argument @code{"reset"} is specified, all objects including
29 ## those with hidden handles are deleted.
31 ## The optional return value @var{h} is the graphics handle of the figure
32 ## window that was cleared.
33 ## @seealso{cla, close, delete}
38 function retval = clf (varargin)
43 if (isfigure (varargin{1}) && ischar (varargin{2})
44 && strcmpi (varargin{2}, "reset"))
52 if (isfigure (varargin{1}))
56 elseif (ischar (varargin{1}) && strcmpi (varargin{1}, "reset"))
70 ## Select all the children, including the one with hidden handles.
74 ## Select only the chilren with visible handles.
75 hc = get (hfig, "children");
78 ## Delete the children.
89 %! hf = figure ("visible", "off");
92 %! assert (!isempty (get (gcf, "children")));
93 %! unwind_protect_cleanup
98 %! hf = figure ("visible", "off");
101 %! assert (isempty (get (gcf, "children")));
102 %! unwind_protect_cleanup
104 %! end_unwind_protect