%% LaTeX class file for QSL card side
%% Copylight (C) 2022 Nobuyuki YARA / JJ1XOF
%%
\NeedsTeXFormat{pLaTeX2e}
\ProvidesClass{qsl-rev1}

\LoadClass[]{article}
\usepackage{plext}
\usepackage{xstring}
\ifx\kanjiskip\undefined\else
  \usepackage{atbegshi}
  \ifx\ucs\undefined
    \ifnum 42146=\euc"A4A2
      \AtBeginShipoutFirst{\special{pdf:tounicode EUC-UCS2}}
    \else
      \AtBeginShipoutFirst{\special{pdf:tounicode 90ms-RKSJ-UCS2}}
    \fi
  \else
    \AtBeginShipoutFirst{\special{pdf:tounicode UTF8-UCS2}}
  \fi
  \usepackage[dvipdfmx]{hyperref}

  %% Set a paper size for dvipdfmx
  \special{papersize=100truemm,148truemm}
\fi


%% Layouts
\setlength{\hoffset}{-1truein}
\setlength{\voffset}{-1truein}
\setlength{\oddsidemargin}{0pt}
\setlength{\evensidemargin}{0pt}
\setlength{\topmargin}{0pt}
\setlength{\topmargin}{0pt}
\setlength{\headheight}{0pt}
\setlength{\headsep}{0pt}
\setlength{\paperwidth}{100truemm}
\setlength{\paperheight}{148truemm}

\setlength{\tabcolsep}{0pt}
\setlength\tabbingsep{0pt}
\setlength{\unitlength}{1truemm} %


