%%
%% This is file `bidipresentation.cls',     % I've modified it, though, and I have also used the class ``bidiSP.cls" by H. Noori, and the style ``sidebidipres.sty" by AR Hashemi
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% bidi.dtx  (with options: `bidipresentation.cls')
%% 
%%   ______________________________________
%%   Copyright © 2009–2010  Vafa Khalighi
%% 
%%   License information appended.
%% 
%% 
\NeedsTeXFormat{LaTeX2e}
\ProvidesClass{bidipresentation_modified}
\DeclareOption*{\PassOptionsToClass{\CurrentOption}{article}}
\ProcessOptions\relax
\LoadClass{article}


\RequirePackage[paperwidth=240mm,paperheight=180mm,  lmargin=20mm,rmargin=40mm,bmargin=16mm,tmargin=16mm]{geometry}
% از  rmargin  برای خالی کردن قسمتی از سمت راست تمامی اسلایدها (حتی اگر استایل آنها empty باشد که زیرنویس و ... هم نداشته باشد) استفاده میشود که بتوان در جای آن یک نوار side-bar قرار داد مثلاً برای فهرست مطالب، اگرچه من آنرا 10mm بزرگتر از سایدبار گرفته ام که کار right را هم همزمان بکند و از سایدبار نوشته های داخل اسلاید به اندازه ی 10mm فاسله بگیرند، خود right اگر مساوی 10mm بود نمیتوانست در حضور rmargin بزرگتر از خودش این کار را بکند و حذفش کردم!       % برای heading صفحات هم اگر کاغذ اسلایدها کوچک معرفی شود گاهی باید از مقادیر منفی استفاده کرد تا header ها داخل اسلاید بیفتند و نه بالاتر و بیرون از آن

\RequirePackage{amsmath,amssymb,amsfonts,textcomp,txfonts,mathrsfs,stmaryrd}


