########################################################################
##
## Copyright (C) 2020 The Octave Project Developers
##
## See the file COPYRIGHT.md in the top-level directory of this
## distribution or <https://octave.org/copyright/>.
##
## This file is part of Octave.
##
## Octave is free software: you can redistribute it and/or modify it
## under the terms of the GNU General Public License as published by
## the Free Software Foundation, either version 3 of the License, or
## (at your option) any later version.
##
## Octave is distributed in the hope that it will be useful, but
## WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
## GNU General Public License for more details.
##
## You should have received a copy of the GNU General Public License
## along with Octave; see the file COPYING.  If not, see
## <https://www.gnu.org/licenses/>.
##
########################################################################

## -*- texinfo -*-
## @deftypefn  {} {} xtickangle (@var{angle})
## @deftypefnx {} {@var{angle} =} xtickangle ()
## @deftypefnx {} {[@dots{}] =} xtickangle (@var{hax}, @dots{})
## Query or set the rotation angle of the tick labels on the x-axis of the current axis.
##
## When called without an argument, return the rotation angle in degrees
## of the tick labels as specified in the @qcode{"XTickLabelRotation"} axes property.
## This angle can be changed by calling @code{xtickangle} with a scalar value
## in degrees.
##
## If the first argument @var{hax} is an axes handle, then operate on
## this axis rather than the current axes returned by @code{gca}.
##
## Requesting a return value when calling @code{xtickangle} to set a property
## value will result in an error.
##
## @seealso{ytickangle, ztickangle, get, set}
## @end deftypefn

function varargout = xtickangle (varargin)

  [varargout{1:nargout}] = __tickangle__ (mfilename, varargin{:});

endfunction

%!test
%! hf = figure ("visible", "off");
%! hax = axes (hf);
%! unwind_protect
%!   xtickangle (45);
%!   assert (xtickangle (), 45);
%!   xtickangle (hax, 90);
%!   a1 = xtickangle ();
%!   a2 = xtickangle (hax);
%!   assert (a1, a2);
%!   assert (a1, 90);
%! unwind_protect_cleanup
%!   close (hf);
%! end_unwind_protect

## Test input validation
%!error <Invalid call> xtickangle (1, 2, 3)
%!error <function called with too many outputs> [a, b] = xtickangle ()
%!error <function called with too many outputs> [a, b] = xtickangle (1, 2, 3)
%!error <function called with too many outputs> a = xtickangle (45)
%!error <Invalid call> xtickangle (Inf)
%!error <Invalid call> xtickangle (NaN)
%!error <Invalid call> xtickangle (eye (2))
%!error <Invalid call> xtickangle ({90})
%!error <Invalid call> xtickangle (struct ("angle", 5))
%!error <Invalid call> xtickangle ("octave")
%!error <HAX must be a handle to an axes object> xtickangle (0, 45)
