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

    function obj = xregaxesinput(varargin)
%XREGAXESINPUT Constructor for the axes input object for a ListCtrl
%
%   Pass in an array of axes handles to create one input object; a gridlayout
%   containing these axes
%
%   Usage:
%   x = xregaxesinput(FIG,[axesHandles])
%   x = xregaxesinput([axesHandles])
%   x = xregaxesinput('Property1',Value1,...)
%   x = xregaxesinput(FIG,'Property1',Value1,...)

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


fh = [];
if nargin>0 && mbcgui.util.isComponentParent(varargin{1})
    fh=varargin{1};
    varargin(1)=[];
end

if ~isempty(varargin) 

    axHnd = varargin{1};
    varargin(1) = []; % sets us up for property arguments below
    if isgraphics(axHnd,'axes')
        axHnd = findobj(axHnd,'flat','Type','axes');
        numAx = length(axHnd);
        % if no fig handle from above, get a figure to parent everything
        if isempty(fh)
            fh = get(axHnd(1),'Parent');
        end
        doCreate = false;
    else
        numAx = axHnd;
        doCreate = true;
    end

    obj.frame = mbcgui.container.layoutpanel('Parent',fh);
    
    % wrap the axes
    aws = cell(1,numAx);
    for i=1:numAx
        if doCreate
            aws{i} = axes('Parent',obj.frame,...
                'Units','pixels'); %#ok<LAXES>
        else
            set(axHnd(i),'Parent',obj.frame);
            aws{i} = axHnd(i);
        end
    end

    obj.grid = xreggridbaglayout(obj.frame,...
        'dimension',[1,numAx],...
        'elements',aws,...
        'gapx',50,...
        'border',[35 35 5 30]);
    set(obj.frame,'LayoutComponent',{obj.grid});

    obj = class(obj,'xregaxesinput');

    if ~isempty(varargin)
        obj = set(obj,varargin{:});
    end

else
    error(message('mbc:xregaxesinput:InvalidArgument'));
end