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

    function pPerformRestack(obj, fH, FORCE)
%PPERFORMRESTACK Restack the figure's canvas axes
%
%  PPERFORMRESTACK(OBJ, FIG) will push the background and mid axes to the
%  bottom of the figure's children stack if the figure is visible.  If the
%  figure is invisible, the ChildAdded listener will be converted to a
%  pre-set listener on the figure's visible property.  This has the effect
%  of compressing multiple child-adds into a single restack.

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


% search for figure in known list
FIGi = [];
if ~isempty(obj.Figures)
    FIGi = (fH==obj.Figures);
end

% FORCE flag lets you force a restack now
if nargin<3
    FORCE = false;
end

if any(FIGi)
    if ~FORCE && strcmp(get(fH, 'Visible'), 'off')
        obj.BGAxesList{FIGi} = mbcgui.hgclassesutil.proplistener(fH, 'Visible', ...
            'PostSet', mbcutils.callback(@i_dorestack, obj));
    else
        % Make sure the mid and bg axes are at the bottom of the child list
        c = allchild(fH);
        hMid = obj.MidAxes(FIGi);
        hBG = obj.BGAxes(FIGi);
        if c(end)~=hBG || c(end-1)~=hMid 
            c(c==hBG) = [];
            c(c==hMid) = [];
            set(fH, 'Children', [c; hMid; hBG]);
        end
    end
end



function i_dorestack(src, evt, obj)
% Force a restack
obj.pPerformRestack(evt.AffectedObject, true);

% Reconnect to ChildAdded event on figure
obj.pConnectToChildAdded(evt.AffectedObject);