Mercurial > hg > octave-lyh
annotate scripts/plot/close.m @ 7966:5747be3ac497
Implement closereq as real callback execution
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Tue, 22 Jul 2008 17:23:28 -0400 |
parents | a1dbe9d80eee |
children | 73d6b71788c0 |
rev | line source |
---|---|
7017 | 1 ## Copyright (C) 2002, 2005, 2006, 2007 John W. Eaton |
4225 | 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 | |
7016 | 7 ## the Free Software Foundation; either version 3 of the License, or (at |
8 ## your option) any later version. | |
4225 | 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 | |
7016 | 16 ## along with Octave; see the file COPYING. If not, see |
17 ## <http://www.gnu.org/licenses/>. | |
4225 | 18 |
19 ## -*- texinfo -*- | |
20 ## @deftypefn {Command} {} close | |
6257 | 21 ## @deftypefnx {Command} {} close (@var{n}) |
4225 | 22 ## @deftypefnx {Command} {} close all |
6257 | 23 ## @deftypefnx {Command} {} close all hidden |
6895 | 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} | |
4225 | 28 ## @end deftypefn |
29 | |
30 ## Author: jwe | |
31 | |
4226 | 32 ## PKG_ADD: mark_as_command close |
4225 | 33 |
34 function retval = close (arg1, arg2) | |
35 | |
6405 | 36 figs = []; |
37 | |
4225 | 38 if (nargin == 0) |
6278 | 39 ## Close current figure. Don't use gcf because that will open a new |
40 ## plot window if one doesn't exist. | |
41 figs = get (0, "currentfigure"); | |
42 if (! isempty (figs) && figs == 0) | |
43 figs = []; | |
44 endif | |
4225 | 45 elseif (nargin == 1) |
6257 | 46 if (ischar (arg1) && strcmp (arg1, "all")) |
6405 | 47 close_all_figures (false); |
6257 | 48 elseif (isfigure (arg1)) |
49 figs = arg1; | |
4225 | 50 else |
6257 | 51 error ("close: expecting argument to be \"all\" or a figure handle"); |
4225 | 52 endif |
53 elseif (nargin == 2 | |
5443 | 54 && ischar (arg1) && strcmp (arg1, "all") |
55 && ischar (arg2) && strcmp (arg2, "hidden")) | |
6405 | 56 close_all_figures (true); |
4225 | 57 else |
6046 | 58 print_usage (); |
4225 | 59 endif |
60 | |
6257 | 61 for h = figs |
7966
5747be3ac497
Implement closereq as real callback execution
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
62 __go_execute_callback__ (h, "closerequestfcn"); |
6257 | 63 endfor |
64 | |
4225 | 65 if (nargout > 0) |
66 retval = 1; | |
67 endif | |
68 | |
69 endfunction | |
6405 | 70 |
71 function close_all_figures (close_hidden_figs) | |
72 | |
73 while (! isempty (fig = get (0, "currentfigure"))) | |
74 ## handlevisibility = get (fig, "handlevisibility") | |
75 ## if (close_hidden_figs || ! strcmp (handlevisibility, "off")) | |
76 close (fig); | |
77 ## endif | |
78 endwhile | |
79 | |
80 endfunction |