Historique des modifications - Message

Message #5135

Sujet: Pointeur de fonctions dans une classe


Type Date Auteur Contenu
Dernière modification 16-02-2009 14:23:54 Stobbyo
Salut,

Merci beaucoup pour cette réponse détaillée !

Je vais essayer d'implémenté ça. Mon dieu que c'est compliqué lol !

Je vais réfléchir.

En fait, ce que je voudrais faire c'est une fonction membre publique qui pointe vers une fonction membre privée.

J'ai une fonction dans ma classe qui permet d'ajouter du texte,
la voici, dans son état actuel :

void CWindow::addLine(const wchar_t *text)
{
    if(text != 0)
    {
        // Calculate width of the text
        irr::core::dimension2d<irr::s32> textSize = CWindow::m_Font->getDimension(text);

        if(textSize.Width > m_TextWidth)
        {
            CWindow::m_TextWidth = textSize.Width;
        }

        // Add the text in the array
        CWindow::m_TextArray.push_back(text);
    }
}

J'aimerai la modifier en ceci :
void CWindow::addLine(const wchar_t *text)
{
     if(text != 0)
    {
        // Calculate width of the text
        irr::core::dimension2d<irr::s32> textSize = CWindow::m_Font->getDimension(text);

        if(textSize.Width > m_TextWidth)
        {
            CWindow::m_TextWidth = textSize.Width;
        }

        // Add the text in the array
        CWindow::m_TextArray.push_back(text);

        if( (CWindow::m_TextArray.size() > CWindow::m_MaxNumberOfLines) && (!CWindow::m_IsMultiline) )
        {
             drawText = &DrawTextMultiline_; // changement d'adresse 
             CWindow::m_IsMultiline = true;
        }   
    }
}

C'était juste pour préciser ce que j'aurais voulu faire.
Je posterai en cas de souci.

Merci beaucoup en tout cas smile
Création du message 06-12-2008 14:02:23 Stobbyo
Salut,

Merci beaucoup pour cette réponse détaillée !

Je vais essayer d'implémenté ça. Mon dieu que c'est compliqué lol !

Je vais réfléchir.

En fait, ce que je voudrais faire c'est une fonction membre publique qui pointe vers une fonction membre privée.

J'ai une fonction dans ma classe qui permet d'ajouter du texte,
la voici, dans son état actuel :

void CWindow::addLine(const wchar_t *text)
{
    if(text != 0)
    {
        // Calculate width of the text
        irr::core::dimension2d<irr::s32> textSize = CWindow::m_Font->getDimension(text);

        if(textSize.Width > m_TextWidth)
        {
            CWindow::m_TextWidth = textSize.Width;
        }

        // Add the text in the array
        CWindow::m_TextArray.push_back(text);
    }
}

J'aimerai la modifier en ceci :
void CWindow::addLine(const wchar_t *text)
{
     if(text != 0)
    {
        // Calculate width of the text
        irr::core::dimension2d<irr::s32> textSize = CWindow::m_Font->getDimension(text);

        if(textSize.Width > m_TextWidth)
        {
            CWindow::m_TextWidth = textSize.Width;
        }

        // Add the text in the array
        CWindow::m_TextArray.push_back(text);

        if( (CWindow::m_TextArray.size() > CWindow::m_MaxNumberOfLines) && (!CWindow::m_IsMultiline) )
        {
             drawText = &DrawTextMultiline_; // changement d'adresse 
             CWindow::m_IsMultiline = true;
        }   
    }
}

C'était juste pour préciser ce que j'aurais voulu faire.
Je posterai en cas de souci.

Merci beaucoup en tout cas smile

Retour

Options Liens officiels Caractéristiques Statistiques Communauté
Préférences cookies
Corrections
irrlicht
irrklang
irredit
irrxml
Propulsé par Django
xhtml 1.0
css 2.1
884 membres
1440 sujets
11337 messages
Dernier membre inscrit: Saidov17
175 invités en ligne
membre en ligne: -
RSS Feed