Mercurial > hg > ltpda
comparison m-toolbox/m/gui/@jcontrol/get.m @ 0:f0afece42f48
Import.
author | Daniele Nicolodi <nicolodi@science.unitn.it> |
---|---|
date | Wed, 23 Nov 2011 19:22:13 +0100 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:f0afece42f48 |
---|---|
1 function s=get(obj, property) | |
2 % GET method overloaded for JCONTROL class | |
3 % | |
4 % Examples: | |
5 % a=get(obj) | |
6 % a=get(obj,PropertyName); | |
7 % | |
8 % If obj is a vector of JCONTROLs, a cell array will be returned | |
9 % | |
10 % See also: jcontrol | |
11 % | |
12 % ------------------------------------------------------------------------- | |
13 % Author: Malcolm Lidierth 07/07 | |
14 % Copyright © The Author & King's College London 2007 | |
15 % ------------------------------------------------------------------------- | |
16 | |
17 % No property: list contents | |
18 if nargin==1 | |
19 if numel(obj)==1 | |
20 s.hgcontainer=obj.hgcontainer; | |
21 s.hgcontrol=obj.hgcontrol; | |
22 s.hghandle=obj.hghandle; | |
23 else | |
24 display(obj); | |
25 end | |
26 return | |
27 end | |
28 | |
29 % Must specify a single property | |
30 if nargin>2 | |
31 error('Too many input arguments'); | |
32 end | |
33 | |
34 % Ensure lower-case | |
35 property=lower(property); | |
36 | |
37 % Vector of JCONTROLs on input | |
38 % Call GET on each in turn returning a cell array | |
39 if numel(obj)>1 | |
40 if nargout>0 | |
41 % Pre-allocate | |
42 s=cell(1,numel(obj)); | |
43 for idx=1:numel(obj) | |
44 % Recursive call | |
45 s{idx}=get(obj(idx),property); | |
46 end | |
47 return | |
48 else | |
49 % Stop problems in nested gets e.g. (get(get,...)...) | |
50 error('Must specify a left-hand side assignment with vector input'); | |
51 end | |
52 end | |
53 | |
54 % Check for ambiguity in property name | |
55 if isprop(obj.hgcontainer, property) &&... | |
56 isprop(obj.hgcontrol, property) | |
57 if strcmp(property,'visible') | |
58 % Visible is an exception - take this from the container, MATLAB | |
59 % links this property for the container and object | |
60 s=obj.hgcontainer.Visible; | |
61 return | |
62 else | |
63 error('Shared property name ''%s''\nYou must explicitly specify the target object',... | |
64 property); | |
65 end | |
66 end | |
67 | |
68 % Do the work | |
69 switch property | |
70 case 'hghandle' | |
71 s=obj.hghandle; | |
72 case 'hgcontainer' | |
73 s=obj.hgcontainer; | |
74 case 'hgcontrol' | |
75 s=obj.hgcontrol; | |
76 otherwise | |
77 if isprop(obj.hgcontainer, property) | |
78 % container property | |
79 s=obj.hgcontainer.(property); | |
80 elseif isprop(obj.hgcontrol, property) | |
81 % control property | |
82 s=obj.hgcontrol.(property); | |
83 elseif isempty(obj.hghandle) | |
84 % Empty -default object | |
85 s=[]; | |
86 else | |
87 % Error | |
88 error('No such property'); | |
89 end | |
90 end | |
91 | |
92 end |