6257
|
1 ## Copyright (C) 2005 John W. Eaton |
|
2 ## |
|
3 ## This file is part of Octave. |
|
4 ## |
|
5 ## Octave is free software; you can redistribute it and/or modify it |
|
6 ## under the terms of the GNU General Public License as published by |
|
7 ## the Free Software Foundation; either version 2, or (at your option) |
|
8 ## any later version. |
|
9 ## |
|
10 ## Octave is distributed in the hope that it will be useful, but |
|
11 ## WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
13 ## General Public License for more details. |
|
14 ## |
|
15 ## You should have received a copy of the GNU General Public License |
|
16 ## along with Octave; see the file COPYING. If not, write to the Free |
|
17 ## Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA |
|
18 ## 02110-1301, USA. |
|
19 |
|
20 ## -*- texinfo -*- |
|
21 ## @deftypefn {Function File} {} set (@var{h}, @var{p}, @var{v}, @dots{}) |
|
22 ## Set the named property @var{p} to the value @var{v} in the graphics |
|
23 ## handle @var{h}. |
|
24 ## @end deftypefn |
|
25 |
|
26 ## Author: jwe |
|
27 |
|
28 function retval = set (h, varargin) |
|
29 |
|
30 __uiobject_globals__; |
|
31 |
|
32 if (rem (nargin-1, 2) == 0) |
|
33 if (ishandle (h)) |
|
34 idx = __uiobject_handle2idx__ (h); |
|
35 obj = __uiobject_list__(idx).object; |
|
36 |
|
37 if (isfield (obj, "__setter__")) |
|
38 obj = feval (obj.__setter__, h, varargin{:}); |
|
39 else |
|
40 for i = 1:2:nargin-1 |
|
41 property = varargin{i}; |
|
42 if (ischar (property)) |
|
43 key = tolower (property); |
|
44 if (isfield (obj, key)) |
|
45 val = varargin{i+1}; |
|
46 if (isfield (obj, "__validators__")) |
|
47 validators = obj.__validators__; |
|
48 if (isfield (validators, key)) |
|
49 feval (validators.(key), val); |
|
50 endif |
|
51 endif |
|
52 obj.(key) = val; |
|
53 else |
|
54 warning ("set: unrecognized property `%s' for uiobject `%s'", |
|
55 property, obj.type); |
|
56 endif |
|
57 else |
|
58 error ("set: expecting property name to be a character string"); |
|
59 endif |
|
60 endfor |
|
61 endif |
|
62 __uiobject_list__(idx).object = obj; |
|
63 __request_drawnow__ (); |
|
64 if (nargout > 0) |
|
65 retval = h; |
|
66 endif |
|
67 else |
|
68 error ("set: invalid handle"); |
|
69 endif |
|
70 else |
|
71 print_usage (); |
|
72 endif |
|
73 |
|
74 endfunction |