7017
|
1 ## Copyright (C) 2001, 2005, 2006, 2007 Paul Kienzle |
5364
|
2 ## |
5365
|
3 ## This file is part of Octave. |
5364
|
4 ## |
5365
|
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 |
7016
|
7 ## the Free Software Foundation; either version 3 of the License, or (at |
|
8 ## your option) any later version. |
5365
|
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. |
5364
|
14 ## |
|
15 ## You should have received a copy of the GNU General Public License |
7016
|
16 ## along with Octave; see the file COPYING. If not, see |
|
17 ## <http://www.gnu.org/licenses/>. |
5364
|
18 |
5365
|
19 ## -*- texinfo -*- |
|
20 ## @deftypefn {Function File} {} orient (@var{orientation}) |
6895
|
21 ## Set the default print orientation. Valid values for |
|
22 ## @var{orientation} include @code{"landscape"} and @code{"portrait"}. |
|
23 ## If called with no arguments, return the default print orientation. |
5365
|
24 ## @end deftypefn |
5364
|
25 |
5365
|
26 ## Author: Paul Kienzle |
|
27 ## Adapted-By: jwe |
5364
|
28 |
5365
|
29 ## PKG_ADD: mark_as_command orient |
|
30 |
6257
|
31 function retval = orient (varargin) |
5365
|
32 |
6257
|
33 nargs = nargin; |
5364
|
34 |
6257
|
35 if (nargs > 0 && ishandle (varargin{1})) |
|
36 cf = varargin{1}; |
|
37 varargin(1) = []; |
|
38 nargs--; |
|
39 else |
|
40 cf = gcf (); |
|
41 endif |
|
42 |
|
43 if (nargs == 0) |
|
44 retval = get (cf, "paperorientation"); |
5364
|
45 elseif (nargin == 1) |
6257
|
46 orientation = varargin{1}; |
5365
|
47 if (strcmp (orientation, "landscape") || strcmp (orientation, "portrait")) |
6257
|
48 set (cf, "paperorientation", orientation) |
5364
|
49 else |
|
50 error ("orient: unknown orientation"); |
|
51 endif |
|
52 else |
6046
|
53 print_usage (); |
5364
|
54 endif |
|
55 |
|
56 endfunction |
|
57 |
6441
|
58 %!shared |
|
59 %! set (gcf (), "visible", "off") |
6257
|
60 %!assert(orient,"portrait") # default |
|
61 %!test orient('landscape') |
|
62 %!assert(orient,"landscape") # change to landscape |
5364
|
63 %!test orient('portrait') |
|
64 %!assert(orient,"portrait") # change to portrait |
|
65 %!fail("orient('nobody')","unknown orientation") |
6257
|
66 %!assert(orient,"portrait") # errors don't change the state |