/**************************************************************************
<MODULE NAME>
  <FILENAME> video.cpp </FILENAME>
  <HISTORY>
    <MODIFICATION>
      <DATE>  </DATE>
      <AUTHOR>  </AUTHOR>
      <DESCRIPTION>
      </DESCRIPTION>
    </MODIFICATION>
</HISTORY>
</MODULE NAME>
**************************************************************************/

/**************************************************************************
INCLUDE FILES
**************************************************************************/
#include <conio.h>
#include <stdio.h>
#include "..\comp\graph\scr_urne.h"

/**************************************************************************
STATIC VARIABLES
**************************************************************************/
static int giScreenType = SCR_START;

/**************************************************************************
<FUNCTION>
  <NAME> Video_Affiche </NAME>
  <TYPE> GLOBAL </TYPE>
  <DESCRIPTION>
  Calls ScreenU_WriteText...
  Displays a text at a specific position
  </DESCRIPTION>
  <PARAMETERS>
    <PARAMETER>
      <NAME> _iType </NAME>
      <TYPE> int </TYPE>
      <IO> IN </ IO >
      <DESCRIPTION>
      Specifies the nature of the text (-> it's position)
      </DESCRIPTION>
    </PARAMETER>
  </PARAMETERS>
</FUNCTION>
**************************************************************************/
void Video_Affiche(int _iType, char *_psBuff)
{
  ScreenU_WriteText(_iType, _psBuff);
}

/**************************************************************************
<FUNCTION>
  <NAME> Video_Init </NAME>
  <TYPE> GLOBAL </TYPE>
  <DESCRIPTION>
  Initialization (graphical mode, language)
  </DESCRIPTION>
  <PARAMETERS>
    <PARAMETER>
      <NAME> _iLg </NAME>
      <TYPE> int </TYPE>
      <IO> IN </ IO >
      <DESCRIPTION>
      The language identification
      </DESCRIPTION>
    </PARAMETER>
    <PARAMETER>
      <NAME> _iNb </NAME>
      <TYPE> int </TYPE>
      <IO> IN </ IO >
      <DESCRIPTION>
      The number of ballots (if 1 -> only one type of voter)
      </DESCRIPTION>
    </PARAMETER>
  </PARAMETERS>
</FUNCTION>
**************************************************************************/
void Video_Init(int _iLg, int _iNb)
{
/* << */
  /*Init_Graph();*/
/* >> */
  Init_Msg(_iLg, _iNb);
}

/**************************************************************************
<FUNCTION>
  <NAME> GetVideoScreen </NAME>
  <TYPE> GLOBAL </TYPE>
  <DESCRIPTION>
  Returns an integer which specifies the type of the current screen
  </DESCRIPTION>
  <RETURNS>
    <TYPE> int </TYPE>
    <DESCRIPTION>
    The id of the current screen
    </DESCRIPTION>
  </RETURNS>
</FUNCTION>
**************************************************************************/
int GetVideoScreen(void)
{
  return giScreenType;
}

/**************************************************************************
<FUNCTION>
  <NAME> Video_Screen </NAME>
  <TYPE> GLOBAL </TYPE>
  <DESCRIPTION>
  </DESCRIPTION>
  <PARAMETERS>
    <PARAMETER>
      <NAME> _iType </NAME>
      <TYPE> int </TYPE>
      <IO> IN </ IO >
      <DESCRIPTION>
      The type of the screen (SCR_START, SCR_PWD, SCR_GEN)
      </DESCRIPTION>
    </PARAMETER>
  </PARAMETERS>
</FUNCTION>
**************************************************************************/
void Video_Screen(int _iType)
{
  static int iPrevScrType_PWD = SCR_START; /* Used by SCR_PWD */

  giScreenType = _iType;

  switch(_iType)
  {
    case SCR_START:
      ScreenU();
      ScreenU_Clear_Middle();
      iPrevScrType_PWD = giScreenType;
      break;

    case SCR_GEN:
      ScreenU_Clear_Middle();
      ScreenU_Urne();
      ScreenU_Validator();
      break;

    case SCR_PWD:
      if(iPrevScrType_PWD == SCR_START)
        ScreenU_Clear_Middle();
      else if(iPrevScrType_PWD == SCR_URNE || iPrevScrType_PWD == SCR_RECOMPT)
        ScreenU_Clear_Validator();

      ScreenU_Pwd(iPrevScrType_PWD);
      giScreenType = _iType;
      break;

    case SCR_URNE:
      ScreenU_Clear_Validator();
      ScreenU_Urne();
      iPrevScrType_PWD = giScreenType;
      break;

    case SCR_RECOMPT:
      ScreenU_Clear_Validator();
      ScreenU_Recompt();
	  ScreenU_Urne();
      iPrevScrType_PWD = giScreenType;
      break;
  }
}
