% whizzytex.sty --- WhizzyTeX, a wysiwyg environment for TeX
%
%  Copyright (C) 2001, 2002 Didier Rémy
%
%  Author         : Didier Remy <Didier.Remy@inria.fr>
%  Version        : 1.1
%  Bug Reports    : whizzytex-bugs@pauillac.inria.fr
%  Web Site       : http://pauillac.inria.fr/whizzytex
% 
%  WhizzyTeX 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 2, or (at your option)
%  any later version.
%  
%  WhizzyTeX 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 
%  (enclosed in the file GPL).
%  
%  See the file COPYING enclosed with the distribution.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%  File whizzedit.sty (LaTeX macros)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% This example requires the a version of advi later than May 7
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\usepackage {advi}

\@ifundefined {whizzy@curfile}{}
    {\def \advi@edit@file {\whizzy@curfile}}
\@ifundefined {whizzy@thelineno}{}
    {\let \advi@edit@line \whizzy@thelineno}
%\def \advi@edit@line {\the \inputlineno}

\newdimen \wed@dim
\def \wed@id #1{#1}

\newcommand{\wedbox}[3][]{%
  \hbox \bgroup
  \advi@edit{\wedbox}{#1}{#2}[unit=1em]
  {}{}
  {\hbox {\kern \advi@edit@x\advi@edit@unit
     \vbox 
       {\vss
        \hbox {\hsize \advi@edit@w\advi@edit@unit
          {\vbox to \advi@edit@h\advi@edit@unit {#3}}}%
        \vskip \advi@edit@y\advi@edit@unit}}}%
  \egroup}

\def\wed@vbox #1#2#3#4#5#6{%
 \hbox \bgroup
 \advi@edit{#1}{#4}{#5}[#3]
  {\setbox0 \hbox{#6}%
    \wed@dim \ht0 \advance \wed@dim by \dp0
    \adviseth{\wed@dim}}
  {}
  {\hbox {\kern \advi@edit@x\advi@edit@unit
     \vbox to \wed@dim {\vss #2{\box0}\vskip \advi@edit@y\advi@edit@unit}}}%
  \egroup
}


\newcommand{\wedvbox}[3][]%
    {\wed@vbox{\wedvbox}{\wed@id}{unit=1em}{#1}{#2}{#3}}

\newcommand {\wedvspace}[2][]{%
  \advi@edit{\wedspace}{#1}{#2}[unit=1em]
    {\def \advi@edit@x{0}\def \advi@edit@y{0}%
     \def \advi@edit@w{1}}%
     {}%
     {\vspace {\advi@edit@h\advi@edit@unit}}}

\newcommand {\wedhspace}[2][]{%
  \advi@edit{\wedspace}{#1}{#2}[unit=1em]
    {\def \advi@edit@x{0}\def \advi@edit@y{0}%
     \def \advi@edit@h{1}}
    {}
    {\hspace {\advi@edit@w\advi@edit@unit}}}

\newcommand{\wedannot}[4][]{%
\advi@edit{\wedannot}{#1}{#2,w=1,h=1,unit=\bbb@unit}{}{}
{\adviannot{#3}(\advi@edit@x,\advi@edit@y){#4}}
}

\newcommand{\wedoval}[2][]{%
  \hbox \bgroup
  \def \advi@edit@x{0}\def \advi@edit@y{0}%
  \def \wed@@oval{\advi@edit{\wedoval}{#1}{#2}[unit=1em]{}{}}%
  \wed@oval}
\newcommand{\wed@oval}[3][]{%
  \wed@@oval
   {\hbox {\kern \advi@edit@x\advi@edit@unit
     \vbox %to  \advi@edit@h\advi@edit@unit
       {\vss
        \hbox {\hsize \advi@edit@w\advi@edit@unit
          {\vbox to \advi@edit@h\advi@edit@unit 
            {\vss \setbox0 \vbox to \advi@edit@h\advi@edit@unit {#3}% 
             \centerline {\ovalnode[#1]{#2}{\box0}}\vss}}}%
        \vskip \advi@edit@y\advi@edit@unit}}}%
  \egroup}

\newcommand{\wedput}[3][]{%
  \setbox0 \hbox {#3}%
  \advi@edit{\wedput}{#1}{#2}[unit=\psunit]
    {\wed@dim \ht0 \advance \wed@dim by \dp0 \adviseth{\wed@dim}%
     \advisetw{0.5\wd0}%
     \edef \advi@edit@tmp {\advi@edit@x}%
     \wed@dim \advi@edit@x\advi@edit@unit \advance \wed@dim by -0.5\wd0
     \advisetx {\wed@dim}%
     \edef \advi@edit@x {\advi@edit@tmp}%
    }
    {}
    {\rput (\advi@edit@x,\advi@edit@y){\box0}}%
}
