% !TEX TS-program = XeLaTeX
% !TeX root = presentation.tex
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% This is 'saahel.sty' the 'Saahel' Style for bidipresentation. v0.3
%% By: S. Razi Alavizadeh <s.r.alavizadeh@gmail.com>
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% This is based on `sidebarbidipres.sty',
%% by: AR Hashemi, <Nekoomehr@gmail.com>
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
%% 
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{saahel}%
[2012/12/21 Saahel Style with sidebar for using with bidipresentation class]
\usepackage[RL]{flowfram}
\usepackage{eso-pic}
\usepackage{graphicx}
\usepackage{zref-lastpage,zref-user}
\geometry{paperwidth=225mm,paperheight=180mm,rmargin=40mm,top=10mm,bottom=10mm}
% to have access to the total number of sections
\usepackage{totcount}                       % http://ctan.org/pkg/totcount
\regtotcounter{section}
%% auxiliary lengths for the height of the frame and the width of each tab
\newlength\frameheight
\newlength\avgtabwidth
% remove TOC's title
\let\oldTOC\tableofcontents
\renewcommand{\tableofcontents}{\renewcommand{\contentsname}{}\oldTOC}
%% some definitions
%% redefinition of titlepage environment %\thispagestyle{empty}
\let\oldTitePage\titlepage
\renewenvironment{titlepage}{\begin{oldTitePage}\begin{rawslide}\setcounter{page}{0}}%
{\end{rawslide}\end{oldTitePage}}
%-----------------------------------------------------------------------------------------%
\newenvironment{page}{\begin{rawslide}\addtocounter{page}{-1}}%
{\end{rawslide}}
%-----------------------------------------------------------------------------------------%
% blocks
%بلوک همرنگ تم اصلی محیط
\tikzstyle{blockStyle} = [draw=themeColor!80, fill=themeColor!9, very thick,
    rectangle, rounded corners=3mm, inner sep=10pt, inner ysep=20pt]
\tikzstyle{blockTitleStyle} =[fill=themeColor!80, rectangle, rounded corners=2mm, text=white
, inner sep=10pt, inner ysep=7pt, left=10pt]
%%%%%%%%%
\newenvironment{block}[1]{%
  \def\blockTitle{\hboxR{{\Large{#1}}}}%
  \begin{tikzpicture}
    \node [blockStyle] (box)
    \bgroup\setRTL\minipage{0.95\textwidth}\vspace{10pt}%
}{
    \endminipage%
    \egroup;
    \node[blockTitleStyle] at (box.north east) {\blockTitle};
  \end{tikzpicture}%
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%بلوک قرمز
\tikzstyle{alertblock} = [draw=red!80, fill=red!12, very thick,
    rectangle, rounded corners=3mm, inner sep=10pt, inner ysep=20pt]
\tikzstyle{alertTitle} =[fill=red!80, rectangle, rounded corners=2mm, text=white
, inner sep=10pt, inner ysep=7pt, left=10pt]
%%%%%%%%%
\newenvironment{alertblock}[1]{%
  \def\blockTitle{\hboxR{{\Large{#1}}}}%
  \begin{tikzpicture}
    \node [alertblock] (box)
    \bgroup\setRTL\minipage{0.95\textwidth}\vspace{10pt}%
}{
    \endminipage%
    \egroup;
    \node[alertTitle] at (box.north east) {\blockTitle};
  \end{tikzpicture}%
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% محیط قضیه
\tikzstyle{myghazye} = [draw=magenta, fill=magenta!12, very thick,
    rectangle, rounded corners=3mm, inner sep=10pt, inner ysep=20pt]
\tikzstyle{fancytitleghazye} =[fill=magenta!80, rectangle, rounded corners=2mm, text=white
, inner sep=10pt, inner ysep=7pt, left=10pt]
%%%%%%%
 \newenvironment{myghazye}[1]{%
  \def\blockTitle{\hboxR{{\Large{قضیه }{#1}}}}%
  \begin{tikzpicture}
    \node [myghazye] (box)
    \bgroup\setRTL\minipage{0.95\textwidth}\vspace{10pt}%
}{
    \endminipage%
    \egroup;
    \node[fancytitleghazye] at (box.north east) {\blockTitle};
  \end{tikzpicture}%
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%گزاره
\tikzstyle{mygozare} = [draw=orange, fill=orange!12, very thick,
    rectangle, rounded corners=3mm, inner sep=10pt, inner ysep=20pt]
\tikzstyle{fancytitlegozare} =[fill=orange, rectangle, rounded corners=2mm, text=white
, inner sep=10pt, inner ysep=7pt, left=10pt]
%%%%%%%
  \newenvironment{mygozare}[1]{%
  \def\blockTitle{\hboxR{{\Large{گزاره }{#1}}}}%
  \begin{tikzpicture}
    \node [mygozare] (box)
    \bgroup\setRTL\minipage{0.95\textwidth}\vspace{10pt}%
}{
    \endminipage%
    \egroup;
    \node[fancytitlegozare] at (box.north east) {\blockTitle};
  \end{tikzpicture}%
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%لم
\tikzstyle{mylem} = [draw=purple, fill=purple!12, very thick,
    rectangle, rounded corners=3mm, inner sep=10pt, inner ysep=20pt]
\tikzstyle{fancytitlelem} =[fill=purple, rectangle, rounded corners=2mm, text=white
, inner sep=10pt, inner ysep=7pt, left=10pt]
%%%%%%%
 \newenvironment{mylem}[1]{%
  \def\blockTitle{\hboxR{{\Large{لم }{#1}}}}%
  \begin{tikzpicture}
    \node [mylem] (box)
    \bgroup\setRTL\minipage{0.95\textwidth}\vspace{10pt}%
}{
    \endminipage%
    \egroup;
    \node[fancytitlelem] at (box.north east) {\blockTitle};
  \end{tikzpicture}%
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% محیط تعریف
\tikzstyle{mytarif} = [draw=orange, fill=orange!10, very thick,
    rectangle, rounded corners=3mm, inner sep=10pt, inner ysep=20pt]
\tikzstyle{fancytitletarif} =[fill=orange!80, rectangle, rounded corners=2mm, text=white
, inner sep=10pt, inner ysep=7pt, left=10pt]
%%%%%%%
 \newenvironment{mytarif}[1]{%
  \def\blockTitle{\hboxR{{\Large{تعریف }{#1}}}}%
  \begin{tikzpicture}
    \node [mytarif] (box)
    \bgroup\setRTL\minipage{0.95\textwidth}\vspace{10pt}%
}{
    \endminipage%
    \egroup;
    \node[fancytitletarif] at (box.north east) {\blockTitle};
  \end{tikzpicture}%
}
%%%%%%%
 \newenvironment{mytarif*}[1]{%
  \def\blockTitle{\hboxR{{\Large{ادامه تعریف }{#1}}}}%
  \begin{tikzpicture}
    \node [mytarif] (box)
    \bgroup\setRTL\minipage{0.95\textwidth}\vspace{10pt}%
}{
    \endminipage%
    \egroup;
    \node[fancytitletarif] at (box.north east) {\blockTitle};
  \end{tikzpicture}%
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% محیط مثال
\tikzstyle{mymesal} = [draw=blue!80, fill=blue!10, very thick,
    rectangle, rounded corners=3mm, inner sep=10pt, inner ysep=20pt]
\tikzstyle{fancytitlemesal} =[fill=blue!80, rectangle, rounded corners=2mm, text=white
, inner sep=10pt, inner ysep=7pt, left=10pt]
%%%%%%%%%
  \newenvironment{mymesal}[1]{%
  \def\blockTitle{\hboxR{{\Large{مثال }{#1}}}}%
  \begin{tikzpicture}
    \node [mymesal] (box)
    \bgroup\setRTL\minipage{0.95\textwidth}\vspace{10pt}%
}{
    \endminipage%
    \egroup;
    \node[fancytitlemesal] at (box.north east) {\blockTitle};
  \end{tikzpicture}%
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% محیط فرضیه
\tikzstyle{myfarz} = [draw=lime, fill=lime!10, very thick,
    rectangle, rounded corners=3mm, inner sep=10pt, inner ysep=20pt]
\tikzstyle{fancytitlefarz} =[fill=lime, rectangle, rounded corners=2mm, text=white
, inner sep=10pt, inner ysep=7pt, left=10pt]
%%%%%%%%%
  \newenvironment{myfarz}[1]{%
  \def\blockTitle{\hboxR{{\Large{فرضیه }{#1}}}}%
  \begin{tikzpicture}
    \node [myfarz] (box)
    \bgroup\setRTL\minipage{0.95\textwidth}\vspace{10pt}%
}{
    \endminipage%
    \egroup;
    \node[fancytitlefarz] at (box.north east) {\blockTitle};
  \end{tikzpicture}%
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%بلوک بدون عنوان
\tikzstyle{m} = [draw=pink, fill=pink!12, very thick,
    rectangle, rounded corners=3mm, inner sep=10pt, inner ysep=20pt]
%%%%%%%
 \newenvironment{m}[1]{%
  \begin{tikzpicture}
    \node [m] (box)
    \bgroup\setRTL\minipage{0.95\textwidth}\vspace{10pt}%
}{
    \endminipage%
    \egroup;
    \end{tikzpicture}%
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Some tweaks about section's title
% re-new section command %
% I like bigger title
\makeatletter
\renewcommand\section{\@startsection {section}{1}{\z@}%
    {-1ex \@plus -1ex \@minus -.2ex}%
    {1ex \@plus.2ex}%
    {\titr\scalebox{1.8}}}%
\makeatother
%
\tikzstyle{titleStyle} = [draw=lightgray, fill=lightgray!40, very thick,
    rectangle, rounded corners=10mm, inner sep=10pt, inner ysep=20pt]

 \newcommand{\titlePage}[1]{
\begin{tikzpicture}\node [titleStyle] (box) 
{\setRTL
\begin{minipage}{0.95\textwidth}
{\vspace{0.1\paperheight}%
\begin{center}{#1}\end{center}%
\vspace{0.1\paperheight}}%
  \end{minipage}};\end{tikzpicture}
}
% section start's slide  
\makeatletter
\newcommand{\SecSlide}{\@dblarg\@SecSlide}
\def\@SecSlide[#1]#2{
\begin{plainslide}%
	\begin{center}%
	\markright{#1}
	\titlePage{\section[#1]{#2}\label{sec:\thesection}}%
	\end{center}%
\end{plainslide}%
}
\makeatother
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%رنگ ها
\def\setThemeColor#1#2{\definecolor{themeColor}{#1}{#2}
\linktc{#1}{#2}
\lbotbarc{#1}{#2}
}
\usepackage{etoolbox}
\newcommand{\selectThemeColor}[1]{%
\ifstrequal{#1}{blue}{\setThemeColor{RGB}{45, 47, 146}}%
{%
\ifstrequal{#1}{NavyBlue}{\setThemeColor{RGB}{0, 110, 184}}%
{%
\ifstrequal{#1}{golden}{\setThemeColor{RGB}{255, 223, 66}}%
{%
\ifstrequal{#1}{red}{\setThemeColor{RGB}{237, 27, 35}}%
{%
\ifstrequal{#1}{green}{\setThemeColor{RGB}{0, 166, 79}}%
{%
\ifstrequal{#1}{LimeGreen}{\setThemeColor{RGB}{141, 199, 62}}%
{%
\ifstrequal{#1}{purple}{\setThemeColor{RGB}{153, 71, 155}}%
{%
\ifstrequal{#1}{sepia}{\setThemeColor{RGB}{103, 24, 0}}%
{%
\ifstrequal{#1}{cyan}{\setThemeColor{RGB}{0, 174, 239}}%
{%
\ifstrequal{#1}{orange}{\setThemeColor{RGB}{245, 129, 55}}%
{%
\ifstrequal{#1}{gray}{\setThemeColor{RGB}{148,150,152}}%
{%
\ifstrequal{#1}{JungleGreen}{\setThemeColor{RGB}{0,169,154}}%
{%
\ifstrequal{#1}{Bittersweet}{\setThemeColor{RGB}{192, 79, 23}}%
{%
\ifstrequal{#1}{brown}{\setThemeColor{RGB}{121, 37,0}}%
{}%%default %\setThemeColor{RGB}{0,0,1}
}}}}}}}}}}}}}
}

\def\linktc#1#2{\definecolor{link-text}{#1}{#2}}
\def\sidebartc#1#2{\definecolor{sidebar-text}{#1}{#2}}
\def\rtopbarc#1#2{\definecolor{topbar1-color}{#1}{#2}}
\def\ltopbarc#1#2{\definecolor{topbar2-color}{#1}{#2}}
\def\ltopbartc#1#2{\definecolor{topbar2-text}{#1}{#2}}
\def\rbotbarc#1#2{\definecolor{botbar1-color}{#1}{#2}}
\def\lbotbarc#1#2{\definecolor{botbar2-color}{#1}{#2}}
\def\lbotbartc#1#2{\definecolor{botbar2-text}{#1}{#2}}
\definecolor{pcolor}{rgb}{1,1,1}
% default colors
\selectThemeColor{NavyBlue}
\setThemeColor{RGB}{50,50,200}
\sidebartc{cmyk}{0,0,0,1}
\linktc{rgb}{0,0,1}
\rtopbarc{cmyk}{0.94,0.54,0,0}
\ltopbarc{cmyk}{0.15,0.15,0,0}
\ltopbartc{cmyk}{0,0,0,1}
otbarc{cmyk}{0.15,0.15,0,0}
\lbotbarc{cmyk}{0.94,0.54,0,0}
\lbotbarc{rgb}{0,0,1}
\lbotbartc{cmyk}{0,0,0,0}
\usepackage[urlcolor=link-text,colorlinks=true,linkcolor=link-text,setpagesize=false,pdfpagemode=FullScreen]{hyperref}%
\hypersetup{
    pdftitle={\theTitle},
    pdfauthor={\theAuthor},
}
%\makeatletter
%\renewcommand{\rotateframe}[2]{\if@ttb@rotate
%\rotatebox{#1}{\if@RTL\beginL\fi#2\if@RTL\endL\fi}%
%\else
%#2\relax
%\fi}
%\makeatother
\renewcommand{\sectionmark}[1]{\markright{#1}{}} %%استخراج عنوان خالص سكشن
%%نوار بالا
%\vtwotonetop{1cm}{0.6\paperwidth}{[cmyk]{0.65,0.13,0,0}}{topleft}%
%{0.4\paperwidth}{[cmyk]{0.94,0.54,0,0}}{topright}
\newdynamicframe[2,>1]{1mm}{10mm}{100mm}{160mm}[topbar1]
\setdynamicframe*{topbar1}{valign=c,textcolor=themeColor}%topbar1-color}

%\newstaticframe[2,>1]{66mm}{1.3cm}{123mm}{159mm}[topbar1]
%\setstaticframe*{topbar1}{backcolor=topbar1-color}
%\newdynamicframe[2,>1]{128mm}{1.3cm}{-5mm}{159mm}[topbar2]
%\setdynamicframe*{topbar2}{valign=c,textcolor=topbar2-text,backcolor=topbar2-color}
%%محتویات نواربالا
%%نوار پایین
%\newstaticframe[2,>1]{99mm}{9mm}{90mm}{-10mm}[botbar1]
%\setstaticframe*{botbar1}{backcolor=botbar1-color}
%\newdynamicframe[2,>1]{95mm}{9mm}{-5mm}{-10mm}[botbar2]
%\setdynamicframe*{botbar2}{valign=c,textcolor=botbar2-text,backcolor=botbar2-color}
\newdynamicframe[2,>1]{1mm}{9mm}{90mm}{-10mm}[botbar1]
\setdynamicframe*{botbar1}{valign=c,backcolor=white}
\newdynamicframe[2,>1]{30mm}{9mm}{-5mm}{-10mm}[botbar2]
\setdynamicframe*{botbar2}{valign=c,textcolor=themeColor,backcolor=white}
%%محتویات نوارپایین
%
%%عكس زمینه سایدبار
%\AddToShipoutPicture{%
%%\hspace{-60mm}
%%\put(33,512){
%\put(-137,512){
%\reflectbox{
%\includegraphics[keepaspectratio=false,height=-\paperheight ,width=31mm]{side.jpg}
%}}}
%%خودسایدبار
%\newstaticframe[2,>2]{30mm}{\paperheight}{190mm}{-10mm}[sidebar]
%\setstaticframe*{sidebar}{valign=b}%{backcolor=[cmyk]{0.15,0.15,0,0}}
\newdynamicframe[1,>1]{30mm}{\paperheight}{188mm}{-10mm}[sidebar]
\setdynamicframe*{sidebar}{valign=t}%{backcolor=[cmyk]{0.15,0.15,0,0}}
%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%محتویات سایدبار
\begin{dynamiccontents*}{sidebar}
\linespread{1}
\AddToShipoutPicture*{%
\tikz[remember picture, overlay]\shade[top color=themeColor!15, bottom color=themeColor!80] (current page.north east) rectangle +(-3.2,-18);
}
\vspace{.3cm}
\hspace{3mm}
{\centering\noindent\includegraphics[width=2cm]{\Logo}}
\vspace{.5cm}
% style for the section tabs
\tikzset{tab/.style={
    text width=50mm,anchor=south,
    draw=gray,thick,rectangle,rounded corners=12pt,%rotate=270,
    align=center,text height=20pt,
    text depth=25pt,inner sep=0pt,fill=gray!20,% yshift=-18pt,
    font=\sffamily\LARGE}}
% style for the current section tab
\tikzset{selectedtab/.style={tab,color=white,fill=gray!90}}
    % calculation of the width for each tab
    \setlength\frameheight{\dimexpr\textheight+2cm\relax}
    \ifnum\totvalue{section}>0
        \setlength\avgtabwidth{30mm}%\dimexpr\frameheight/\totvalue{section}\relax}
    \fi
                    \tikzstyle{sec} = [draw=white, fill=white, very thick,
                     rounded rectangle, rounded rectangle west arc=none,  inner xsep=-5pt, inner ysep=10pt]
\begin{small}
\ifnum\the\numexpr\totvalue{section}>0
            \foreach \valsection in {0,...,\numexpr\totvalue{section}-1\relax} {
               \ifnum\thesection<\numexpr\valsection+1 
\begin{center}
\nameref{sec:\the\numexpr\valsection+1\relax}
\end{center}
               \relax
                        \else \ifnum\thesection>\numexpr\valsection+1
\begin{center}
\nameref{sec:\the\numexpr\valsection+1\relax}
\end{center}
                         \relax
                        \else
                        
\begin{tikzpicture}
 \node [sec] {\setRTL
             	       \begin{minipage}{30mm}{
            		        \begin{center}
\nameref{sec:\the\numexpr\valsection+1\relax}
\end{center}}
\end{minipage}};
\end{tikzpicture}
                        \fi\fi
            }
\fi % end of if the total sections > 0
\end{small}
\end{dynamiccontents*}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\def\setTextTR#1{
\begin{dynamiccontents*}{topbar1}\linespread{1}
#1
\end{dynamiccontents*}
}
%
\setTextTR{{\footnotesize \centerline{\bfseries{\rightmark}}}}
%%%

\def\setTextBL#1{
\begin{dynamiccontents*}{botbar2}\linespread{1}
	%\begin{flushleft}
	%	\footnotesize{
\begin{center}
#1
\end{center}	
%	}
	%\end{flushleft}
\end{dynamiccontents*}
}
%
\setTextBL{\bfseries{\thepage}
از
\zpageref{LastPage}%
}


%%
%% End of file `saahel.sty'.