www.gusucode.com > mbctools 工具箱 matlab 源码程序 > mbctools/@xregtools/@MBrowser/doEnableStatus.m

    function doEnableStatus(h)
% DOENABLESTATUS  Update enable setting of Mbrowser objects
%
%   doEnableStatus(h)
%

%  Copyright 2000-2016 The MathWorks, Inc. and Ford Global Technologies, Inc.


p=h.getViewedNode;

% Menus
supp=p.MBsupport(h.DefaultSupport);

menus=h.Hand.Menubar;
tools=h.Hand.Toolbar.buttons;

hndls=[menus.NewX;
   menus.Export;
   menus.Print; 
   menus.DeleteY;
   menus.TidyTree];
tbhndls = [tools(6);
    tools(5);
    tools(7);
    tools(8)];
   
en=repmat({'off'},length(hndls),1);
tben = {'off';'off';'off';'off'};

if supp.newmodel
   en(1)={'on'};
   tben{1} = 'on';
end
if supp.export
   en{2}='on';
end
if supp.print
   en{3}='on';
   tben{2} = 'on';
end
if p.Parent~=0
   en{4}='on';   % delete and move up
   tben(3:4) = {'on'};
end
if ~isempty(p.children)
   en{5}='on';
end


set(hndls,{'Enable'},en);
set(h.ContextMenus.NewMenus,'Enable',en{1});
set(h.ContextMenus.DeleteMenus,'Enable',en{5});

h.Hand.Toolbar.MainBar.setRedraw(false);
set(tbhndls, {'Enable'}, tben);
h.Hand.Toolbar.MainBar.setRedraw(true);
h.Hand.Toolbar.MainBar.drawToolBar;