www.gusucode.com > mbclayouts 工具箱 matlab 源码程序 > mbclayouts/@xregsplitlayout/copyobj.m

    function newobj=copyobj(obj,fig)
%COPYOBJ Create a copy of an object in a new figure
%
%  NEWOBJ=COPYOBJ(OBJ,FIG) creates a replica of the object OBJ in the
%  figure FIG.

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


newobj = obj;
newobj.xregcontainer = copyobj(obj.xregcontainer,fig);

% copy graphics objects
newobj.datastore = xregGui.RunTimePointer(obj.datastore.info);
connectdata(newobj, newobj.datastore);

% Copy the dragger and correct the callback
newobj.rsbutton = copyobj(obj.rsbutton,fig);
connectdata(newobj, newobj.rsbutton);

fnhndl = get(newobj.rsbutton,'ButtonDownFcn');
fnhndl{2} = newobj;
set(newobj.rsbutton,'ButtonDownFcn',fnhndl);

% Create a new mouse pointer region
newobj.PointerRegion = mbcgui.motion.MotionManager;
newobj.PointerRegion.ExternalRef = newobj.rsbutton;
newobj.PointerRegion.UseExternalRef = 'on';
newobj.PointerRegion.MouseInFcn= @(h,evt) mousetracker(newobj, 1);
newobj.PointerRegion.MouseOutFcn= @(h,evt) mousetracker(newobj, -1);

if strcmp(get(newobj.rsbutton, 'Visible'), 'on')
    MM = MotionManager(fig);
    MM.RegisterManager(newobj.PointerRegion);
end


% Add a deletion callback for the new object
adddeletecallback(newobj, @i_removeMM);


% Destruction callback that removes the motion manager
function i_removeMM(obj, evt)
MM = MotionManager(get(obj.xregcontainer,'Parent'));
MM.UnregisterManager(obj.PointerRegion);
delete(obj.PointerRegion);