%% \qsodata : command for QSO basic information 
%%
%%    % #1 : Callsign of counter part station
%%    % #2 : QSL card serial number
%%    % #3 : QSO year
%%    % #4 : QSO month
%%    % #5 : QSO date
%%    % #6 : QSO time
%%    % #7 : my RST report
%%    % #8 : Frequency
%%    % #9 : mode
 \newcommand{\qsodata}[9] {

  \clearpage
  \refstepcounter{section}
  \addcontentsline{toc}{section}{#1}
  \noindent %
  \begin{picture}(100,148)(0,0)%

  % #1 : Callsign of counter part station
    \put(18.5,134){ %
      \vtop to 9truemm{\vfil\hbox{\fontsize{15pt}{0pt}\selectfont%
        \hbox to 6.5truemm{\hfil\StrChar{#1}{1}\hfil}\hskip2.5truemm
        \hbox to 6.5truemm{\hfil\StrChar{#1}{2}\hfil}\hskip2.5truemm
        \hbox to 6.5truemm{\hfil\StrChar{#1}{3}\hfil}\hskip2.5truemm
        \hbox to 6.5truemm{\hfil\StrChar{#1}{4}\hfil}\hskip2.5truemm
        \hbox to 6.5truemm{\hfil\StrChar{#1}{5}\hfil}\hskip2.5truemm
        \hbox to 6.5truemm{\hfil\StrChar{#1}{6}\hfil}\hskip2.5truemm
        \hbox to 6.5truemm{\hfil\StrChar{#1}{7}\hfil}\hskip2.5truemm
        \hbox to 6.5truemm{\hfil\StrChar{#1}{8}\hfil}%
    }\vfil}}

  % #2 : QSL card serial number
    \put(79,118){\fontsize{9pt}{0pt}\selectfont%
        \hbox to 10.5truemm{\hfil#2\hfil}
        }

  % #3 : QSO year
    \put(5,102){\fontsize{9pt}{0pt}\selectfont%
        \hbox to 10.5truemm{\hfil#3\hfil}
        }

  % #4 : QSO month
    \put(15.5,102){\fontsize{9pt}{0pt}\selectfont%
        \hbox to 9.5truemm{\hfil#4\hfil}
        }

  % #5 : QSO date
    \put(25,102){\fontsize{9pt}{0pt}\selectfont%
        \hbox to 9.5truemm{\hfil#5\hfil}
        }

  % #6 : QSO time
    \put(34,102){\fontsize{9pt}{0pt}\selectfont%
        \hbox to 14.5truemm{\hfil#6\hfil}
        }

  % #7 : my RST report
    \put(49,102){\fontsize{9pt}{0pt}\selectfont%
        \hbox to 12.5truemm{\hfil#7\hfil}
        }

  % #8 : Freqency
    \put(61,102){\fontsize{9pt}{0pt}\selectfont%
        \hbox to 17truemm{\hfil#8\hfil}
        }

  % #9 : mode
    \put(77,102){\fontsize{9pt}{0pt}\selectfont%
        \hbox to 17truemm{\hfil#9\hfil}
        }
        
}

%% \qsoremarks : command for Remaks and supplemental information 
%%
%%    % #1 : checkmark for PSE QSL
%%    % #2 : checkmark for QSL TNX
%%    % #3 : Rig info.
%%    % #4 : Power
%%    % #5 : Antenna info.
%%    % #6 : Remark comment 1
%%    % #7 : Remark comment 2 
\newcommand{\qsoremarks}[7] {

%%    % #1 : checkmark for PSE QSL
    \put(5.5,95.5){\fontsize{9pt}{0pt}\selectfont%
        \hbox to 3.5truemm{\hfil#1\hfil}
        }

%%    % #2 : checkmark for QSL TNX
    \put(42,95.5){\fontsize{9pt}{0pt}\selectfont%
        \hbox to 3.5truemm{\hfil#2\hfil}
        }

%%    % #3 : Rig info.
    \put(13,89.5){\fontsize{9pt}{0pt}\selectfont%
        \hbox to 70truemm{#3\hfil}
        }

%%    % #4 : Power
    \put(84,89.5){\fontsize{9pt}{0pt}\selectfont%
        \hbox to 6truemm{#4\hfil}
        }

%%    % #5 : Antenna info.
    \put(13,82){\fontsize{9pt}{0pt}\selectfont%
        \hbox to 80truemm{#5\hfil}
        }

%%    % #6 : Remark comment 1
    \put(13,74.5){\fontsize{9pt}{0pt}\selectfont%
        \hbox to 80truemm{#6\hfil}
        }

%%    % #7 : Remark comment 2 
    \put(13,70){\fontsize{9pt}{0pt}\selectfont%
        \hbox to 80truemm{#7\hfil}
        }
}

%% \qslfooter : command for additional comment and fixed op. info. 
%%
%%    % #1 : additional comment 1
%%    % #2 : additional comment 2
%%    % #3 : additional comment 3

\newcommand{\qslfooter}[3] {

%%    % #1 : additional comment 1
    \put(5.5,60){\fontsize{9pt}{0pt}\selectfont%
        \hbox to 80truemm{#1\hfil}
        }

%%    % #2 : additional comment 2
    \put(5.5,56){\fontsize{9pt}{0pt}\selectfont%
        \hbox to 80truemm{#2\hfil}
        }

%%    % #3 : additional comment 3
    \put(5.5,52){\fontsize{9pt}{0pt}\selectfont%
        \hbox to 80truemm{#3\hfil}
        }

% fixed op. info 1
    \put(5.5,48){\fontsize{8pt}{0pt}\selectfont%
        \hbox to 80truemm{Op. 屋良信幸 / Nobuyuki YARA / jj1xof@jarl.com\hfil}
        }
% fixed op. info 2
    \put(5.5,44){\fontsize{8pt}{0pt}\selectfont%
        \hbox to 80truemm{twitter: @hyllique / フリラーコール: べっぷFB026 \hfil}
        }

% fixed op. info 3
    \put(5.5,40){\fontsize{8pt}{0pt}\selectfont%
        \hbox to 80truemm{常置場所: 東京都江東区(****) / Koto City Tokyo, Japan\hfil}
        }
        
% printing info.
    \put(5.5,36){\fontsize{8pt}{0pt}\selectfont%
        \hbox to 80truemm{Log managed with MacLoggerDX / QSL typeset with \LaTeXe \hfil}
        }
}

\newcommand{\closeqsl} [0] {
  \end{picture} %
}

