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

    function obj = set(obj, varargin)
% xregconstinput/SET
%     set(xregconstinput, 'Property', Value)
%     Property = {'Position', 'Name', 'Parent', 'Value'}
%
%     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);

ud = get(obj.text,'UserData');

for arg=1:2:nparam*2-1
   parameter = varargin{arg};
   value = varargin{arg+1};
   switch upper(parameter)
      
   case 'POSITION'
      pos=value;
      if pos(3) < 20
         pos(3) = 20;
      end
      if pos(4) < 10
         pos(4) = 10;
      end
      % change ratios if restricted length
      if pos(3)<200
         set(obj.layout,...
            'colratios',[4,4,1,2],...
            'colsizes',[],...
            'gapx',1);
      else
         set(obj.layout,...
            'colratios',[],...
            'colsizes',[-1,70,20,40],...
            'gapx',5);
      end      
      set(obj.layout,'Position',pos);
      
   case 'CALLBACK'
       set(obj.clickedit,'Callback',value);
      
   case {'VARNAME','NAME'}
      if ischar(value)
         set(obj.text,'String',value);
      end
      
   case {'TOLERANCE','TOL'}
      if ischar(value)
         value = str2num(value);
      end
      
      if isempty(value)
         return
      else
         set(obj.tolerance,'String',num2str(value));
         set(obj.tolerance,'UserData',num2str(value));      
      end
      
   case 'TOLERANCEENABLE'
      if strcmpi(value,'off')
         set(obj.tolerancetext,'Enable','off');
         set(obj.tolerance,'Enable','off',...
            'BackgroundColor',get(obj.text,'BackgroundColor'));
      else
         set(obj.tolerancetext,'Enable','on');
         set(obj.tolerance,'Enable','on',...
            'BackgroundColor','w');         
      end
         
   case 'VISIBLE'
      if ischar(value)
         switch upper(value)
         case 'OFF'
            set(obj.layout ,'Visible','off');
         case 'ON'
            set(obj.layout,'Visible','on');
         end
      end
      
   case 'PARENT'
      if isgraphics(value)
         set(obj.clickedit,'Parent',value);
         set([obj.text,obj.tolerancetext,obj.tolerance],'Parent',value);
         set(obj.layout,'Parent',value);
      end
      
   case 'USERDATA'
      ud.UserData = value;
      
   case 'FONTWEIGHT'
      try
         set([obj.text,obj.tolerancetext],'FontWeight',value);      
      end
      
   otherwise
      try
         set(obj.clickedit,parameter,value);
      catch
         warning(message('mbc:xregclicktolinput:InvalidPropertyName1'));
      end
      
   end
end

set(obj.text,'UserData',ud);