1 | function unset( hObj, propName ) |
---|
2 | %uiextras.unset Clear a default property value from a parent object |
---|
3 | % |
---|
4 | % uiextras.unset(hObj,propName) clears a default property value from the |
---|
5 | % object hObj. Note that the hObj must be a valid graphics container |
---|
6 | % object such as a uipanel, figure or the special flag 0 (the overall |
---|
7 | % environment. If a default has been set for the specified property |
---|
8 | % (propName) of the specified layout (className), it is removed. |
---|
9 | % |
---|
10 | % Examples: |
---|
11 | % >> uiextras.unset( gcf(), 'DefaultBoxPanelTitleColor' ) |
---|
12 | % |
---|
13 | % See also: uiextras.set |
---|
14 | % uiextras.get |
---|
15 | |
---|
16 | % Copyright 2010 The MathWorks, Inc. |
---|
17 | % 1.1 |
---|
18 | % 2012/05/08 08:02:58 |
---|
19 | |
---|
20 | % Check inputs |
---|
21 | error( nargchk( 2, 2, nargin ) ); |
---|
22 | if isempty( hObj ) |
---|
23 | hObj = 0; |
---|
24 | end |
---|
25 | if strncmpi( class( hObj ), 'uiextras.', 9 ) |
---|
26 | hObj = double( hObj ); |
---|
27 | end |
---|
28 | if ~isequal( hObj, 0 ) && ~ishghandle( hObj ) |
---|
29 | error( 'GUILayout:InvalidArgument', 'Object must be a valid Handle Graphics object.' ); |
---|
30 | end |
---|
31 | if ~ischar( propName ) |
---|
32 | error( 'GUILayout:InvalidArgument', 'Property name must be a string.' ) |
---|
33 | end |
---|
34 | |
---|
35 | % Make sure the property requested is a default |
---|
36 | if ~strncmp( propName, 'Default', 7 ) |
---|
37 | error( 'GUILayout:InvalidArgument', 'Property name must begin with ''Default''.' ) |
---|
38 | end |
---|
39 | |
---|
40 | % Try to remove appdata |
---|
41 | while true |
---|
42 | if isappdata( hObj, propName ) % appdata found |
---|
43 | rmappdata( hObj, propName ); % remove |
---|
44 | break % done |
---|
45 | elseif isempty( get( hObj, 'Parent' ) ) % cannot look higher than root |
---|
46 | error( 'GUILayout:get:ItemNotFound', ... |
---|
47 | 'Could not find a value for property ''%s'' in the ancestors of this object.', propName ); |
---|
48 | else % continue one level up |
---|
49 | hObj = get( hObj, 'Parent' ); |
---|
50 | continue |
---|
51 | end |
---|
52 | end |
---|