www.gusucode.com > mbcguitools 工具箱 matlab 源码程序 > mbcguitools/+mbcgui/+widget/@ClassicTable/doSetupCTable.m
function doSetupCTable(obj) %DOSETUPCTABLE Setup listeners % % obj.doSetupCTable % Copyright 2015 The MathWorks, Inc. and Ford Global Technologies, Inc. obj.sharedAxisTable_Listeners = [... event.proplistener(obj, obj.findprop('Border'), 'PostSet', @(h,evt) iSetBorder(h,evt)); ... event.proplistener(obj, obj.findprop('CurrentRow'), 'PostSet', @(h,evt) i_setCurRow(h,evt,obj.vSliderbar)); ... event.proplistener(obj, obj.findprop('CurrentColumn'), 'PostSet', @(h,evt) i_setCurCol(h,evt,obj.hSliderbar)); ... event.proplistener(obj, obj.findprop('ScrollRowLimits'), 'PostSet', @(h,evt) i_setScrRowLims(h,evt,obj.vSliderbar)); ... event.proplistener(obj, obj.findprop('ScrollColumnLimits'), 'PostSet', @(h,evt) i_setScrColLims(h,evt,obj.hSliderbar)); ... event.listener(obj, 'DisplayObjectsChanged', @i_setupGrid); ... event.listener(obj, 'DataSizeChanged', @i_setupGrid); ... event.proplistener(obj, obj.findprop('MinimumCellSize'), 'PostSet', @i_setCellSize); ... event.proplistener(obj, obj.findprop('RowHeaderWidth'), 'PostSet', @(h,evt) i_setRowHeaderWidth(h,evt,obj.gridObject)); ... event.proplistener(obj, obj.findprop('ColumnHeaderWidth'), 'PostSet', @(h,evt) i_setColHeaderWidth(h,evt,obj.gridObject)); ... event.proplistener(obj, obj.findprop('ScrollbarWidth'), 'PostSet', @(h,evt) i_setScrollWidth(h,evt,obj.gridObject)); ... event.proplistener(obj, obj.findprop('RowGap'), 'PostSet', @(h,evt) i_setgap(h,evt,obj.gridObject,'gapy')); ... event.proplistener(obj, obj.findprop('ColumnGap'), 'PostSet', @(h,evt) i_setgap(h,evt,obj.gridObject,'gapx')); ... event.proplistener(obj, obj.findprop('ScrollBarStyle'), 'PostSet', @i_setupGrid_InternalCall); ... event.proplistener(obj, obj.findprop('TopLeftCorner'), 'PostSet', @i_setItemAtTL); ... event.proplistener(obj, obj.findprop('TopRightCorner'), 'PostSet', @i_setItemAtTR); ... event.proplistener(obj, obj.findprop('BottomLeftCorner'), 'PostSet', @i_setItemAtBL); ... event.proplistener(obj, obj.findprop('BottomRightCorner'), 'PostSet', @i_setItemAtBR); ... event.proplistener(obj, obj.findprop('EmptyTableComponent'), 'PostSet', @i_setupGrid_InternalCall); ... event.proplistener(obj, obj.findprop('ColumnHeaderPosition'), 'PostSet', @i_setupGrid_InternalCall); ... ]; end function iSetBorder(~,evt) obj = evt.AffectedObject; set(obj.gridObject,'Border',obj.Border); end function i_setCellSize(~, evt) evt.AffectedObject.setPosition([]); end % i_setCellSize function i_setCurCol(~, evt, hScroll) set(hScroll, 'Value', evt.AffectedObject.CurrentColumn+1); end % i_setCurCol function i_setCurRow(~, evt, hScroll) set(hScroll, 'Value', -evt.AffectedObject.CurrentRow-1); end % i_setCurRow function i_setScrRowLims(~, evt, hScroll) obj = evt.AffectedObject; slims = obj.ScrollRowLimits; if all(slims==0) || all(slims==1) set(hScroll, 'Min', -2, 'Max', -1, 'SliderStep', [1 1]); else szData = double(obj.getVisibleSize); sliderStep = [1, szData(1)]/(slims(2)-slims(1)); set(hScroll, 'Min', -slims(2), 'Max', -slims(1), 'SliderStep', sliderStep); end end % i_setScrRowLims function i_setScrColLims(~, evt, hScroll) obj = evt.AffectedObject; slims = obj.ScrollColumnLimits; if all(slims==0) || all(slims==1) set(hScroll, 'Min', 1, 'Max', 2, 'SliderStep', [1 1]); else szData = double(obj.getVisibleSize); sliderStep = [1, szData(2)]/(slims(2)-slims(1)); set(hScroll, 'Min', slims(1), 'Max', slims(2), 'SliderStep', sliderStep); end end % i_setScrColLims function i_setupGrid(src, ~) src.doSetupGrid; end % i_setupGrid function i_setupGrid_InternalCall(~, evt) evt.AffectedObject.doSetupGrid; end % i_setupGrid_InternalCall function i_setRowHeaderWidth(~, evt, hGrid) obj = evt.AffectedObject; sz = get(hGrid, 'colsizes'); if ~isempty(sz) && obj.ShowColumnHeaders if sz(1)>0 sz(1) = obj.RowHeaderWidth; end set(hGrid, 'colsizes', sz); end end % i_setRowHeaderWidth function i_setColHeaderWidth(~, evt, hGrid) obj = evt.AffectedObject; sz = get(hGrid, 'rowsizes'); if ~isempty(sz) && obj.ShowColumnHeaders if strcmp(obj.ColumnHeaderPosition, 'top') if sz(1)>0 sz(1) = obj.ColumnHeaderWidth; end else if sz(end-1)>0 sz(end-1) = obj.ColumnHeaderWidth; elseif sz(end)>0 sz(end) = obj.ColumnHeaderWidth; end end set(hGrid, 'rowsizes', sz); end end % i_setColHeaderWidth function i_setScrollWidth(~, evt, hGrid) obj = evt.AffectedObject; szrow = get(hGrid, 'rowsizes'); szcol = get(hGrid, 'colsizes'); if ~isempty(szrow) && ~isempty(szcol) if strcmp(obj.ColumnHeaderPosition, 'top') if szrow(end)>0 szrow(end) = obj.ScrollbarWidth; end else if (obj.ShowColumnHeaders && szrow(end-1)>0) || (~obj.ShowColumnHeaders && szrow(end)>0) szrow(end) = obj.ScrollbarWidth; end end if szcol(end)>0 szcol(end) = obj.ScrollbarWidth; end set(hGrid, 'rowsizes', szrow, 'colsizes', szcol); end end % i_setScrollWidth function i_setItemAtTL(~, evt) evt.AffectedObject.doTLComp; end % i_setItemAtTL function i_setItemAtTR(~, evt) evt.AffectedObject.doTRComp; end % i_setItemAtTR function i_setItemAtBL(~, evt) evt.AffectedObject.doBLComp; end % i_setItemAtBL function i_setItemAtBR(~, evt) evt.AffectedObject.doBRComp; end % i_setItemAtBR function i_setgap(~, evt, hGrid, prop) set(hGrid, prop, evt.AffectedObject.RowGap); end % i_setgap