www.gusucode.com > mbcview 工具箱matlab源码程序 > mbcview/@cgtools/@cgbrowser/doEnableStatus.m

    function doEnableStatus(h)
%DOENABLESTATUS Update enable status of optional browser services
%
%  DOENABLESTATUS(CGB) updates the enable status of menus and toolbar items
%  that depend on the settings of the current node.

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


if h.GUIExists
    supp = h.getBrowserOptions;
    
    hndls = [];
    tbhndls = [];
    enstatus = {};
    tbenstatus = {};
    
    menus = h.Hand.Menubar;
    tools = h.Hand.Toolbar;
    cmenus = h.ContextMenus;
    
    % Rename items
    hndls = [hndls; menus.Edit.Rename; cmenus.RenameMenus(:)];
    if supp.allowlabeledit
        enstatus = [enstatus; repmat({'on'},length(cmenus.RenameMenus)+1,1)];
    else
        enstatus = [enstatus;repmat({'off'},length(cmenus.RenameMenus)+1,1)];
    end
    
    % Delete items
    hndls = [hndls; menus.Edit.Delete; cmenus.DeleteMenus(:)];
    tbhndls = [tbhndls; tools.buttons.Delete];
    if supp.allowremoval
        enstatus = [enstatus;repmat({'on'},length(cmenus.DeleteMenus)+1,1)];
        tbenstatus = [tbenstatus;{'on'}];
    else
        enstatus = [enstatus;repmat({'off'},length(cmenus.DeleteMenus)+1,1)];
        tbenstatus = [tbenstatus;{'off'}];
    end
    
    % Calibration manager
    hndls = [hndls; menus.Tools.CalManager];
    tbhndls = [tbhndls; tools.buttons.CalManager];
    if supp.calmanager
        enstatus = [enstatus;{'on'}];
        tbenstatus = [tbenstatus;{'on'}];
    else
        enstatus = [enstatus;{'off'}];
        tbenstatus = [tbenstatus;{'off'}];
    end
    
    % create from model tools
    hndls = [hndls; menus.Tools.CreateTables; menus.Tools.CreateOptim];
    tbhndls = [tbhndls; tools.buttons.CreateTables; tools.buttons.CreateOptim];
    if isempty(h.RootNode)|| isnull(h.RootNode) || isempty(h.RootNode.getmodels)
        enstatus = [enstatus;{'off';'off'}];
        tbenstatus = [tbenstatus;{'off';'off'}];
    else
        enstatus = [enstatus;{'on';'on'}];
        tbenstatus = [tbenstatus;{'on';'on'}];
    end
    
    % Surface viewer
    hndls = [hndls; menus.Tools.SurfViewer];
    tbhndls = [tbhndls; tools.buttons.SurfViewer];
    if supp.surfaceviewer
        enstatus = [enstatus;{'on'}];
        tbenstatus = [tbenstatus;{'on'}];
    else
        enstatus = [enstatus;{'off'}];
        tbenstatus = [tbenstatus;{'off'}];
    end
    
    % Duplicate items
    hndls = [hndls; menus.Edit.Duplicate; cmenus.DuplicateMenus(:)];
    if supp.allowduplication
        enstatus = [enstatus;repmat({'on'},length(cmenus.DuplicateMenus)+1,1)];
    else
        enstatus = [enstatus;repmat({'off'},length(cmenus.DuplicateMenus)+1,1)];
    end
    
    set(hndls,{'Enable'},enstatus);
    set(tbhndls, {'Enable'}, tbenstatus);
end