www.gusucode.com > mbcguitools 工具箱 matlab 源码程序 > mbcguitools/@mbcwidgets/@scrollTable/setDataAtRow.m
function setDataAtRow(obj, R, maindata, headdata) %SETDATAATROW Push new data into a single table row % % SETDATAATROW(OBJ, ROW, MAINDATA) sets a new row of data at ROW, and % updates the display object. ROW must be within the current limits of % the main data array. % % SETDATAATROW(OBJ, ROW, MAINDATA, HEADDATA) also sets a new piece of data % into the row header data array. % Copyright 2000-2008 The MathWorks, Inc. and Ford Global Technologies, Inc. if nargin>3 UPDATE_HEADER = true; else UPDATE_HEADER = false; end szD = obj.pGetDataSize; if R<=szD(1) if R==0 error(message('mbc:scrolltable:InvalidIndex3')); elseif length(maindata)~=szD(2) error(message('mbc:scrolltable:InvalidArgument3')); elseif UPDATE_HEADER && obj.pDataIsArray(obj.RowHeaderData) ... && R>length(obj.RowHeaderData) error(message('mbc:scrolltable:InvalidIndex4')); else i_quietsetdata(obj, obj.scrollTable_DataListeners, 'MainData', R, maindata); if UPDATE_HEADER i_quietsetdata(obj, obj.scrollTable_DataListeners, 'RowHeaderData', R, headdata); end if obj.isAlive if (R>=obj.CurrentRow) && (R<(obj.CurrentRow+obj.numRows)) % Repaint display dispR = R-obj.CurrentRow+1; obj.paintObjects(obj.MainObjects(dispR, :), obj.indexData(obj.MainData, R, R, obj.CurrentColumn, obj.CurrentColumn+obj.numCols-1),... R, obj.CurrentColumn); if UPDATE_HEADER && obj.ShowRowHeaders obj.paintObjects(obj.RowHeaderObjects(dispR), obj.indexData(obj.RowHeaderData, R, R), R, 0); end end end end end function i_quietsetdata(obj, L, prop, Ridx, newdata) try tmp = get(obj, prop); set(obj, prop, []); tmp = obj.assignData(tmp, newdata, Ridx, Ridx, 1, size(tmp, 2)); set(obj, prop, tmp); set(L, 'enabled', 'on'); catch ME set(L, 'enabled', 'on'); rethrow(ME); end