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

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

Initial import--MML version from SOLEIL@2013

File size: 1.5 KB
Line 
1function set( hObj, propName, propValue )
2%uiextras.set  Store a default property value in a parent object
3%
4%   uiextras.set(hObj,propName,propValue) stores a default property value
5%   in the object hObj such that children created inside it of the correct
6%   class will use the specified value (propValue) for the specified
7%   property by default. The property name should take the form
8%   "DefaultClassProperty", for example to set the default "TitleColor" for
9%   the class "uiextras.BoxPanel", use "DefaultBoxPanelTitleColor". Note
10%   that using the special object handle 0 sets the default for all new
11%   figures.
12%
13%   Examples:
14%   >> uiextras.set( gcf(), 'DefaultBoxPanelTitleColor', 'g' )
15%   >> uiextras.set( 0, 'DefaultHBoxPadding', 5 )
16%
17%   See also: uiextras.get
18%             uiextras.unset
19
20%   Copyright 2010 The MathWorks, Inc.
21%   1.1
22%   2012/05/08 08:02:58
23
24% Check inputs
25error( nargchk( 3, 3, nargin, 'struct' ) )
26
27if isa( hObj, 'uiextras.Container' )
28    hObj = double( hObj );
29end
30if ~isequal( hObj, 0 ) && ~ishghandle( hObj )
31    error( 'GUILayout:InvalidArgument', 'Object must be a valid Handle Graphics object.' )
32end
33if ~ischar( propName )
34    error( 'GUILayout:InvalidArgument', 'Property name must be a string.' )
35end
36
37% Make sure the property requested is a default
38if ~strncmp( propName, 'Default', 7 )
39    error( 'GUILayout:InvalidArgument', 'Property name must begin with ''Default''.' )
40end
41
42% All OK, so set it
43setappdata( hObj, propName, propValue );
Note: See TracBrowser for help on using the repository browser.