%%
%% This is file `efbox.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% efbox.dtx  (with options: `package')
%% 
%% This is a generated file.
%% 
%% Copyright (C) 2014 by José Romildo Malaquias <malaquias@gmail.com>
%% --------------------------------------------------------------------------
%% This work may be distributed and/or modified under the
%% conditions of the LaTeX Project Public License, either version 1.3
%% of this license or (at your option) any later version.
%% The latest version of this license is in
%%   http://www.latex-project.org/lppl.txt
%% and version 1.3 or later is part of all distributions of LaTeX
%% version 2005/12/01 or later.
%% 
\NeedsTeXFormat{LaTeX2e}[1999/12/01]
\ProvidesPackage{efbox}
    [2014/03/19 1.0 An enhanced fbox command.]
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{efbox}[2014/03/19 v1.0 An enhanced fbox command]
\RequirePackage{color}
\RequirePackage{pgfkeys}
\newif\if@efbox@leftline
\newif\if@efbox@rightline
\newif\if@efbox@topline
\newif\if@efbox@bottomline
\pgfkeys{
  /efbox/.cd,
  leftline/.is if           = @efbox@leftline,
  rightline/.is if          = @efbox@rightline,
  topline/.is if            = @efbox@topline,
  bottomline/.is if         = @efbox@bottomline,
  hidealllines/.style       = {leftline=false,rightline=false,topline=false,bottomline=false},
  backgroundcolor/.store in = \efbox@backgroundcolor,
  linecolor/.store in       = \efbox@linecolor,
  linewidth/.store in       = \efbox@linewidth,
  margin/.store in          = \efbox@margin,
  font/.store in            = \efbox@font,
  baselinestretch/.store in = \efbox@baselinestretch,
}
\pgfqkeys{/efbox}{
  leftline   = true,
  rightline  = true,
  topline    = true,
  bottomline = true,
  linecolor  = black,
  linewidth  = \fboxrule,
  margin     = \fboxsep,
}
\newif\if@efbox@hasframe
\def\efbox@global@options{}
\newcommand\efboxsetup[1]{%
  \def\efbox@global@options{#1}%
}%
\newcommand*\mypgfqkeys@with@saved@options[3]{%
  % #1 => path
  % #2 => macro holding saved options
  % #3 => keys
  \def\@pgfqkeys@##1{\pgfqkeys{#1}{##1}}%
  \expandafter\@pgfqkeys@\expandafter{#2,#3}%
}%
\newcommand\efbox[2][]{%
  \begingroup%
    \mypgfqkeys@with@saved@options{/efbox}{\efbox@global@options}{#1}%
    %\expandafter\pgfqkeys\expandafter{/efbox}\expandafter{\efbox@global@options,#1}%
    \ifdefined\efbox@font\efbox@font\fi
    \ifdefined\efbox@baselinestretch
      \def\baselinestretch{\efbox@baselinestretch}%
    \fi
    \@efbox@hasframefalse
    \if@efbox@topline\@efbox@hasframetrue\else\fi
    \if@efbox@bottomline\@efbox@hasframetrue\else\fi
    \if@efbox@leftline\@efbox@hasframetrue\else\fi
    \if@efbox@rightline\@efbox@hasframetrue\else\fi
    \ifdefined\efbox@backgroundcolor\@efbox@hasframetrue\else\fi
    \if@efbox@hasframe
      \ifdefined\efbox@backgroundcolor\else\def\efbox@backgroundcolor{white}\fi
      \fboxsep=\efbox@margin
      \fboxrule=\efbox@linewidth
      \let\@frameb@x\@my@frameb@x
      \fboxsep=\efbox@margin
      \def\efbox@body{\fcolorbox{\efbox@linecolor}{\efbox@backgroundcolor}{#2}}%
    \else
      \def\efbox@body{#2}%
    \fi
    \ifdefined\efbox@title
      \ifx\@empty\efbox@title
        \noindent\efbox@body
      \else
        \vbox{%
          \nobreak\vskip\fboxsep
          \rlap{\frametitle{\efbox@title}}%
          \nobreak\nointerlineskip
          \vskip-\baselineskip
          \vskip \fboxsep
          \noindent\efbox@body
        }%
      \fi
    \else
      \efbox@body
    \fi
  \endgroup
}
\def\@my@frameb@x#1{%
   \@tempdima\fboxrule
   \advance\@tempdima\fboxsep
   \advance\@tempdima\dp\@tempboxa
   \hbox{%
     \lower\@tempdima\hbox{%
       \vbox{%
\if@efbox@topline\hrule\@height\fboxrule\fi
\hbox{%
  \if@efbox@leftline\vrule\@width\fboxrule\fi
           #1%
           \vbox{%
             \vskip\fboxsep
             \box\@tempboxa
             \vskip\fboxsep}%
           #1%
           \if@efbox@rightline\vrule\@width\fboxrule\fi
}%
         \if@efbox@bottomline\hrule\@height\fboxrule\fi
       }%
     }%
   }%
}%
\endinput
%%
%% End of file `efbox.sty'.
