function print_heirarchy(show_hidden,h,s,i_am_last)
%PRINT_HEIRARCHY  Show the Matlab GUI object heirarchy
%
% No arguments are required.  Use print_heirarchy(1) to see even
% the hidden objects.
%
% Tobin Fricke 2002-07-16 <tobin@splorg.org>
% Weizmann Institute of Science, Rehovot, Israel
%
% $Id: print_heirarchy.m,v 1.3 2002/07/16 19:58:00 tobin Exp $

if nargin<4,
  i_am_last = 1;
  if nargin<3,
    s = '';
    if nargin<2,
      h = 0;
      if nargin<1,
	show_hidden = 0;
      end
    end
  end
end

if i_am_last,
  disp([s '\--' get(h,'type')]); 
else
  disp([s '+--' get(h,'type')]);
end

if show_hidden,
  children = allchild(h);
else
  children = get(h,'children');
end

for n=1:length(children),
  x = children(n);

  i_will_be_last = (n == length(children));
  
  if i_am_last,
    print_heirarchy(show_hidden,x,[s '   '],i_will_be_last);
  else
    print_heirarchy(show_hidden,x,[s '|   '], i_will_be_last);
  end
end
	    
 
