Sophie

Sophie

distrib > Mandriva > 2011.0 > i586 > media > contrib-release-debug > by-pkgid > cf0a4bc9dd41be5e72771c8857fae56f > files > 147

briquolo-debug-0.5.7-2mdv2011.0.i586.rpm

/*****************************************************************************
 *
 *  Copyright (C) 2003 Cédric Brégardis <cedric.bregardis@free.fr>
 *
 *  This file is part of BRIQUOLO
 *
 *  BRIQUOLO is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2 of the License, or
 *  (at your option) any later version.
 *
 *  BRIQUOLO is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with BRIQUOLO; if not, write to the Free Software
 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 *
 *****************************************************************************/
#ifndef MOGL_POLICEBITMAP
#define MOGL_POLICEBITMAP

#include "MOGL_Structure.h"
#include "MOGL_Police.h"

using namespace std;

class MOGL_PoliceBitmap: public MOGL_Police
{
    // **** Types locaux à la classe ****
    struct MOGL_Struct_Carac
    {
        unsigned char carac;
        unsigned int x1;
        unsigned int y1;
        unsigned int x2;
        unsigned int y2;
    };
    // **********************************

  public:
    /**
       Constructeur
    */
    MOGL_PoliceBitmap();

    /**
       Destructeur
    */
    ~MOGL_PoliceBitmap();

    /**
       Permet de Charger  une police de caractères.
    */
    bool Charger(const char * p_NomFichier);

    /**
       Permet d'afficher une chaine de caractères.
       @param p_Chaine : chaine de caractères à afficher.
       @param p_X : coordonnée X de la chaine de caractères.
       @param p_Y : coordonnée Y de la chaine de caractères.       
       @param p_CouleurTexte : couleur de la chaine de caractères.
    */
    void Afficher(const string & p_Chaine, int p_X, int p_Y, const MOGL_Struct_Couleur & p_CouleurTexte) const;

    /**
       Permet d'afficher une chaine de caractères.
       @param p_Chaine : chaine de caractères à afficher.
       @param p_X : coordonnée X de la chaine de caractères.
       @param p_Y : coordonnée Y de la chaine de caractères.       
       @param p_CouleurTexte : couleur de la chaine de caractères.
       @param p_CouleurFond : couleur du fond.
    */
    void Afficher(const string & p_Chaine, int p_X, int p_Y,
                  const MOGL_Struct_Couleur & p_CouleurTexte, const MOGL_Struct_Couleur & p_CouleurFond) const;

    /**
       Permet de récupérer la largeur d'un caractère de la police.
       @param p_Caractere : caractère dont on veut la largeur.
       @return la largeur du caractère en pixels.
    */
    unsigned int GetTailleXCaractere(Uint16 p_Caractere) const;

    /**
       Permet de récupérer la hauteur d'un caractère de la police.
       @param p_Caractere : caractère dont on veut la hauteur.
       @return la hauteur du caractère en pixels.
    */
    unsigned int GetTailleYCaractere(Uint16 p_Caractere) const;

    /**
       Permet de recharger la police.
    */
    bool Recharger();


  protected:
    /**
       Permet d'afficher un caractère
       @param p_X : position X du caractère
       @param p_Y : position Y du caractère
       @param p_Caractere : caractère à afficher.
       @return Position x du prochain caractère
    */
    float _AfficherCaractere(float p_X, float p_Y, unsigned char p_Caractere) const;

    /**
       Permet d'afficher le fond d'un caractère.
       Il s'agit en fait d'afficher un rectangle de la taille du caractère, et de couleur unie.
       @param p_X : position X du caractère
       @param p_Y : position Y du caractère
       @param p_Caractere : caractère à afficher.
       @return Position x du prochain caractère
    */
    float _AfficherFondCaractere(float p_X, float p_Y, unsigned char p_Caractere) const;
        
    GLuint _Nom;
    unsigned int _TailleX;
    unsigned int _TailleY;
    MOGL_Struct_Couleur * _Image;

    unsigned int _NbCaractere;
    MOGL_Struct_Carac * _Caracteres;
    MOGL_Struct_Carac * (_Correspondance[256-32]);
};

#endif