www.gusucode.com > mbcguitools 工具箱 matlab 源码程序 > mbcguitools/@mbcwidgets/@abstractcomponent/abstractcomponent.m
function obj = abstractcomponent(varargin) %ABSTRACTCOMPONENT constructor for the abstractcomponent object % % OBJ = ABSTRACTCOMPONENT % OBJ = ABSTRACTCOMPONENT(OBJ) % OBJ = ABSTRACTCOMPONENT('Property', Value) % % Copyright 2000-2006 The MathWorks, Inc. and Ford Global Technologies, Inc. if nargin && isa(varargin{1}, 'mbcwidgets.abstractcomponent') obj = varargin{1}; varargin(1) = []; else obj = mbcwidgets.abstractcomponent; end % Allow property, value pairs to be passed into constructor if length(varargin) set(obj, varargin{:}); end % Ensure we have a parent to attach our view to (usually we expect it will % be passed in to the constructor hence appear from the above set % statement) if isempty(obj.Parent) obj.Parent = gcf; end % Setup basic listeners for properties and destruction % Need to setup the deletion listeners obj.ComponentListeners = [ ... handle.listener(obj, 'ObjectBeingDestroyed', @pObjectBeingDestroyed); ... handle.listener(obj, obj.findprop('Parent'), 'PropertyPostSet', @pPostSetParent); ... handle.listener(obj, obj.findprop('Position'), 'PropertyPostSet', @pPostSetPosition); ... handle.listener(obj, obj.findprop('Visible'), 'PropertyPostSet', @pPostSetVisible); ... handle.listener(obj, obj.findprop('Enable'), 'PropertyPostSet', @pPostSetEnable); ... ]; % Ensure that the calls goes to this object set(obj.ComponentListeners, 'CallbackTarget', obj); % Ensure that when the parent object is destroyed this object is destroyed % by linking in an HG chain obj.connect(xregfigurehook(obj.Parent),'up');