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

    function obj = set(obj, varargin)
%SET
%    SET(xregaxesinput, 'Property', Value) where Property is one of
%    'POSITION', 'VISIBLE', 'PARENT' or 'AXES'
%
%    Also at this time only one parameter value pair per call can be used
%
%    This form of the set method return a modified form of the object

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


d = length(varargin)/2;
nparam = floor(d);

for arg=1:2:nparam*2-1
    parameter = varargin{arg};
    value = varargin{arg+1};

    switch upper(parameter)

        case {'NUMCELLS','NUMAXES'}
            if length(value)==1
                set(obj.grid,'dimension',[1,value]);
            end

        case {'POSITION','POS'}
            set(obj.frame,'Position',value);

        case 'CALLBACK'
            % axesinputs don't have a callback but must implement
            
        case 'AXES'
            % Use the specified axes in place of the current ones.  
            axw = get(obj.grid, 'elements');
            nNewAxes = length(value);
            nOldWrappers = length(axw);
            
            for n=1:nNewAxes
                if ~isequal(get(value(n), 'Parent'),obj.frame)
                    set(value(n), 'Parent', obj.frame);
                end
            end
            if nNewAxes>=nOldWrappers
                for n = 1:nOldWrappers
                    axw{n} = value(n);
                end
                for n = nOldWrappers+1:nNewAxes
                    axw{n} = value(n);
                end
            else
                delete([axw{nNewAxes+1:end}]);
                axw = axw(1:nNewAxes);
                for n = 1:nNewAxes
                    axw{n} = value(n);
                end
            end
            set(obj.grid, 'elements', axw);
            
        case 'GAPX'
            % Give the gap to the border of the axes
            if value>20
                LBord = value-10;
                RBord = 10;
            else
                LBord = value-5;
                RBord = 5;
            end
            set(obj.grid,'gapx',value);
            set(obj.grid, 'Border', [LBord+20 35 RBord 30]);
        case 'PARENT'
            if isgraphics(value)
                set(obj.frame, 'Parent', value);
            end
        case 'VISIBLE'
            set(obj.frame,'Visible',value);
        case 'UICONTEXTMENU'
            set(obj.frame,'UIContextMenu',value);
            axHandles = get(obj,'axes');
            for i=1:length(axHandles)
                set(axHandles(i),'UIContextMenu',value);
            end            
        otherwise
            try
                set(obj.grid, parameter, value);
            catch
                warning(message('mbc:xregaxesinput:InvalidPropertyName', parameter));
            end
    end
end