source: MML/trunk/machine/SOLEIL/common/toolbox/GUILayout/+uiextras/unset.m @ 4

Last change on this file since 4 was 4, checked in by zhangj, 10 years ago

Initial import--MML version from SOLEIL@2013

File size: 1.7 KB
Line 
1function 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
21error( nargchk( 2, 2, nargin ) );
22if isempty( hObj )
23    hObj = 0;
24end
25if strncmpi( class( hObj ), 'uiextras.', 9 )
26    hObj = double( hObj );
27end
28if ~isequal( hObj, 0 ) && ~ishghandle( hObj )
29    error( 'GUILayout:InvalidArgument', 'Object must be a valid Handle Graphics object.' );
30end
31if ~ischar( propName )
32    error( 'GUILayout:InvalidArgument', 'Property name must be a string.' )
33end
34
35% Make sure the property requested is a default
36if ~strncmp( propName, 'Default', 7 )
37    error( 'GUILayout:InvalidArgument', 'Property name must begin with ''Default''.' )
38end
39
40% Try to remove appdata
41while 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
52end
Note: See TracBrowser for help on using the repository browser.