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-98 by The MathWorks, Inc.
%  $Revision: 1.7 $  $Date: 1997/11/21 23:49:13 $

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

elseif (nargin == 1)
  warning('PRINTMENU is OBSOLETE and may be removed in future versions.');

  % 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
