1 | function 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 |
---|
25 | error( nargchk( 3, 3, nargin, 'struct' ) ) |
---|
26 | |
---|
27 | if isa( hObj, 'uiextras.Container' ) |
---|
28 | hObj = double( hObj ); |
---|
29 | end |
---|
30 | if ~isequal( hObj, 0 ) && ~ishghandle( hObj ) |
---|
31 | error( 'GUILayout:InvalidArgument', 'Object must be a valid Handle Graphics object.' ) |
---|
32 | end |
---|
33 | if ~ischar( propName ) |
---|
34 | error( 'GUILayout:InvalidArgument', 'Property name must be a string.' ) |
---|
35 | end |
---|
36 | |
---|
37 | % Make sure the property requested is a default |
---|
38 | if ~strncmp( propName, 'Default', 7 ) |
---|
39 | error( 'GUILayout:InvalidArgument', 'Property name must begin with ''Default''.' ) |
---|
40 | end |
---|
41 | |
---|
42 | % All OK, so set it |
---|
43 | setappdata( hObj, propName, propValue ); |
---|