www.gusucode.com > mbcguitools 工具箱 matlab 源码程序 > mbcguitools/@mbcmultiview/@MultiViewPanel/pViewSelected.m

    function pViewSelected(obj)
%PVIEWSELECTED Update object when the selected view changes
%
%  PVIEWSELECTED(OBJ) is called when the selected view is changed.  This
%  method updates the enabled status of actions and puts the view-specific
%  actions in the correct place.

%  Copyright 2005 The MathWorks, Inc. and Ford Global Technologies, Inc.


A = obj.Actions;
hVC = obj.ViewGroup.SelectedViewContainer;
printActions = [A.CopyView; ...
        A.PrintView; ...
        A.PrintViewQuiet; ...
        A.PrintViewPreview];
    
if ~isempty(hVC) && strcmpi(obj.Visible, 'on')
    set(printActions, 'Enabled', hVC.canPrint);
    if obj.AlwaysAllowPrintToFigure
        A.PrintViewFigure.Enabled = true;
    else
        A.PrintViewFigure.Enabled = hVC.canPrint;
    end
    hV = hVC.View;
    A.ViewOptions.Actions = hV.Options;
    A.ViewActions.Actions = hV.Actions;
else
    set(printActions, 'Enabled', false);
    A.PrintViewFigure.Enabled = false;
    A.ViewOptions.Actions = [];
    A.ViewActions.Actions = [];
end

% Check the create action for the currently selected view
AG = A.ChangeView;
idx = obj.getSelectedViewTypeIndex;
sel = false(size(AG.Actions));
if ~isempty(idx) && idx<=length(sel) && idx>0
    sel(idx) = true;
end
set(AG.Actions, {'Selected'}, num2cell(sel(:)));