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

    function addFromExtensions(obj, e, ExtName)
%ADDFROMEXTENSIONS Add views from extensions
%
%  ADDFROMEXTENSIONS(OBJ, E, EXTNAME) adds any view definitions that are in
%  the extensions object E, in the property EXTNAME.

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


sData = get(e, ExtName);
nViews = length(sData);
for n = 1:nViews
    sView = sData(n);
    obj.ConstructorFcns = i_getcelldata(sView, 'Constructor', '', obj.ConstructorFcns);
    obj.Labels = i_getcelldata(sView, 'MenuLabel', '', obj.Labels);
    obj.IconFiles = i_getcelldata(sView, 'IconFile', '', obj.IconFiles);
    obj.Descriptions= i_getcelldata(sView, 'Description', '', obj.Descriptions);
    obj.MaxRecommended = i_getnumdata(sView, 'MaxRecommended', inf, obj.MaxRecommended);
end

obj.ViewID = [obj.ViewID, obj.NextViewID:(obj.NextViewID+nViews-1)];
obj.NextViewID = obj.NextViewID + nViews;
obj.NumCreated = [obj.NumCreated, zeros(1, nViews)];
obj.DestructionListeners = [obj.DestructionListeners, cell(1, nViews)];



function data = i_getcelldata(sView, field, defvalue, data)
if isfield(sView, field)
    data = [data, {sView.(field)}];
else
    data = [data, {defvalue}];
end

function data = i_getnumdata(sView, field, defvalue, data)
if isfield(sView, field)
    data = [data, sView.(field)];
else
    data = [data, defvalue];
end