\RequirePackage{multicol,multirow,xcolor,colortbl,graphicx,watermark,tikz,multicol}
%package: multicol         if ``twocolumn" is added as an argument to the class definition, this package should be unactivated; I need it for my proposal's  time table
%package: multirow       again I need it for my proposal's time table
%package: xcolor             used  for coloring the texts, tables (if ``table" is used for it as an option then itself calls for the ``colortbl" package?), hyper references and etc., seemingly many times better than the package ``color". The colors already available by name in it are: red, green, blue, cyan, magenta, yellow, black, gray, white, darkgray, lightgray, brown, lime, olive, orange, pink, purple, teal, and violet. Use the commands ``\color{}", or ``\textcolor{}{text}", or ``\pagecolor{}".
%package: xecolour        used  for RTL coloured texts that spans more than a line     % not required to be called as is already called from within the class exploited
%package: colortbl          used for coloring the tables and also coloring the fonts in text and also highligthing the texts
%package: graphicx        used to include figures and watermarks as well       % not required to be called as is already called from within the class exploited
%package: watermark    to use the command \watermark, to add watermark to the slides
%package: tikz                 useful to produce rotated (by an arbitrary angle) colored boxes (it even doesn't need any "color" related package to be called, either)
%package: multicol         useful for producing multicolumn pages or parts of pages, here used for the thanks page: placing the thanks world beside the thanks figure

% to define some colors
\def\linktc#1#2{\definecolor{link-text}{#1}{#2}}                  %رنگ لینك​ها  % e.g., ``items in the tables of contents (1 slide and all the side bars)", the ``last page number in footer"
\def\urltc#1#2{\definecolor{url-text}{#1}{#2}}                      %	رنگ url       % e.g., the ``author's name" in the title page
\def\citetc#1#2{\definecolor{cite-text}{#1}{#2}}                  %رنگ اشاره ها
\def\sidebartc#1#2{\definecolor{sidebar-text}{#1}{#2}}     %رنگ متن سایدبار    % except for the links in the side bar's table of contents!
\def\mywhite#1#2{\definecolor{mywhite}{#1}{#2}}           %رنگ سفید دلخواه من برای این ارائه!
\def\myblue#1#2{\definecolor{myblue}{#1}{#2}}                %رنگ آبی دلخواه من برای این ارائه!
\def\myred#1#2{\definecolor{myred}{#1}{#2}}                   %رنگ قرمز دلخواه من برای این ارائه!
\def\mygreen#1#2{\definecolor{mygreen}{#1}{#2}}           %رنگ سبز دلخواه من برای این ارائه!
\def\myyellow#1#2{\definecolor{myyellow}{#1}{#2}}       %رنگ زرد دلخواه من برای این ارائه!
\colorlet{tablecolor_1}{gray!10}                                                  %رنگ زمینه ی برخی ستونها یا سطرها یا خانه های جدول مورد نظر
\colorlet{tablecolor_2}{gray!25}                                                  %رنگ زمینه ی برخی ستونها یا سطرها یا خانه های جدول مورد نظر

\usetikzlibrary{shapes,snakes}     %to work with "tikz" package


\RequirePackage[RL]{flowfram}       % it is required for using the command ``\newstaticframe" and etc. in definition of the sidebar, but destroys the headers and footers by pulling them to the left    % we enable `RL' option for RTL multicolumn typesetting (see flowfram package documentation)


\RequirePackage{eso-pic}                   % it is required for using the command ``\AddToShipoutPicture" in definition of a background for the sidebar


\renewcommand{\sectionmark}[1]{\markright{#1}{}} %%استخراج عنوان خالص سكشن % required for writing the section titles in the header


\RequirePackage{lastpage}     % this package is used for the last page of the presentation to be known, useful for writing down the slide's page number as page/lastpage


\RequirePackage[colorlinks=true,linkcolor=link-text,filecolor=blue,urlcolor=url-text,citecolor=cite-text,setpagesize=false,pdfhighlight=/N,backref=page]{hyperref}     % thispackage would be called from within sidebarbidipres_modified, so the below adjustments should be placed after that package
\hypersetup{
pdfpagemode=FullScreen,                                                 % this opens the pdf in fullscreen such that it will be more suitable for a presentation
pdftitle={عنوان اسلاید},pdfkeywords={کلید واژه‌ها},
pdfauthor={نویسنده}, pdfsubject={موضوع},
%anchorcolor={blue},linktocpage=true,
}



%\RequirePackage[RTLdocument]{bidi}                                                                         % this is supposed  to be the last package to be called, so add other packages before it
\RequirePackage{xepersian}       % this includes the bidi package? and translates some latin commands to their persian translations, e.g. see that \date now writes the persian date
\setmainfont[Scale=1,Script=Parsi,Language=Parsi,Mapping=parsidigits]{XB Niloofar}              %the main font to be used within the script%
\newfontfamily\kayhan[Scale=1,Script=Parsi,Language=Parsi,Mapping=farsidigits]{XB Kayhan}           %an extra font to be used whenever interested
%\newfontfamily\kayhansayeh[Scale=0.9,Script=Parsi,Language=Parsi,Mapping=farsidigits]{XB Kayhan Sayeh} %an extra font to be used whenever interested
%\newfontfamily\yas[Scale=1.1,Script=Parsi,Language=Parsi,Mapping=farsidigits]{XB Yas}                          %an extra font to be used whenever interested
%\newfontfamily\zar[Scale=1,Script=Parsi,Language=Parsi,Mapping=farsidigits]{XB Zar}                          %an extra font to be used whenever interested
\newfontfamily\sols[Scale=0.7,Script=Parsi,Language=Parsi,Mapping=farsidigits]{XB Sols}                          %an extra font to be used whenever interested
\newfontfamily\nastaliq[Scale=1.7,Script=Parsi,Language=Parsi,Mapping=farsidigits]{IranNastaliq}          %an extra font to be used whenever interested
%\newfontfamily\parsidigits[Scale=1]{Parsi Digits}
\setdigitfont[Scale=1]{Parsi Digits}  % I don't know why the above command didn't work properly, but this command makes the numbers in formulas in Persian instead of English

%-------------------------------------------------------------------------------------------------------------
\def\contentsname{ }           % this redifinition acts like modiffying the class ``article" for nothing to be written above the table of contents like ``Contents" or ``فهرست مطالب"
\renewcommand\thesection { }   % and this redifinition acts like modiffying the class ``article" for the sections not to be numbered, neither in the slides, nor in the list of content
\renewcommand\section{\@startsection {section}{1}{\z@}%  % and this modifies how the ``section titles" appear in their corresponding slides
                                   {-3.5ex \@plus -1ex \@minus -.2ex}%
                                   {2.3ex \@plus.2ex}%
                                   {\hspace{-15.9mm}\centering\normalfont\huge\bfseries\nastaliq}}      % I used a \hspace{-7.5mm} here to omit the indentation before the section's title, for the sake of beauty
\renewcommand*\l@section[2]{ % and this modifies the original tableofcontents not to include the page numbers corresponding to sections, for beauty and also using in sidebar
  \ifnum \c@tocdepth >\z@
    %\addpenalty\@secpenalty
    \addvspace{1.0em \@plus\p@}%
    \setlength\@tempdima{0.1em}%                  %insread of 1.5em in the original command \l@section[2]
    \begingroup
      %\parindent \z@ \rightskip \@pnumwidth
      %\parfillskip -\@pnumwidth
      %\leavevmode \bfseries
      \advance\leftskip\@tempdima
      %\hskip -\leftskip
      #1\par            %  the command used originally in ``article.cls" was:     #1\nobreak\hfil \nobreak\hb@xt@\@pnumwidth{\hss #2}\par    %   #1 stands for the title, and #2 stands for its corresponding page number
    \endgroup
  \fi}
%-------------------------------------------------------------------------------------------------------------

\renewcommand{\maketitle}%
  {\ClassError{bidipresentation}{Caution: ``maketitle'' command not supported}%
  {Please use ``titlepage'' environment instead}%
}
%------------------------------------------
%\def\institute#1{\gdef\@institute{#1}}	  %
%\def\department#1{\gdef\@department{#1}}  %
\def\presentation_title#1{\gdef\@presentation_title{#1}}  %
\def\advisor#1{\gdef\@advisor{#1}}%
\def\researcher#1{\gdef\@researcher{#1}}%
\def\slidedate#1{\gdef\@slidedate{#1}}	  %
%------------------------------------------
\newcommand{\distance}[1]{\vspace*{\stretch{#1}}}
\newcommand{\abstand}[1]{\vspace*{\stretch{#1}}}
%------------------------------------------
\newcommand{\titleslide}                                                           %%  دستوری برای ایجاد صفحه ی عنوان
{{\addtocounter{page}{-1}\thispagestyle{empty}\distance{0}\centering{     % I used here \addtocounter{page}{-1} for the title page to be coined the number 0 instead of 1
            {\Large\sols\textcolor{myblue}{«بِسمِ اللّٰهِ الرَّحمٰنِ الرَّحیمِ»}}\\
            \distance{2.7}  {\LARGE\kayhan\textcolor{myred}{\@presentation_title}}\\
            \distance{1.5}  {\large\sols اساتید راهنما:}\\
            \distance{0.1}  {\LARGE\sols\textcolor{mygreen}{\@advisor}}\\
			\distance{1.5} {\LARGE\sols\@researcher}\\	
			\distance{1.1}  {\normalsize\textcolor{myred}{\@slidedate}}
	        \distance{0.3}}\newpage}}             % this ends the title page and starts a new page with page number just starting from 1   %\setcounter{page}{1} could be used instead of \addtocounter{page}{-1} to do so, but this was then coining the page number 1 also to the title page and it is not good as the first page would have footer and hader!
%--------------------------------------------


\setlength{\parskip}{0.6ex}
\setlength{\parindent}{0mm}


%--------------------------------------------------------------------------------------------------
\newenvironment{plainslide}[1][]%
   {{\centering\LARGE\bfseries\sols\color{myblue} #1\par}\par\vspace*{0.5cm}}%          % I deleted a ``\vspace*{\stretch{1}}" command after ``\par", since otherwise the firest line was started vertically from the center of the page
  {\par\vspace*{\stretch{1}}\newpage}

\newenvironment{frameslide}[1][]%
   {\addtocounter{page}{-1}{\centering\LARGE\bfseries\sols\color{myblue} #1\par}\par\vspace*{0.5cm}}%        %this is just like ``plainslide" but only keeps the same its pagenumber, so is useful as a frame to be called inside one slide! a figure, a table, or even counting the \items in a text slide!
  {\par\vspace*{\stretch{1}}\newpage}

\newenvironment{rawslide}{}{\newpage}%

%\newenvironment{rawframe}{}{\addtocounter{page}{-1}\newpage}%    % this is the same as frameslide but only for rawslides! so that there is no ``عنوان" but all the lines start at top of the page

%one may also combine the ``plainslide" and ``rawslide" to obtain something in middle as his own ``frameslide"
%--------------------------------------------------------------------------------------------------


\def\itemize{%
  \ifnum \@itemdepth >\thr@@\@toodeep\else
    \advance\@itemdepth\@ne
    \edef\@itemitem{labelitem\romannumeral\the\@itemdepth}%
    \expandafter
    \list
      \csname\@itemitem\endcsname
      {\def\makelabel##1{\hss\llap{\color{myred}##1}}}%          % ``myred" colors the bullets in my red
  \fi
    \setlength{\itemsep}{5ex}%
    \setlength{\parskip}{0.1ex}%
    \setlength{\parsep}{0ex}%
    }%
\let\enditemize =\endlist

\def\enumerate{%
  \ifnum \@enumdepth >\thr@@\@toodeep\else
    \advance\@enumdepth\@ne
    \edef\@enumctr{enum\romannumeral\the\@enumdepth}%
      \expandafter
      \list
        \csname label\@enumctr\endcsname
        {\usecounter\@enumctr\def\makelabel##1{\hss\llap{##1}}}%
  \fi
    \setlength{\itemsep}{0ex}%
    \setlength{\parskip}{0.1ex}%
    \setlength{\parsep}{0ex}%
    }%
\let\endenumerate =\endlist

\renewenvironment{description}
               {\list{}{\labelwidth\z@ \itemindent-\leftmargin
                        \let\makelabel\descriptionlabel}
 \setlength{\itemsep}{2ex}%
    \setlength{\parskip}{0.1ex}%
    \setlength{\parsep}{1ex}}
               {\endlist}
%% 
%% Copyright © 2009–2010  Vafa Khalighi <vafakhlgh@gmail.com>
%% 
%% It may be distributed and/or modified under the LaTeX Project Public License,
%% version 1.3c or higher (your choice). The latest version of
%% this license is at: http://www.latex-project.org/lppl.txt
%% 
%% This work is “author-maintained” (as per LPPL maintenance status)
%% by Vafa Khalighi.
%% 
%% In addition to the terms of LPPL any distributed version
%% (unchanged or modified) of bidi has to keep the statement
%% about the moral obligation for using bidi. In case of major
%% changes where this would not be appropriate the author of the
%% changed version should contact the copyright holder.
%% 
%% 
%% 
%% Moral obligation for using bidi:
%% ____________________________________
%% 
%% Users of bidi who wish to include or use bidi or a modified
%% version in a proprietary and commercially market product are asked
%% under certain conditions (see below) for the payment of a license
%% fee.  The size of this fee is to be determined, in each instance,
%% by the commercial user, depending on his/her judgment of the value of
%% bidi for his/her product.
%% 
%% 
%% The conditions for this are as follows:
%% 
%% The producer of a proprietary and commercially market product
%% that involves typesetting using bidi is asked to determine
%% the value of a license fee for using bidi if
%% 
%%    - the product is a document and the producer has decided to
%%      include bidi to typeset (parts of) the document or has
%%      directed the author of the document to include bidi (for
%%      example, by providing a class file to be used by the author)
%% 
%%    - the product is a LaTeX class or package that includes bidi
%% 
%% 
%% There is no moral obligation in case
%% 
%%    - the product is a document but producer has not directed
%%      the author to include bidi (in that case the moral obligation
%%      lies with the author of the document)
%% 
%%    - the product does not involve typesetting, e.g., consists, for
%%      example, of distributing bidi and its documentation.
%% 
%%    - the product is not proprietary, i.e., is made available as free
%%      software itself (which doesn't prohibit its commercial marketing)
%% 
%%    - bidi is used for non-commercial purposes
%% 
%% 
%% Determinating a license fee might result in a license fee of zero
%% (i.e., no payment) in case a producer has determined that the use
%% of bidi has no enhancing effect on the product. This is a
%% plausible scenario, i.e., in the above two cases the producer is
%% only asked to evaluate the value of bidi for the product
%% not for the payment of a license fee per se (which might or might
%% not follow from this evaluation).
%% 
%%  The license fee, if any, can be payed to the author of
%%  the program who can be contacted at
%% 
%%      vafakhlgh@gmail.com
%% 
%% 
%% 
%%
%% End of file `bidipresentation.cls'.
