%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Makra TeX-owo-PostScript-owe obs�uguj�ce druk pejza�owy,
% lustrzane odbicie i co si� komu zamarzy w oparciu o DVIPS-ow�
% zmienn� bop-hook
%   
% BOP s. c. Gda�sk, ul. Tatrza�ska 6/1,    tel. 56-78-77
%           Sopot, al. Niepodleg�o�ci 606/610,
%           tel. (+48 58) 51-32-14 do 16 w. 55
%           fax  (+48 58) 51-40-53
%   
% HISTORIA:  
% wersja 0.5 z pi�tku, 13 stycznia 1995 r. po neutralizacji aktywnego ciach-a
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Makra u�ytkowe:
%
%   \papersize#1#2{... Ustalenie rozmiaru papieru. Poprawne warto�ci s�
%                      spraw� kluczow� dla poprawnego dzia�ania pozosta�ych
%                      makr. Parametry oznaczaj�: #1 -- szeroko��, 
%                      #2 -- wysoko�� strony wyra�one w jednostkach TeX-owych.
%                      W pakiecie BOP-HAX ustala si� domy�lny rozmiar A4.
%
%   \clearbophook{...  Inicjalizacja warto�ci zmiennej bop-hook. W zwyk�ych
%                      warunkach u�ytkownik nie ma potrzeby u�ywania 
%                      tego makra.
%
%   \mirror{...        Odbicie lustrzane stron dokumentu.
%
%   \landscape{...     Orientacja pejza�owa stron. 
%
%   \hpfour{...        Neutralizacja b��du GhostScript-u (wer, 2.60)
%                      pojegaj�cego na ignorowaniu pionowego przesuni�cia
%                      (offset) zawarto�ci strony w rozdzielczo�ci 600 dpi.
%
%   \userbophook#1{... Mo�liwo�� dopisywania w�asnych tre�ci do zmiennej
%                      bop-hook.
%
% UWAGA:
%   Makra \mirror oraz \hpfour powinny poprzedza� \landscape
%   w przypadku wykorzystywania ich w jednym dokumencie.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\edef\slashcatcode{\the\catcode`\/}
\catcode`\/12
%
\newdimen\bigpoint \bigpoint 1bp
\newdimen\paperwidth
\newdimen\paperheight
\newcount\paperwidthcount
\newcount\paperheightcount
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Inicjalizacja zmiennej bop-hook
%
\def\clearbophook{%
  \special{!userdict begin /bop-hook {} def end }}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Rozszerzanie definicji procedury PS-owej
%
\def\PSprocappend#1#2{% #1 -- literal, #2 -- tre�� dopisywana
  [#1 where {pop #1 load aload pop} if {#2} aload pop] cvx #1 exch def }
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Rozmiar papieru
%   Niezb�dne obliczenia: szeroko�� i wysoko�� papieru 
%   wyra�one zostaj� w jednostkach PS.
%
\def\papersize#1#2{%
  \paperwidth #1 \divide\paperwidth by \bigpoint
  \paperwidthcount\paperwidth
  \paperheight #2 \divide\paperheight by \bigpoint
  \paperheightcount\paperheight }
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Lustro
%
\def\mirror{%
  \special{!userdict begin \PSprocappend {/bop-hook}
    {[-1 0 0 1 \the\paperwidthcount\space 0] concat} end }}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Pejza�
%
\def\landscape{%
  \special{!userdict begin \PSprocappend {/bop-hook}
     {[0 -1 1 0 \the\paperwidthcount\space \the\paperheightcount\space sub
     \the\paperheightcount] concat} end }}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Specjalny \special do eliminacji b��du GhostScript-a (wer. 2.60)
% polegaj�cego na ignorowaniu pionowego offsetu w rozdzielczo�ci 600 dpi
%
\def\hpfour{%
  \special{!userdict begin \PSprocappend {/bop-hook}
    {gsave 0.2 setlinewidth
    10 \the\paperheightcount\space 1 add moveto 10 0 rlineto stroke
    grestore
    currentscreen 3 -1 roll pop 85 3 1 roll setscreen
    } end }}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% W�asny bop-hook u�ytkownika
%
\def\userbophook#1{%
  \special{!userdict begin \PSprocappend {/bop-hook}{#1} end }}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Domy�lne rozmiary papieru okre�laj� format A4.
%
\papersize{210mm}{297mm}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\catcode`\/\slashcatcode
%
\endinput
