www.gusucode.com > mbcguitools 工具箱 matlab 源码程序 > mbcguitools/+mbcgui/+widget/@ScrollTable/ScrollTable.m
classdef ScrollTable < mbcgui.widget.BasicContainer %mbcgui.widget.scrollTable class % mbcgui.widget.scrollTable extends mbcgui.widget.BasicContainer. % % mbcgui.widget.scrollTable properties: % Parent - Property is of type 'MATLAB array' % Position - Property is of type 'rect' % Enable - Property is of type 'on/off' % Visible - Property is of type 'on/off' % Userdata - Property is of type 'MATLAB array' % Tag - Property is of type 'string' % CurrentRow - Property is of type 'double' % CurrentColumn - Property is of type 'double' % ScrollRowLimits - Property is of type 'MATLAB array' (read only) % ScrollColumnLimits - Property is of type 'MATLAB array' (read only) % RowHeaderObjects - Property is of type 'MATLAB array' (read only) % ColumnHeaderObjects - Property is of type 'MATLAB array' (read only) % MainObjects - Property is of type 'MATLAB array' (read only) % RowHeaderData - Property is of type 'MATLAB array' % ColumnHeaderData - Property is of type 'MATLAB array' % MainData - Property is of type 'MATLAB array' % RowConstructor - Property is of type 'MATLAB array' % ColumnConstructor - Property is of type 'MATLAB array' % MainConstructor - Property is of type 'MATLAB array' % ShowRowHeaders - Property is of type 'bool' % ShowColumnHeaders - Property is of type 'bool' % UseVectorDrawMethod - Property is of type 'bool' % MaximumObjectCacheSize - Property is of type 'int' % % mbcgui.widget.scrollTable methods: % canPaint - Indicate whether object can be drawn % checkScrollLocation - Adjust current row and column if necessary % createObjects - Create given number of display objects % deleteObjects - Delete given display objects % disableScrolling - Turn off the scrolling listeners % doSetupBaseClass - Setup listeners % doUpdateCacheSizes - Update the size of the main and header caches % enableScrolling - Turn on the scrolling listeners % getDisplaySize - Return the actual number of rows and columns that are displayed % getObjectAt - Return display object at specified row and column % getVisibleSize - Return the current number of visible rows/columns % isAlive - Returns true if the object is currently correctly drawn % isCellVisible - Check whether cell is currently visible % isCreatedCorrect - ISCREATEDCORRRECT Check whether table is as big as possible % pGetDataSize - Get the size of the data array. % setEnable - Respond to enable being set % setParent - Respond to parent being set % setVisible - Respond to visible being set % paintCell - Refresh specified cell % paintColumnHeader - Refresh column header contents % paintColumns - Refresh specified columns % paintMain - Refresh main contents % paintObjects - Push new data into display objects % paintRowHeader - Refresh row header contents % paintRows - Refresh specified rows % repaint - Force a repaint of the displays % setVisibleSize - Set the number of visible rows and columns % update - Force a full object refresh % updateColumnHeader - Redraw row header when turned on/off % updateDataFlag - Re-check that data sizes match % updateObjectArrays - Update the number of display objects % updateRealSize - Update the internal size properties % updateRowHeader - Redraw row header when turned on/off % updateToDeadState - Redraw object in its dead state % updateToLiveState - Redraw object as live, assuming it is initially dead % Copyright 2014-2015 The MathWorks, Inc. and Ford Global Technologies, Inc. properties (AbortSet) %ROWCONSTRUCTOR Property is of type 'MATLAB array' RowConstructor = []; %COLUMNCONSTRUCTOR Property is of type 'MATLAB array' ColumnConstructor = []; %MAINCONSTRUCTOR Property is of type 'MATLAB array' MainConstructor = []; end properties (AbortSet, SetObservable) %CURRENTROW Property is of type 'double' CurrentRow = 0; %CURRENTCOLUMN Property is of type 'double' CurrentColumn = 0; %ROWHEADERDATA Property is of type 'MATLAB array' RowHeaderData = []; %COLUMNHEADERDATA Property is of type 'MATLAB array' ColumnHeaderData = []; %MAINDATA Property is of type 'MATLAB array' MainData = []; %SHOWROWHEADERS Property is of type 'bool' ShowRowHeaders = true; %SHOWCOLUMNHEADERS Property is of type 'bool' ShowColumnHeaders = true; %USEVECTORDRAWMETHOD Property is of type 'bool' UseVectorDrawMethod = true; %MAXIMUMOBJECTCACHESIZE Property is of type 'int' MaximumObjectCacheSize = 0; end properties (AbortSet) %Access=protected %VISIBLEROWS Property is of type 'int' VisibleRows = 0; %VISIBLECOLS Property is of type 'int' VisibleCols = 0; %DATASIZESMATCHED Property is of type 'bool' dataSizesMatched = true; %INLIVESTATE Property is of type 'bool' inLiveState = false; %NUMROWS Property is of type 'int' numRows = 0; %NUMCOLS Property is of type 'int' numCols = 0; %ScrollEnabled ScrollEnabled = false; %SCROLLTABLE_DATALISTENERS Property is of type 'handle vector' scrollTable_DataListeners = []; %MAINOBJECTCACHESIZE Property is of type 'int' mainObjectCacheSize = 0; %HEADOBJECTCACHESIZE Property is of type 'int' headObjectCacheSize = 0; %MAINOBJECTCACHE Property is of type 'MATLAB array' mainObjectCache = []; %ROWOBJECTCACHE Property is of type 'MATLAB array' rowObjectCache = []; %COLOBJECTCACHE Property is of type 'MATLAB array' colObjectCache = []; end properties (SetAccess=protected, AbortSet) %ROWHEADEROBJECTS Property is of type 'MATLAB array' (read only) RowHeaderObjects = []; %COLUMNHEADEROBJECTS Property is of type 'MATLAB array' (read only) ColumnHeaderObjects = []; %MAINOBJECTS Property is of type 'MATLAB array' (read only) MainObjects = []; end properties (SetAccess=protected, AbortSet, SetObservable) %SCROLLROWLIMITS Property is of type 'MATLAB array' (read only) ScrollRowLimits = [0, 0]; %SCROLLCOLUMNLIMITS Property is of type 'MATLAB array' (read only) ScrollColumnLimits = [0, 0]; end events DisplayObjectsChanged DataSizeChanged DisplaySizeChanged end % events methods % constructor block function obj = ScrollTable(varargin) %SCROLLTABLE Constructor for scrollTable object % % H = SCROLLTABLE(PROP1, VAL1, ...) obj@mbcgui.widget.BasicContainer(varargin{:}); % converted super class constructor call if obj.MaximumObjectCacheSize>0 obj.doUpdateCacheSizes; end obj.updateDataFlag; obj.updateRealSize; obj.CurrentRow = max(min(obj.CurrentRow, obj.ScrollRowLimits(2)), obj.ScrollRowLimits(1)); obj.CurrentColumn = max(min(obj.CurrentColumn, obj.ScrollColumnLimits(2)), obj.ScrollColumnLimits(1)); obj.doSetupBaseClass; obj.enableScrolling; end % scrollTable end % constructor block methods function set.CurrentRow(obj, value) %CurrentRow Current row is zero based so the top row is =0 if obj.ScrollEnabled % Limit the property value = max(min(value, obj.ScrollRowLimits(2)), obj.ScrollRowLimits(1)-1); obj.CurrentRow = value; if obj.canPaint obj.paintRowHeader; obj.paintMain; end else obj.CurrentRow = value; end end function set.CurrentColumn(obj, value) %CurrentColumn Current column is zero based so the left column is = 0 if obj.ScrollEnabled % Limit the property value = max(min(value, obj.ScrollColumnLimits(2)), obj.ScrollColumnLimits(1)-1); obj.CurrentColumn = value; if obj.canPaint obj.paintColumnHeader; obj.paintMain; end else obj.CurrentColumn = value; end end function set.ShowRowHeaders(obj,value) obj.ShowRowHeaders=value; obj.updateDataFlag; obj.updateRealSize; if obj.canPaint if obj.isAlive obj.updateRowHeader; else obj.updateToLiveState; end else obj.updateToDeadState; end end function set.ShowColumnHeaders(obj,value) obj.ShowColumnHeaders=value; obj.updateDataFlag; obj.updateRealSize; if obj.canPaint if obj.isAlive obj.updateColumnHeader; else obj.updateToLiveState; end else obj.updateToDeadState; end end function set.MaximumObjectCacheSize(obj,value) % DataType = 'int' if value<0 obj.MaximumObjectCacheSize = 0; else value = round(value); % round to obtain an integer obj.MaximumObjectCacheSize = value; end obj.doUpdateCacheSizes; end function set.VisibleRows(obj,value) % DataType = 'int' value = round(value); % round to obtain an integer obj.VisibleRows = value; end function set.VisibleCols(obj,value) % DataType = 'int' value = round(value); % round to obtain an integer obj.VisibleCols = value; end function set.numRows(obj,value) % DataType = 'int' value = round(value); % round to obtain an integer obj.numRows = value; end function set.numCols(obj,value) % DataType = 'int' value = round(value); % round to obtain an integer obj.numCols = value; end function set.mainObjectCacheSize(obj,value) % DataType = 'int' value = round(value); % round to obtain an integer obj.mainObjectCacheSize = value; end function set.headObjectCacheSize(obj,value) % DataType = 'int' value = round(value); % round to obtain an integer obj.headObjectCacheSize = value; end end % set and get functions methods % public methods PAINT_OK = canPaint(obj) ret = checkScrollLocation(obj) disp_obj = createObjects(obj,fcn,N,cachename) deleteObjects(obj,h_del,cachename) disableScrolling(obj) doSetupBaseClass(obj) doUpdateCacheSizes(obj) enableScrolling(obj) sz = getDisplaySize(obj) h = getObjectAt(obj,R,C) sz = getVisibleSize(obj) ALIVE_FLAG = isAlive(obj) vis = isCellVisible(obj,R,C) ret = isCreatedCorrect(obj) sz = pGetDataSize(obj,dim) paintCell(obj,R,C) paintColumnHeader(obj) paintColumns(obj,C) paintMain(obj) paintObjects(obj,disp_obj,data,row,col) paintRowHeader(obj) paintRows(obj,R) repaint(obj) setVisibleSize(obj,nR,nC) update(obj) updateColumnHeader(obj) updateDataFlag(obj) changes = updateObjectArrays(obj) updateRealSize(obj) updateRowHeader(obj) updateToDeadState(obj) updateToLiveState(obj) end % public methods methods (Access=protected) val = setEnable(obj,val) val = setParent(obj,val) val = setVisible(obj,val) end end % classdef