www.gusucode.com > mbc 工具箱 matlab 源码程序 > mbc/@mctree/treeview.m
function varargout = treeview(T,Action,varargin) %TREEVIEW Treeview Control from tree % % TVH = TREEVIEW(T,pos,fH,callbacks) % % where: % pos - a length 4 vector specifying position in pixels % fH - figure handle % callbacks - a cell array of strings specifying the event handling % % Copyright 2000-2011 The MathWorks, Inc. and Ford Global Technologies, Inc. if nargout==1 varargout{1}=[]; end switch lower(Action) case 'create' varargout{1}= i_Create(T,varargin{:}); case 'clear' i_Clear(T,varargin{:}); case 'remove' i_Remove(T,varargin{:}); case 'add' i_Add(T,varargin{:}); case 'select' i_Select(T,varargin{:}); case 'icon' i_Icon(T,varargin{:}); case 'replace' i_Replace(T,varargin{:}); case 'refresh' i_Refresh(T,varargin{:}); case 'current' varargout{1}= i_Current(T,varargin{:}); case 'label' i_Label(T,varargin{:}); case 'expand' i_Expand(T,varargin{:}); case 'disable' disable(varargin{1}); case 'enable' enable(varargin{1}); end %---------------------------------------------- function h=i_Create(T,pos,fH,callbacks,MaxLvl,varargin) if nargin<5 MaxLvl=2; end if nargin<4 callbacks={}; end h = mbctreeadapter.MBCTree('Parent',fH,... 'Position',pos,... 'Editable',true,... callbacks{:},... 'IconTransparentColor',[255 0 255],... 'IconLocation',xregrespath); % add nodes to tree refresh(h,address(T),MaxLvl,varargin{:}); %---------------------------------------------- function i_Refresh(T,h,MaxLvl,varargin) if nargin<3 MaxLvl= 2; end refresh(h,address(T),MaxLvl,varargin{:}); %---------------------------------------------- function i_Replace(T,h) p = address(T); remove(h,p); add(h,p) select(h,p) function i_Expand(T,h) p = address(T); expand(h,p); %---------------------------------------------- function i_Clear(T,h) clear(h) %---------------------------------------------- function i_Remove(T,h) remove(h,address(T)); %---------------------------------------------- function i_Add(T,h,MaxLvl) if nargin<3 MaxLvl= Inf; end add(h,address(T),Parent(T),MaxLvl); expand(h,address(T)) %---------------------------------------------- function i_Select(T,h) select(h,address(T)); %---------------------------------------------- function i_Icon(T,h) update(h,address(T)); %---------------------------------------------- function i_Label(T,h) update(h,address(T)); %---------------------------------------------- function p= i_Current(T,h) p= h.Selected;