Home > m > gui > @jcontrol > get.m

get

PURPOSE ^

GET method overloaded for JCONTROL class

SYNOPSIS ^

function s=get(obj, property)

DESCRIPTION ^

 GET method overloaded for JCONTROL class

 Examples:
 a=get(obj)
 a=get(obj,PropertyName);
 
 If obj is a vector of JCONTROLs, a cell array will be returned

 See also: jcontrol

 -------------------------------------------------------------------------
 Author: Malcolm Lidierth 07/07
 Copyright © The Author & King's College London 2007
 -------------------------------------------------------------------------

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function s=get(obj, property)
0002 % GET method overloaded for JCONTROL class
0003 %
0004 % Examples:
0005 % a=get(obj)
0006 % a=get(obj,PropertyName);
0007 %
0008 % If obj is a vector of JCONTROLs, a cell array will be returned
0009 %
0010 % See also: jcontrol
0011 %
0012 % -------------------------------------------------------------------------
0013 % Author: Malcolm Lidierth 07/07
0014 % Copyright © The Author & King's College London 2007
0015 % -------------------------------------------------------------------------
0016 
0017 % No property: list contents
0018 if nargin==1
0019     if numel(obj)==1
0020         s.hgcontainer=obj.hgcontainer;
0021         s.hgcontrol=obj.hgcontrol;
0022         s.hghandle=obj.hghandle;
0023     else
0024         display(obj);
0025     end
0026     return
0027 end
0028 
0029 % Must specify a single property
0030 if nargin>2
0031     error('Too many input arguments');
0032 end
0033 
0034 % Ensure lower-case
0035 property=lower(property);
0036 
0037 % Vector of JCONTROLs on input
0038 % Call GET on each in turn returning a cell array
0039 if numel(obj)>1
0040     if nargout>0
0041         % Pre-allocate
0042         s=cell(1,numel(obj));
0043         for idx=1:numel(obj)
0044             % Recursive call
0045             s{idx}=get(obj(idx),property);
0046         end
0047         return
0048     else
0049         % Stop problems in nested gets e.g. (get(get,...)...)
0050         error('Must specify a left-hand side assignment with vector input');
0051     end
0052 end
0053     
0054 % Check for ambiguity in property name
0055 if isprop(obj.hgcontainer, property) &&...
0056         isprop(obj.hgcontrol, property)
0057     if strcmp(property,'visible')
0058         % Visible is an exception -  take this from the container, MATLAB
0059         % links this property for the container and object
0060         s=obj.hgcontainer.Visible;
0061         return
0062     else
0063     error('Shared property name ''%s''\nYou must explicitly specify the target object',...
0064         property);
0065     end
0066 end
0067 
0068 % Do the work
0069 switch property
0070     case 'hghandle'
0071         s=obj.hghandle;
0072     case 'hgcontainer'
0073         s=obj.hgcontainer;
0074     case 'hgcontrol'
0075         s=obj.hgcontrol;
0076     otherwise
0077         if isprop(obj.hgcontainer, property)
0078             % container property
0079             s=obj.hgcontainer.(property);
0080         elseif isprop(obj.hgcontrol, property)
0081             % control property
0082             s=obj.hgcontrol.(property);
0083         elseif isempty(obj.hghandle)
0084             % Empty -default object
0085             s=[];
0086         else
0087             % Error
0088             error('No such property');
0089         end
0090 end
0091 
0092 end

Generated on Mon 31-Mar-2008 13:54:54 by m2html © 2003