Mercurial > hg > octave-lyh
annotate scripts/plot/close.m @ 8920:eb63fbe60fab
update copyright notices
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Sat, 07 Mar 2009 10:41:27 -0500 |
parents | 5dd06f19e9be |
children | 95c3e38098bf |
rev | line source |
---|---|
8920 | 1 ## Copyright (C) 2002, 2005, 2006, 2007, 2008, 2009 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 | |
32 function retval = close (arg1, arg2) | |
33 | |
6405 | 34 figs = []; |
35 | |
4225 | 36 if (nargin == 0) |
6278 | 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 | |
4225 | 43 elseif (nargin == 1) |
8190
73d6b71788c0
use case-insensitive comparison for graphics properties; misc style fixes
John W. Eaton <jwe@octave.org>
parents:
7966
diff
changeset
|
44 if (ischar (arg1) && strcmpi (arg1, "all")) |
6405 | 45 close_all_figures (false); |
6257 | 46 elseif (isfigure (arg1)) |
47 figs = arg1; | |
4225 | 48 else |
6257 | 49 error ("close: expecting argument to be \"all\" or a figure handle"); |
4225 | 50 endif |
51 elseif (nargin == 2 | |
8190
73d6b71788c0
use case-insensitive comparison for graphics properties; misc style fixes
John W. Eaton <jwe@octave.org>
parents:
7966
diff
changeset
|
52 && ischar (arg1) && strcmpi (arg1, "all") |
73d6b71788c0
use case-insensitive comparison for graphics properties; misc style fixes
John W. Eaton <jwe@octave.org>
parents:
7966
diff
changeset
|
53 && ischar (arg2) && strcmpi (arg2, "hidden")) |
6405 | 54 close_all_figures (true); |
4225 | 55 else |
6046 | 56 print_usage (); |
4225 | 57 endif |
58 | |
6257 | 59 for h = figs |
7966
5747be3ac497
Implement closereq as real callback execution
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
60 __go_execute_callback__ (h, "closerequestfcn"); |
6257 | 61 endfor |
62 | |
4225 | 63 if (nargout > 0) |
64 retval = 1; | |
65 endif | |
66 | |
67 endfunction | |
6405 | 68 |
69 function close_all_figures (close_hidden_figs) | |
70 | |
71 while (! isempty (fig = get (0, "currentfigure"))) | |
72 ## handlevisibility = get (fig, "handlevisibility") | |
8190
73d6b71788c0
use case-insensitive comparison for graphics properties; misc style fixes
John W. Eaton <jwe@octave.org>
parents:
7966
diff
changeset
|
73 ## if (close_hidden_figs || ! strcmpi (handlevisibility, "off")) |
6405 | 74 close (fig); |
75 ## endif | |
76 endwhile | |
77 | |
78 endfunction |