changelog shortlog tags changeset files revisions annotate raw

scripts/plot/close.m

changeset 10289: 4b124317dc38
parent:5dd06f19e9be
author: John W. Eaton <jwe@octave.org>
date: Tue Feb 09 20:58:55 2010 -0500 (33 minutes ago)
permissions: -rw-r--r--
description: base_properties::set_children: account for hidden children
1## Copyright (C) 2002, 2005, 2006, 2007, 2008, 2009 John W. Eaton
2##
3## This file is part of Octave.
4##
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.
9##
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.
14##
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/>.
18
19## -*- texinfo -*-
20## @deftypefn {Command} {} close
21## @deftypefnx {Command} {} close (@var{n})
22## @deftypefnx {Command} {} close all
23## @deftypefnx {Command} {} close all hidden
24## Close figure window(s) by calling the function specified by the
25## @code{"closerequestfcn"} property for each figure. By default, the
26## function @code{closereq} is used.
27## @seealso{closereq}
28## @end deftypefn
29
30## Author: jwe
31
32function retval = close (arg1, arg2)
33
34 figs = [];
35
36 if (nargin == 0)
37 ## Close current figure. Don't use gcf because that will open a new
38 ## plot window if one doesn't exist.
39 figs = get (0, "currentfigure");
40 if (! isempty (figs) && figs == 0)
41 figs = [];
42 endif
43 elseif (nargin == 1)
44 if (ischar (arg1) && strcmpi (arg1, "all"))
45 close_all_figures (false);
46 elseif (isfigure (arg1))
47 figs = arg1;
48 else
49 error ("close: expecting argument to be \"all\" or a figure handle");
50 endif
51 elseif (nargin == 2
52 && ischar (arg1) && strcmpi (arg1, "all")
53 && ischar (arg2) && strcmpi (arg2, "hidden"))
54 close_all_figures (true);
55 else
56 print_usage ();
57 endif
58
59 for h = figs
60 __go_execute_callback__ (h, "closerequestfcn");
61 endfor
62
63 if (nargout > 0)
64 retval = 1;
65 endif
66
67endfunction
68
69function close_all_figures (close_hidden_figs)
70
71 while (! isempty (fig = get (0, "currentfigure")))
72 ## handlevisibility = get (fig, "handlevisibility")
73 ## if (close_hidden_figs || ! strcmpi (handlevisibility, "off"))
74 close (fig);
75 ## endif
76 endwhile
77
78endfunction