% Copyright 2006 by Till Tantau
%
% This file may be distributed and/or modified
%
% 1. under the LaTeX Project Public License and/or
% 2. under the GNU Public License.
%
% See the file doc/generic/pgf/licenses/LICENSE for more details.

\ProvidesFileRCS[v\pgfversion] $Header: /cvsroot/pgf/pgf/generic/pgf/frontendlayer/tikz/libraries/tikzlibraryautomata.code.tex,v 1.3 2008/07/14 10:30:36 tantau Exp $

\usetikzlibrary{shapes.multipart}

% Styles for states:

\tikzstyle{every state}=           []

\tikzstyle{state without output}=  [circle,draw,minimum size=2.5em,every state]
\tikzstyle{state with output}=     [circle split,draw,minimum size=2.5em,every state]

\tikzstyle{accepting by arrow}=    [after node path=
{
  {
    [to path=
    {
      [->,double=none,every accepting by arrow]
      --
      ([shift=(\tikz@accepting@angle:\tikz@accepting@distance)]\tikztostart.\tikz@accepting@angle)
          node [shape=rectangle,anchor=\tikz@accepting@anchor] {\tikz@accepting@text}
      }]
    edge ()
  }
}]
\tikzstyle{every accepting by arrow}=[]
\tikzstyle{accepting by double}= [double,outer sep=.5\pgflinewidth+.3pt] % .3pt is half double width distance

\tikzstyle{initial by arrow}=   [after node path=
{
  {
    [to path=
    {
      [->,double=none,every initial by arrow]
      ([shift=(\tikz@initial@angle:\tikz@initial@distance)]\tikztostart.\tikz@initial@angle)
          node [shape=rectangle,anchor=\tikz@initial@anchor] {\tikz@initial@text}
        -- (\tikztostart)}]
    edge ()
  }
}]
\tikzstyle{every initial by arrow}=[]

\tikzstyle{initial by diamond}=[shape=diamond]


\tikzoption{initial text}{\tikzaddafternodepathoption{\def\tikz@initial@text{#1}}}
\tikzoption{accepting text}{\tikzaddafternodepathoption{\def\tikz@accepting@text{#1}}}

\tikzoption{initial where}{\tikzaddafternodepathoption{\csname tikz@initial@compute@#1\endcsname}}
\tikzoption{accepting where}{\tikzaddafternodepathoption{\csname tikz@accepting@compute@#1\endcsname}}

\tikzoption{initial distance}{\tikzaddafternodepathoption{\def\tikz@initial@distance{#1}}}
\tikzoption{accepting distance}{\tikzaddafternodepathoption{\def\tikz@accepting@distance{#1}}}

\def\tikz@initial@text{start}
\def\tikz@accepting@text{}

\def\tikz@initial@distance{3ex}
\def\tikz@accepting@distance{3ex}

\def\tikz@initial@compute@above{\def\tikz@initial@angle{90}\def\tikz@initial@anchor{south}}
\def\tikz@initial@compute@below{\def\tikz@initial@angle{270}\def\tikz@initial@anchor{north}}
\def\tikz@initial@compute@left{\def\tikz@initial@angle{180}\def\tikz@initial@anchor{east}}
\def\tikz@initial@compute@right{\def\tikz@initial@angle{0}\def\tikz@initial@anchor{west}}

\def\tikz@initial@angle{180}
\def\tikz@initial@anchor{east}

\def\tikz@accepting@compute@above{\def\tikz@accepting@angle{90}\def\tikz@accepting@anchor{south}}
\def\tikz@accepting@compute@below{\def\tikz@accepting@angle{270}\def\tikz@accepting@anchor{north}}
\def\tikz@accepting@compute@left{\def\tikz@accepting@angle{180}\def\tikz@accepting@anchor{east}}
\def\tikz@accepting@compute@right{\def\tikz@accepting@angle{0}\def\tikz@accepting@anchor{west}}

\def\tikz@accepting@angle{0}
\def\tikz@accepting@anchor{west}


\tikzstyle{initial above}=        [initial by arrow,initial where=above]
\tikzstyle{initial below}=        [initial by arrow,initial where=below]
\tikzstyle{initial left}=         [initial by arrow,initial where=left]
\tikzstyle{initial right}=        [initial by arrow,initial where=right]

\tikzstyle{accepting above}=      [accepting by arrow,accepting where=above]
\tikzstyle{accepting below}=      [accepting by arrow,accepting where=below]
\tikzstyle{accepting left}=       [accepting by arrow,accepting where=left]
\tikzstyle{accepting right}=      [accepting by arrow,accepting where=right]


% Defaults:

\tikzstyle{state}=                [state without output]
\tikzstyle{accepting}=            [accepting by double]
\tikzstyle{initial}=              [initial by arrow]



\endinput
