4225
|
1 ## Copyright (C) 2002 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 2, or (at your option) |
|
8 ## 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, write to the Free |
5307
|
17 ## Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA |
|
18 ## 02110-1301, USA. |
4225
|
19 |
|
20 ## -*- texinfo -*- |
|
21 ## @deftypefn {Command} {} close |
6257
|
22 ## @deftypefnx {Command} {} close (@var{n}) |
4225
|
23 ## @deftypefnx {Command} {} close all |
6257
|
24 ## @deftypefnx {Command} {} close all hidden |
4225
|
25 ## Close the plot window(s). |
|
26 ## @end deftypefn |
|
27 |
|
28 ## Author: jwe |
|
29 |
4226
|
30 ## PKG_ADD: mark_as_command close |
4225
|
31 |
|
32 function retval = close (arg1, arg2) |
|
33 |
|
34 if (nargin == 0) |
6278
|
35 ## Close current figure. Don't use gcf because that will open a new |
|
36 ## plot window if one doesn't exist. |
|
37 figs = get (0, "currentfigure"); |
|
38 if (! isempty (figs) && figs == 0) |
|
39 figs = []; |
|
40 endif |
4225
|
41 elseif (nargin == 1) |
6257
|
42 if (ischar (arg1) && strcmp (arg1, "all")) |
|
43 ## Close all figures. |
|
44 figs = __uiobject_figures__ (); |
|
45 elseif (isfigure (arg1)) |
|
46 figs = arg1; |
4225
|
47 else |
6257
|
48 error ("close: expecting argument to be \"all\" or a figure handle"); |
4225
|
49 endif |
|
50 elseif (nargin == 2 |
5443
|
51 && ischar (arg1) && strcmp (arg1, "all") |
|
52 && ischar (arg2) && strcmp (arg2, "hidden")) |
6257
|
53 figs = __uiobject_figures__ (); |
4225
|
54 else |
6046
|
55 print_usage (); |
4225
|
56 endif |
|
57 |
6257
|
58 for h = figs |
|
59 set (0, "currentfigure", h); |
|
60 feval (get (h, "closerequestfcn")); |
|
61 endfor |
|
62 |
4225
|
63 if (nargout > 0) |
|
64 retval = 1; |
|
65 endif |
|
66 |
|
67 endfunction |