Mercurial > hg > octave-lyh
diff scripts/plot/orient.m @ 6257:44c91c5dfe1d
[project @ 2007-01-30 19:16:52 by jwe]
author | jwe |
---|---|
date | Tue, 30 Jan 2007 19:16:55 +0000 |
parents | 34f96dd5441b |
children | 8bcceddab2d5 |
line wrap: on
line diff
--- a/scripts/plot/orient.m +++ b/scripts/plot/orient.m @@ -29,15 +29,24 @@ ## PKG_ADD: mark_as_command orient -function retval = orient (orientation) +function retval = orient (varargin) - static __print_orientation__ = "landscape"; + nargs = nargin; - if (nargin == 0) - retval = __print_orientation__; + if (nargs > 0 && ishandle (varargin{1})) + cf = varargin{1}; + varargin(1) = []; + nargs--; + else + cf = gcf (); + endif + + if (nargs == 0) + retval = get (cf, "paperorientation"); elseif (nargin == 1) + orientation = varargin{1}; if (strcmp (orientation, "landscape") || strcmp (orientation, "portrait")) - __print_orientation__ = orientation; + set (cf, "paperorientation", orientation) else error ("orient: unknown orientation"); endif @@ -47,10 +56,10 @@ endfunction -%!assert(orient,"landscape") # default +%!assert(orient,"portrait") # default +%!test orient('landscape') +%!assert(orient,"landscape") # change to landscape %!test orient('portrait') %!assert(orient,"portrait") # change to portrait -%!test orient('landscape') -%!assert(orient,"landscape") # change to landscape %!fail("orient('nobody')","unknown orientation") -%!assert(orient,"landscape") # errors don't change the state +%!assert(orient,"portrait") # errors don't change the state