www.gusucode.com > mbcmodels 工具箱 matlab 源码程序 > mbcmodels/@term_selector/term_selector.m

    function hnd=term_selector(varargin)
%TERM_SELECTOR   Constructor function for term_selector object
%   Constructor function for the term_selector object
%

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




% Use given figure handle or current figure by default (creates one if necessary)
if nargin && mbcgui.util.isComponentParent(varargin{1})
   parent=varargin{1};
   poss=strcmpi(varargin(2:2:length(varargin)),'position');
   ind=1+2*find(poss);
else
   parent=gcf;
   poss=strcmpi(varargin(1:2:length(varargin)),'position');
   ind=2*find(poss);
end

% limit table width to limit damage to memory!
if ~isempty(ind)
   %need to grab out position setting and limit it
   pos=varargin{ind};
   %centre the term selector
   pos(1)=pos(1)+(pos(3)-200).*0.5;
   pos(3)=200;
   varargin(ind)={pos};
else
   %add a limited position set of my own
   pos=[50 50 200 400];
   varargin(end+1)={'position'};
   varargin(end+1)={pos};
end

t=xregtable(varargin{:});
set(t,'cols.size',35,'rows.size',16,'cells.defaultfontsize',8);

ud.model=[];
ud.updatefunction='';
ud.updateparams=[];
ud.killedvis=0;
ud.visible=1;
ud.badim=image('Parent',get(t,'bghandle'),...
   'CData',pr_badim,...
   'XData',[.4 .6],...
   'YData',[.4 .6],...
   'Visible','off',...
   'Clipping','off');

ud.btnrows=[];
ud.chboxrows=[];
ud.chboxstate=[];
ud.termsind=[];
ud.termsbreak=[];
ud.termsbrkstart=[];

t.userdata=ud;
hnd.userdata=[];
hnd=class(hnd,'term_selector',t);

set(t, 'CellChangedCallback', {@iCellEdit, hnd});


function iCellEdit(~, evt, ts)
if evt.Column==1 
    % Check
    checkterms(ts, evt.Row);
elseif evt.Column==4
    % Togglebutton
    toggleterm(ts, evt.Row);
end