www.gusucode.com > mbcguitools 工具箱 matlab 源码程序 > mbcguitools/@xregGui/@MBCToolbar/notifyAddition.m

    function notifyAddition(obj, but)
%NOTIFYADDITION Notify toolbar of button addition
%
%  NOTIFYADDITION(OBJ, BUT) notifies OBJ that the button BUT has been added
%  to the toolbar.

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


obj.Children = [obj.Children; but];
but.connect(obj, 'up');

obj.ButtonVisCache = [obj.ButtonVisCache, strcmp(but.Visible, 'on')];
obj.ButtonSepCache = [obj.ButtonSepCache, strcmp(but.Separator, 'on')];

if obj.ButtonVisCache(end)
    if obj.ButtonSepCache(end)
        if isempty(obj.ButtonEdges)
            obj.ButtonEdges = [10 9+but.pGetWidth];
        else
            obj.ButtonEdges = [obj.ButtonEdges; ...
                    obj.ButtonEdges(end)+7, obj.ButtonEdges(end)+6+but.pGetWidth];
        end
    else
        if isempty(obj.ButtonEdges)
            obj.ButtonEdges = [6 5+but.pGetWidth];
        else
            obj.ButtonEdges = [obj.ButtonEdges; ...
                    obj.ButtonEdges(end)+1, obj.ButtonEdges(end)+but.pGetWidth];
        end
    end
    
    % Update the common button height
    obj.pUpdateHeight(but, 'added');
    
    if obj.DrawingEnabled
        % Update the number of buttons to render
        obj.NButtonsToRender = obj.pNumberOfButtonsToRender(obj.hToolbarInterface.Position);
    end
else
    if isempty(obj.ButtonEdges)
        obj.ButtonEdges = [5 5];
    else
        obj.ButtonEdges = [obj.ButtonEdges; ...
                obj.ButtonEdges(end), obj.ButtonEdges(end)];
    end
end