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

    function nButtons = pNumberOfButtonsToRender(obj, posRect)
%PNUMBEROFBUTTONSTORENDER Calculate how many buttons can currently be rendered
%
%  NBUTTONS = PNUMBEROFBUTTONSTORENDER(OBJ, POSRECT) returns the number of
%  buttons that can be completely rendered using the current setup of the
%  toolbar.

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


ch = obj.Children;

if isempty(ch)
    nButtons = 0;
else
    nButtons = length(ch);
    for n = 1:nButtons
        if obj.ButtonEdges(n,2)>(posRect(3)-7)
            nButtons = n-1;
            break
        end
    end
    if nButtons>0 && nButtons<length(ch)
        % Need to ensure there is enough room to render a "more buttons are
        % hidden" marker at the right hand edge
        if (posRect(3)-7-obj.ButtonEdges(nButtons,2)) < 9
            nButtons = nButtons - 1;    
        end
    end
end