www.gusucode.com > mbcguitools 工具箱 matlab 源码程序 > mbcguitools/@mbcwidgets/@Table2D/Table2D.m

    function obj = Table2D(varargin)
%TABLE2D Construct a new Table1D object
%
%  OBJ = TABLE2D(TYPE, PROP, VALUE, ...) constructs a new Table2D object of
%  the specified type.  TYPE can be a string that specifies one of the
%  default types or a java object that is a subclass of Abstract2DTablePeer.
%  The available default types are 'String', 'Numeric' and
%  'ExtendedNumeric'.

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


numArgs = length(varargin);

if numArgs && isa(varargin{1}, 'mbcwidgets.Table2D')
    obj = varargin{1};
    varargin(1) = [];
    numArgs = numArgs-1;
else
    obj = mbcwidgets.Table2D;
end

if rem(numArgs, 2)>0
    % Sort out type argument
    if isjava(varargin{1})
        P = varargin{1};
    elseif ischar(varargin{1})
        switch lower(varargin{1})
            case 'string'
                P = com.mathworks.toolbox.mbc.gui.peer.String2DTablePeer;
            case 'numeric'
                P = com.mathworks.toolbox.mbc.gui.peer.Numeric2DTablePeer;
            case 'extendednumeric'
                P = com.mathworks.toolbox.mbc.gui.peer.ExtendedNumeric2DTablePeer;
            otherwise
                error(message('mbc:mbcwidgets:Table2D:InvalidArgument1'));
        end
    else
        error(message('mbc:mbcwidgets:Table2D:InvalidArgument2'));
    end
    varargin(1) = [];
    numArgs = numArgs-1;
else
    % Default type
    P = com.mathworks.toolbox.mbc.gui.peer.Numeric2DTablePeer;
end

% Call superclass constructor
obj.Table1D(P, ...
    'SelectionMode', 'MultiRegion', ...
    'ShowHeaderSelection', true, ...
    varargin{:});

% Attach peer callbacks
L = handle.listener(obj.Peer, 'RowPopup', {@i_rowcontextpopup, obj});
set(L, 'RecursionLimit', 50);
obj.addListeners(L);

% Attach property listeners
obj.addPropertyListeners('ShowRowHeader', @i_setShowHeader);


function i_rowcontextpopup(src, evt, obj)
obj.pShowContextMenu(obj.pGetContextMenu('RowHeaderContextMenu'), evt.JavaEvent);


function i_setShowHeader(obj, evt)
obj.Peer.setDisplayRowHeaders(evt.NewValue);