Mercurial > hg > octave-lyh
comparison scripts/plot/graphics_toolkit.m @ 14724:395d238418a7
Allow graphics_toolkit (h) to return the value for specified figures.
* graphics_toolkit: Support "kits = graphics_toolkit (h)."
Improve documentation. Modify test.
author | Ben Abbott <bpabbott@mac.com> |
---|---|
date | Mon, 04 Jun 2012 20:55:25 -0400 |
parents | f3d52523cde1 |
children | 53d2c3598d33 |
comparison
equal
deleted
inserted
replaced
14723:3fd6f637c573 | 14724:395d238418a7 |
---|---|
16 ## along with Octave; see the file COPYING. If not, see | 16 ## along with Octave; see the file COPYING. If not, see |
17 ## <http://www.gnu.org/licenses/>. | 17 ## <http://www.gnu.org/licenses/>. |
18 | 18 |
19 ## -*- texinfo -*- | 19 ## -*- texinfo -*- |
20 ## @deftypefn {Function File} {@var{name} =} graphics_toolkit () | 20 ## @deftypefn {Function File} {@var{name} =} graphics_toolkit () |
21 ## @deftypefnx {Function File} {@var{old_name} =} graphics_toolkit (@var{name}) | 21 ## Returns the default graphics toolkit. The default graphics toolkit value |
22 ## is assigned to new figures. | |
23 ## @deftypefnx {Function File} {@var{name} =} graphics_toolkit (@var{hlist}) | |
24 ## Returns the graphics toolkits for the figures with handles @var{hlist}. | |
25 ## @deftypefnx {Function File} {} graphics_toolkit (@var{name}) | |
26 ## Sets the default graphics toolkit to @var{name}. If the toolkit is not | |
27 ## already loaded, it is initialized by calling the function | |
28 ## @code{__init_@var{name}__}. | |
22 ## @deftypefnx {Function File} {} graphics_toolkit (@var{hlist}, @var{name}) | 29 ## @deftypefnx {Function File} {} graphics_toolkit (@var{hlist}, @var{name}) |
23 ## Query or set the default graphics toolkit to @var{name}. If the | 30 ## Sets the graphics toolkit for the figues with handles @var{hlist} to |
24 ## toolkit is not already loaded, it is first initialized by calling the | 31 ## @var{name}. |
25 ## function @code{__init_@var{name}__}. | |
26 ## | |
27 ## When called with a list of figure handles, @var{hlist}, the graphics | |
28 ## toolkit is changed only for the listed figures. | |
29 ## @seealso{available_graphics_toolkits} | 32 ## @seealso{available_graphics_toolkits} |
30 ## @end deftypefn | 33 ## @end deftypefn |
31 | 34 |
32 function retval = graphics_toolkit (name, hlist = []) | 35 function retval = graphics_toolkit (name, hlist = []) |
33 | 36 |
40 endif | 43 endif |
41 | 44 |
42 if (nargin == 0) | 45 if (nargin == 0) |
43 return; | 46 return; |
44 elseif (nargin == 1) | 47 elseif (nargin == 1) |
45 if (! ischar (name)) | 48 if (all (isfigure (name))) |
49 hlist = name; | |
50 retval = get (hlist, "__graphics_toolkit__"); | |
51 return | |
52 elseif (! ischar (name)) | |
46 error ("graphics_toolkit: invalid graphics toolkit NAME"); | 53 error ("graphics_toolkit: invalid graphics toolkit NAME"); |
47 endif | 54 endif |
48 elseif (nargin == 2) | 55 elseif (nargin == 2) |
49 ## Swap input arguments | 56 ## Swap input arguments |
50 [hlist, name] = deal (name, hlist); | 57 [hlist, name] = deal (name, hlist); |
75 %! unwind_protect | 82 %! unwind_protect |
76 %! hf = figure ("visible", "off"); | 83 %! hf = figure ("visible", "off"); |
77 %! toolkit = graphics_toolkit (); | 84 %! toolkit = graphics_toolkit (); |
78 %! assert (get (0, "defaultfigure__graphics_toolkit__"), toolkit); | 85 %! assert (get (0, "defaultfigure__graphics_toolkit__"), toolkit); |
79 %! graphics_toolkit (hf, "fltk"); | 86 %! graphics_toolkit (hf, "fltk"); |
80 %! assert (get (hf, "__graphics_toolkit__"), "fltk"); | 87 %! assert (graphics_toolkit (hf), "fltk"); |
81 %! unwind_protect_cleanup | 88 %! unwind_protect_cleanup |
82 %! close (hf); | 89 %! close (hf); |
83 %! end_unwind_protect | 90 %! end_unwind_protect |
84 | 91 |
85 %!testif HAVE_FLTK | 92 %!testif HAVE_FLTK |