1########################################################################
2##
3## Copyright (C) 2008-2021 The Octave Project Developers
4##
5## See the file COPYRIGHT.md in the top-level directory of this
6## distribution or <https://octave.org/copyright/>.
7##
8## This file is part of Octave.
9##
10## Octave is free software: you can redistribute it and/or modify it
11## under the terms of the GNU General Public License as published by
12## the Free Software Foundation, either version 3 of the License, or
13## (at your option) any later version.
14##
15## Octave is distributed in the hope that it will be useful, but
16## WITHOUT ANY WARRANTY; without even the implied warranty of
17## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18## GNU General Public License for more details.
19##
20## You should have received a copy of the GNU General Public License
21## along with Octave; see the file COPYING.  If not, see
22## <https://www.gnu.org/licenses/>.
23##
24########################################################################
25
26## -*- texinfo -*-
27## @deftypefn  {} {@var{h} =} findall ()
28## @deftypefnx {} {@var{h} =} findall (@var{prop_name}, @var{prop_value}, @dots{})
29## @deftypefnx {} {@var{h} =} findall (@var{prop_name}, @var{prop_value}, "-@var{logical_op}", @var{prop_name}, @var{prop_value})
30## @deftypefnx {} {@var{h} =} findall ("-property", @var{prop_name})
31## @deftypefnx {} {@var{h} =} findall ("-regexp", @var{prop_name}, @var{pattern})
32## @deftypefnx {} {@var{h} =} findall (@var{hlist}, @dots{})
33## @deftypefnx {} {@var{h} =} findall (@var{hlist}, "flat", @dots{})
34## @deftypefnx {} {@var{h} =} findall (@var{hlist}, "-depth", @var{d}, @dots{})
35## Find graphics object, including hidden ones, with specified properties.
36##
37## The return value @var{h} is a list of handles to the found graphic objects.
38##
39## @code{findall} performs the same search as @code{findobj}, but it
40## includes hidden objects (HandleVisibility = @qcode{"off"}).  For full
41## documentation, @pxref{XREFfindobj,,findobj}.
42## @seealso{findobj, allchild, get, set}
43## @end deftypefn
44
45function h = findall (varargin)
46
47  unwind_protect
48    shh = get (0, "showhiddenhandles");
49    set (0, "showhiddenhandles", "on");
50    h = findobj (varargin{:});
51  unwind_protect_cleanup
52    set (0, "showhiddenhandles", shh);
53  end_unwind_protect
54
55endfunction
56
57
58%!test
59%! hf = figure ("visible", "off");
60%! unwind_protect
61%!   h = findall (hf);
62%!   types = {"uitoolbar"};
63%!   htb = uitoolbar (hf);
64%!   types = [types {"uimenu", "uimenu", "uimenu", ...
65%!                   "uimenu", "uimenu", "uimenu"}];
66%!   hm1 = uimenu (hf, "label", "menu1", "handlevisibility", "off");
67%!   uimenu (hm1, "label", "menu1");
68%!   hm2 = uimenu (hf, "label", "menu2", "handlevisibility", "off");
69%!   uimenu (hm2, "label", "menu2");
70%!   hm3 = uimenu (hf, "label", "menu3");
71%!   uimenu (hm3, "label", "menu3");
72%!   types = [types {"uipushtool", "uitoggletool", "uipushtool"}];
73%!   uipushtool (htb, "handlevisibility", "off");
74%!   uitoggletool (htb);
75%!   uipushtool (htb);
76%!   h = setxor (findall (hf), h);
77%!   assert (get (h, "type"), types(:));
78%! unwind_protect_cleanup
79%!   close (hf);
80%! end_unwind_protect
81