% This is 'beamerframescreenshot.sty' file
% Fri May 23 2008 - Christophe Lohr
% License LPPL and/or GPL
%
% 
% This package provides a [screenshot] option to the beamer frame
% environment.
% It is supposed to be used within workflow presented in beameruserguide.pdf 
% by section named
%    "Including Slides from the Presentation Version in the Article Version"
% (section 20.2.3 of the Beamer manual v 3.06)
% 
% In <presentation> mode, this option has no visible action:
% - it increments the 'framescreenshot' counter,
% - and sets this counter as the frame label (so, please do not use the
%   [label=..] option in with [screenshot]).
% 
% In <article> mode, this option:
% - does not typeset at all the frame content,
% - instead inserts a screenshot of this frame from the <presentation>
%   document (that has to be previously generated)
% 
% Notes:
% - The name of the <presentation> pdf document has to be given by
%   \setjobnamebeamerversion{...}
% - Usually, frame options are not evaluated in <article> mode. This package
%   force options to be evaluated even in <article> mode. So, this may have 
%   some side effects... sorry!
%
\ProvidesFile{beamerframescreenshot.sty}
\ProvidesPackage{beamerframescreenshot}

\RequirePackage{xkeyval}
\RequirePackage{ifthen} 

\newcounter{framescreenshot}

\define@boolkey{beamerframe}{screenshot}[true]{%
  \ifKV@beamerframe@screenshot
    \stepcounter{framescreenshot}
    \mode<presentation>{% 
      % Add [label=\theframescreenshot] to the curent frame
      % It's a copy-paste of body of \define@key{beamerframe}{label}{..}
      % because one can't use \setkey inside this key definition (recursity?)
      \def\beamer@againname{\theframescreenshot}% 
      {\let\@elt\beamer@labelsavecounter\beamer@overlaycounterresets}%
    }
    \mode<article>{%
	% Do not typset frame content in <article> mode
	\let\beamer@dosingleframe\beamer@donoframe%
	% Insert the pdf screenshot of this frame from the <beamer> document
        \smallskip
	\centerline{\fbox{\includeslide[width=.8\linewidth]{\theframescreenshot}}}
        \smallskip
    } % 
  \fi
}
\presetkeys{beamerframe}{screenshot=false}{}

% Force frame options evaluation in <article> mode
\mode<article>{\let\usual@beamer@@frame=\beamer@@frame%
  \long\def\beamer@@frame<#1>[#2]{%
	\setkeys{beamerframe}{#2}%
	\usual@beamer@@frame<#1>[#2]}

% From beamerbaseframe.sty
\define@key{beamerframe}{allowdisplaybreaks}[4]{}
\define@key{beamerframe}{allowframebreaks}[0.95]{}
\define@key{beamerframe}{squeeze}[]{}
\define@key{beamerframe}{shrink}[0]{}
\define@key{beamerframe}{label}[]{}
\define@key{beamerframe}{relabel}[]{}
\define@key{beamerframe}{plain}[true]{}
\define@key{beamerframe}{containsverbatim}[true]{}
\define@key{beamerframe}{fragile}[true]{}
\define@key{beamerframe}{c}[true]{}
\define@key{beamerframe}{t}[true]{}
\define@key{beamerframe}{b}[true]{}
\define@key{beamerframe}{environment}[]{}
\define@key{beamerframe}{typeset second}[true]{}

% From beamerthemeTELECOMBretagne.sty
\define@boolkey{beamerframe}{title}[true]{}
\define@key{beamerframe}{background}[]{}
\define@key{beamerframe}{title color}[]{}
}

%
% End of 'beamerframescreenshot.sty' file
