function printmenu(uimh, level)
%PRINTMENU Print pull-down menu structure to the command window.
%	PRINTMENU(FIG) displays the pull-down menu structure in
%	figure FIG as a tree structure in the command window.
%	PRINTMENU displays the pull-down menu of the current
%	figure.

%	Steven L. Eddins, 25 May 1994
%	Copyright (c) 1984-94 by The MathWorks, Inc.
%	$Revision: 1.4 $  $Date: 1995/05/18 15:21:58 $

if (nargin == 0)
  % PRINTMENU
  printmenu(gcf);

elseif (nargin == 1)
  % PRINTMENU(FIG)
  
  uimenu_kids = findobj(get(uimh,'Children'), 'flat', 'Type', 'uimenu');

  for k = length(uimenu_kids):-1:1
    printmenu(uimenu_kids(k), 0);
  end
  
else
  % PRINTMENU(UIMH, LEVEL)
  
  label = get(uimh, 'Label');
  tab = '';
  for k = 1:level
    tab = [tab '\t'];
  end
  format_string = [tab '%s\n'];
  fprintf(1, format_string, label);
  
  uimenu_kids =  get(uimh, 'Children');
  for k = length(uimenu_kids):-1:1
    printmenu(uimenu_kids(k), level+1);
  end
end
