www.gusucode.com > mbcguitools 工具箱 matlab 源码程序 > mbcguitools/+mbcgui/+motion/ContainerMotionManager.m
classdef ContainerMotionManager < mbcgui.motion.MotionManager %mbcgui.motion.ContainerMotionManager abstract class % mbcgui.motion.ContainerMotionManager extends mbcgui.motion.MotionManager. % % mbcgui.motion.PanelMotionManager properties: % Figure - Property is of type 'MATLAB array' % Mode - Property is of type 'string' % Enable - Property is of type 'on/off' % MouseMoveFcn - Property is of type 'MATLAB callback' % MouseInFcn - Property is of type 'MATLAB callback' % MouseOutFcn - Property is of type 'MATLAB callback' % EnableTree - Property is of type 'bool' % Region - Property is of type 'rect' % UseExternalRef - Property is of type 'on/off' % ExternalRef - Property is of type 'MATLAB array' % Handle - Property is of type 'MATLAB array' % % mbcgui.motion.ContainerMotionManager methods: % AttachToPanel - Attach Motion Manager to uipanel % ExecuteMovement - Execute MotionManager callbacks % enableManager - determine whether to enable manager % % See also PanelMotionManager, TabMotionManager, TabGroupMotionManager % Copyright 2000-2016 The MathWorks, Inc. and Ford Global Technologies, Inc. properties (SetAccess=protected) %Handle Property is of type 'MATLAB array' Handle end properties (Access=protected) %PMMLISTENERS Property is of type 'MATLAB array' PMMListeners end methods % constructor block function obj = ContainerMotionManager(varargin) %ContainerMotionManager Window Motion management class % OBJ = mbcgui.motion.ContainerMotionManager (PROP, VALUE, ...) % Call superclass constructor obj@mbcgui.motion.MotionManager(varargin{ : }); % converted super class constructor call end % PanelMotionManager end % constructor block methods % public methods %---------------------------------------- function AttachToPanel(obj, hPanel) %ATTACHTOPANEL Attach Motion Manager to container % ATTACHTOPANEL(OBJ, P) attaches OBJ to the container P. if ~isgraphics(hPanel, 'uipanel') && ~isgraphics(hPanel, 'uitab') && ~isgraphics(hPanel, 'uitabgroup') error(message('mbc:xregGui:MotionManager:InvalidHandle1')); end if ~isprop(hPanel,'MotionManagerStore') mbcgui.hgclassesutil.addprop(hPanel, 'MotionManagerStore'); end set(hPanel,'MotionManagerStore',obj); obj.Handle = hPanel; obj.Figure = ancestor(hPanel,'figure'); % Set region to match panel's position set(obj, 'UseExternalRef', 'on', 'ExternalRef', hPanel); % Listeners: createContainerListeners(obj) % Attach to MotionManager in panel's parent MParent = MotionManager(get(hPanel, 'Parent')); MParent.RegisterManager(obj); % enable based on parent enabled and the panel state obj.Enable = mbconoff(isParentEnabled(MParent) && enableManager(obj) && strcmp(obj.UserEnabled,'on')); end % AttachToPanel %---------------------------------------- function ExecuteMovement(obj,~, evt) %EXECUTEMOVEMENT Execute MotionManager callbacks % EXECUTEMOVEMENT(OBJ, src,EVENTDATA) is the function that responds to a % MouseMove event on the object. This method is overridden to adjust the % event coordinates before dispatching to sub-MotionManagers. % Adjust coordinate system of event data to match the region of this object evt.CurrentPoint = evt.CurrentPoint - [obj.getXmin obj.getYmin] + 1; % Add a further adjustment to take account of uipanel borders Delta = calculateDelta(obj); evt.CurrentPoint = evt.CurrentPoint - Delta; % Call superclass ExecuteMovement@mbcgui.motion.MotionManager(obj,[],evt); end % ExecuteMovement end % public methods methods (Abstract) %enableManager specify conditions required to enable the %MotionManager. This may be requiring that a component is visible %or a tab is selected. en = enableManager(obj) end methods (Abstract,Access=protected) %createContainerListeners create listeners to container properties %or state so that the MotionManager state can be updated. createContainerListeners(obj) end methods (Access=protected) function onDeletePanel(obj,~,~) Parent = obj.Parent; if ~isempty(Parent); Parent.UnregisterManager(obj); end end function Delta = calculateDelta(obj) %#ok<MANU> %calculateDelta no offset required Delta = 0; end end end % classdef