5364
|
1 ## Copyright (C) 2001 Paul Kienzle |
|
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 |
|
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. |
5364
|
14 ## |
|
15 ## You should have received a copy of the GNU General Public License |
5365
|
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. |
5364
|
19 |
5365
|
20 ## -*- texinfo -*- |
|
21 ## @deftypefn {Function File} {} orient (@var{orientation}) |
|
22 ## Set default print orientation. Valid values for @var{orientation} |
|
23 ## include @code{"landscape"} and @code{"portrait"}. If called with no |
|
24 ## arguments, return the default print orientation. |
|
25 ## @end deftypefn |
5364
|
26 |
5365
|
27 ## Author: Paul Kienzle |
|
28 ## Adapted-By: jwe |
5364
|
29 |
5365
|
30 ## PKG_ADD: mark_as_command orient |
|
31 |
6257
|
32 function retval = orient (varargin) |
5365
|
33 |
6257
|
34 nargs = nargin; |
5364
|
35 |
6257
|
36 if (nargs > 0 && ishandle (varargin{1})) |
|
37 cf = varargin{1}; |
|
38 varargin(1) = []; |
|
39 nargs--; |
|
40 else |
|
41 cf = gcf (); |
|
42 endif |
|
43 |
|
44 if (nargs == 0) |
|
45 retval = get (cf, "paperorientation"); |
5364
|
46 elseif (nargin == 1) |
6257
|
47 orientation = varargin{1}; |
5365
|
48 if (strcmp (orientation, "landscape") || strcmp (orientation, "portrait")) |
6257
|
49 set (cf, "paperorientation", orientation) |
5364
|
50 else |
|
51 error ("orient: unknown orientation"); |
|
52 endif |
|
53 else |
6046
|
54 print_usage (); |
5364
|
55 endif |
|
56 |
|
57 endfunction |
|
58 |
6257
|
59 %!assert(orient,"portrait") # default |
|
60 %!test orient('landscape') |
|
61 %!assert(orient,"landscape") # change to landscape |
5364
|
62 %!test orient('portrait') |
|
63 %!assert(orient,"portrait") # change to portrait |
|
64 %!fail("orient('nobody')","unknown orientation") |
6257
|
65 %!assert(orient,"portrait") # errors don't change the state |