/*****************************************************************************
 ** CalcStats -- 
 **    This function calculates the percentages in the breakdown at the bottom
 ** of the output, and prints them in a nice little table plus total time in
 ** HH:MM:SS form.
 **        Inputs : The total number of unique sites, the total of each site
 **                 type, the total time logged and the total number of non
 **                 unique sites.
 **        Output : The printed results and the suggestion
 *****************************************************************************/
void CalcStats(float TotalUnique, float TotalFunSites, float TotalSearchSites,
	       float TotalNewsSites, float TotalEducationSites, 
	       int TotalTimeLogged, int TotalNonUnique)
{
   float InterestFun, InterestSearch, InterestNews, InterestEducation;
   int hours, minutes, seconds;
   
   /*The number of each site type is converted to a percentage based on*/
   /*the total number of unique sites*/
   InterestFun = (TotalFunSites/TotalUnique)*100;
   InterestSearch= (TotalSearchSites/TotalUnique)*100;
   InterestNews = (TotalNewsSites/TotalUnique)*100;
   InterestEducation = (TotalEducationSites/TotalUnique)*100;
   
   /*The total time is converted to hours, minutes and seconds*/
   hours = TotalTimeLogged/3600;
   minutes = (TotalTimeLogged%3600)/60;
   seconds = (TotalTimeLogged - (minutes*60) - (hours*3600));
   
   fprintf(stdout, "\n\n=============================================");
   fprintf(stdout, "\n               MINED RESULTS                   ");
   fprintf(stdout, "\n=============================================\n");
   fprintf(stdout, "\nTotal Unique Websites : %.0lf             \n", 
	   TotalUnique); 
   fprintf(stdout, "Total Time Logged: %d:%d:%d            \n", 
	   hours, minutes, seconds);
   fprintf(stdout, "Total Non Unique Websites: %.d          \n",
	   TotalNonUnique); 
   fprintf(stdout, "\n=============================================\n");
   fprintf(stdout, "           Website Content Breakdown           \n");
   fprintf(stdout, "=============================================\n");
   fprintf(stdout, "   Search Pages:\t%.0f\tInterest: %.0f%%\n",
	   TotalSearchSites, InterestSearch);
   fprintf(stdout, "   News Pages:\t\t%.0f\tInterest: %.0f%%\n",
	   TotalNewsSites, InterestNews);
   fprintf(stdout, "   Fun Pages:\t\t%.0f\tInterest: %.0f%%\n",
	   TotalFunSites, InterestFun);
   fprintf(stdout, "   Education Pages:\t%.0f\tInterest: %.0f%%\n",
	   TotalEducationSites, InterestEducation);
   fprintf(stdout, "=============================================\n");
   
   PrintSuggestion(InterestFun, InterestSearch, InterestNews,
		   InterestEducation);
   
   return;
}
Size HeaderView::RenderTranslationResult(Renderer* renderer, TranslateResult translateResult)
{
    RenderPosition renderPosition = RenderPosition(PaddingX, LineHeight);

    TranslateResultSentence sentence = translateResult.GetSentence();
    renderer->PrintText(sentence.GetTranslation(), FontHeader, Colors::Black, renderPosition);

    renderPosition = renderPosition.MoveY(LineHeight);

    int imageSize = FontSmall->GetAscent();
    HoverIconButtonControl* audioButton = new HoverIconButtonControl(Context, this);
    audioButton->SetDimensions(
        renderPosition.MoveY(-imageSize).MoveY(2, ScaleProvider).GetPosition(),
        Size(imageSize, imageSize));
    audioButton->SetHoverIconResource(IDR_AUDIO);
    audioButton->SetNormalIconResource(IDR_AUDIO_INACTIVE);
    audioButton->OnClick.Subscribe(&OnPlayText);
    audioButton->InitializeAndRender();

    renderPosition = renderPosition.MoveX(imageSize).MoveX(2, ScaleProvider);
    renderPosition = renderer->PrintText(sentence.GetOrigin(), FontSmall, Colors::Gray, renderPosition);

    RenderDescriptor actionRenderDescriptor = RenderDescriptor(renderer, renderPosition.MoveX(1));
    if (translateResult.IsInputCorrected())
    {
        PrintInputCorrectionWarning(actionRenderDescriptor, sentence.GetInput());
    }
    else if (!sentence.GetSuggestion().empty())
    {
        PrintSuggestion(actionRenderDescriptor, sentence.GetSuggestion());
    }

    renderer->IncreaseWidth(PaddingX);

    return renderer->GetSize();
}