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 |
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) |
6257
|
44 if (ischar (arg1) && strcmp (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 |
5443
|
52 && ischar (arg1) && strcmp (arg1, "all") |
|
53 && ischar (arg2) && strcmp (arg2, "hidden")) |
6405
|
54 close_all_figures (true); |
4225
|
55 else |
6046
|
56 print_usage (); |
4225
|
57 endif |
|
58 |
6257
|
59 for h = figs |
|
60 set (0, "currentfigure", h); |
|
61 feval (get (h, "closerequestfcn")); |
|
62 endfor |
|
63 |
4225
|
64 if (nargout > 0) |
|
65 retval = 1; |
|
66 endif |
|
67 |
|
68 endfunction |
6405
|
69 |
|
70 function close_all_figures (close_hidden_figs) |
|
71 |
|
72 while (! isempty (fig = get (0, "currentfigure"))) |
|
73 ## handlevisibility = get (fig, "handlevisibility") |
|
74 ## if (close_hidden_figs || ! strcmp (handlevisibility, "off")) |
|
75 close (fig); |
|
76 ## endif |
|
77 endwhile |
|
78 |
|
79 endfunction |