%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Makra TeX-owo-PostScript-owe obs/luguj/ace druk pejza/zowy,
% lustrzane odbicie i co si/e komu zamarzy w oparciu o DVIPS-ow/a
% zmienn/a bop-hook
%
%   BOP s.c.
%   ul. Piastowska 70, 80-363 Gda\'nsk, Poland
%   tel. +48 58 53-46-59
%   email: jacko@ipipan.gda.pl
%
%
% HISTORIA:
% wersja 0.5 z pi/atku, 13 stycznia 1995 r. po neutralizacji aktywnego ciach-a
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Makra u/zytkowe:
%
%   \papersize#1#2{... Ustalenie rozmiaru papieru. Poprawne warto/sci s/a
%                      spraw/a kluczow/a dla poprawnego dzia/lania pozosta/lych
%                      makr. Parametry oznaczaj/a: #1 -- szeroko/s/c,
%                      #2 -- wysoko/s/c strony wyra/zone w jednostkach TeX-owych.
%                      W pakiecie BOP-HAX ustala si/e domy/slny rozmiar A4.
%
%   \clearbophook{...  Inicjalizacja warto/sci zmiennej bop-hook. W zwyk/lych
%                      warunkach u/zytkownik nie ma potrzeby u/zywania
%                      tego makra.
%
%   \mirror{...        Odbicie lustrzane stron dokumentu.
%
%   \landscape{...     Orientacja pejza/zowa stron.
%
%   \hpfour{...        Neutralizacja b/l/edu GhostScript-u (wer, 2.60)
%                      pojegaj/acego na ignorowaniu pionowego przesuni/ecia
%                      (offset) zawarto/sci strony w rozdzielczo/sci 600 dpi.
%
%   \userbophook#1{... Mo/zliwo/s/c dopisywania w/lasnych tre/sci do zmiennej
%                      bop-hook.
%
% UWAGA:
%   Makra \mirror oraz \hpfour powinny poprzedza/c \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/s/c dopisywana
  [#1 where {pop #1 load aload pop} if {#2} aload pop] cvx #1 exch def }
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Rozmiar papieru
%   Niezb/edne obliczenia: szeroko/s/c i wysoko/s/c papieru
%   wyra/zone zostaj/a 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/z
%
\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/l/edu GhostScript-a (wer. 2.60)
% polegaj/acego na ignorowaniu pionowego offsetu w rozdzielczo/sci 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/lasny bop-hook u/zytkownika
%
\def\userbophook#1{%
  \special{!userdict begin \PSprocappend {/bop-hook}{#1} end }}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Domy/slne rozmiary papieru okre/slaj/a format A4.
%
\papersize{210mm}{297mm}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\catcode`\/\slashcatcode
%
\endinput
