\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{nccpic}
         [2002/03/20 v1.03 NCC Extention of Graphicx (NCC)]
%
% \changes{v1.01}{2002/01/23}{This version is uploaded to CTAN}
% \changes{v1.02}{2002/02/17}{All options are passed to graphicx}
% \changes{v1.03}{2002/03/20}{\draftgraphics and \finalgraphics introduced}
%
% This package customizes graphics extensions list for most popular drivers,
% namely dvips, dvidpf, and dvipdfm, and for use with pdftex also. Extension
% lists contain extensions of graphics files which are processed on the fly
% without additional efforts.
%
% The package also sets graphics file search path to the current directory
% and \meta{graphics} subdirectory of the current directory.
%
% All options are passed to the graphicx package.
%
% Additionally, this package creates some commands for compartibility
% with NCC-LaTeX.
%
\DeclareOption*{\PassOptionsToPackage{\CurrentOption}{graphicx}}
\ProcessOptions\relax
\RequirePackage{graphicx}[1999/02/16]
\RequirePackage{nccboxes}[2002/01/09]
%
% Customize extension lists.
%
\def\@tempa{dvips.def}
\ifx\Gin@driver\@tempa
  \DeclareGraphicsExtensions{.eps,.ps,.bmp,.msp,.pcx,.pict,.pntg}
\else
  \def\@tempa{dvipdf.def}
  \ifx\Gin@driver\@tempa
    \DeclareGraphicsExtensions{.eps,.ps,.bmp,.msp,.jpg}
  \else
    \def\@tempa{dvipdfm.def}
    \ifx\Gin@driver\@tempa
      \DeclareGraphicsExtensions{.bmp}
%    \else
%      This case is commented because driver file sets proper extensions
%      \def\@tempa{pdftex.def}
%      \ifx\Gin@driver\@tempa
%        \DeclareGraphicsExtensions{.png,.mps,.tif,.pdf,.jpg}
%      \fi
    \fi
  \fi
\fi
\graphicspath{{graphics/}}
%
% NCC-LaTeX's graphics command.
%
%   \putimage(X,Y)[Xreal,Yreal](Xshift,Yshift){FILENAME}
%
% (X,Y)           -- dimensions of image box (in \unitlength).
% [Xreal,Yreal]   -- real dimensions of the image (in \unitlength).
% (Xshift,Yshift) -- shift of the image with respect the
%                    image box  (in \unitlength).
% FILENAME        -- name of graphics.
%
% Xreal:=X and Yreal:=Y if [Xreal,Yreal] is omitted.
% Xshifh:=0 and Yshifh:=0 if (Xshift,Yshift) is omitted.
%
% The image is vertically adjusted to the height of \Strut/0/ from
% the nccboxes package, i.e. the top of image box is aligned on the
% height of letter `A'.
%
% \drafgraphics and \finalgraphics commands toggles graphics output
% to draft or final. In draft mode, an graphic is replaced to a framebox of
% required size with a file name in its center.
%
\newcommand{\putimage}{} % Ensure the command was undefined before
\def\putimage(#1,#2){%
  \@ifnextchar[{\NCC@Gim(#1,#2)}{\NCC@Gim(#1,#2)[#1,#2]}%
}
\def\NCC@Gim(#1,#2)[#3,#4]{%
  \ifGin@draft
    \def\NCC@temp(##1,##2)##3{%
      \edef\@tempa{##3}%
      \put(0,0){%
        \framebox(#1,#2){\ttfamily\expandafter\strip@prefix\meaning\@tempa}%
      }%
    }%
  \else
    \def\NCC@temp(##1,##2)##3{%
      \put(##1,##2){%
        \includegraphics[width=#3\unitlength,height=#4\unitlength]{##3}%
      }%
    }%
  \fi
  \@ifnextchar({\NCC@Gim@(#1,#2)}{\NCC@Gim@(#1,#2)(0,0)}%
}
\def\NCC@Gim@(#1,#2)(#3,#4)#5{%
  \jvbox{\Strut/0/}[t]{%
    \begin{picture}(#1,#2)\NCC@temp(#3,#4){#5}\end{picture}%
  }%
}
\newcommand\draftgraphics{\Gin@drafttrue}
\newcommand\finalgraphics{\Gin@draftfalse}
%
% \ipic{file} is equivalent to \input{file.pic} with search in
% \graphicspath directory list. The file is opened within a
% group and the beginning and final spaces are removed in it.
%
\newcommand*{\ipic}[1]{%
  \begingroup \let\input@path\Ginput@path
    \ignorespaces\input{#1.pic}\unskip
  \endgroup
}
\endinput
