Logo Search packages:      
Sourcecode: kanagram version File versions  Download package

void Kanagram::paintEvent ( QPaintEvent *   ) [private]

paint the widget. draws all the elements of the kanagram interface (except the config dialog of course.)

Definition at line 241 of file kanagram.cpp.

References drawHelpText(), drawSwitcher(), drawTextNew(), FixFontSize(), KanagramGame::getAnagram(), KanagramGame::getHint(), innerRect(), m_cornerFontSize, m_fillColor, m_game, m_hintOverlayName, m_inputBox, m_overNext, m_renderer, and m_xRatio.

{
    QPixmap buf(width(), height());
    QPainter p(&buf);
    p.setRenderHint(QPainter::Antialiasing);

    m_renderer->render(&p, "background");

    m_xRatio = width() / kWindowWidth;
    m_yRatio = height() / kWindowHeight;

    if (m_overLogo)
    {
        p.translate(int(112.188 * m_xRatio), int(32.375 * m_yRatio));
        p.scale(466.981 / kWindowWidth, 91.407 / kWindowHeight);
        m_renderer->render(&p, "logo_hover");
        p.resetMatrix();
    }
    else
    {
        p.translate(int(112.188 * m_xRatio), int(32.375 * m_yRatio));
        p.scale(466.981 / kWindowWidth, 91.407 / kWindowHeight);
        m_renderer->render(&p, "logo");
        p.resetMatrix();
    }

    if (m_overNext)
    {
        p.translate(xTranslateButtons * width(), yTranslateNextButton * height());
        p.scale(xScale55Buttons, yScale55Buttons);
        m_renderer->render(&p, "next_hover");
        p.resetMatrix();
    }

    if (m_overConfig)
    {
        p.translate(xTranslateButtons * width(), yTranslateConfigButton * height());
        p.scale(xScale55Buttons, yScale55Buttons);
        m_renderer->render(&p, "config_hover");
        p.resetMatrix();
    }

    if (m_overHelp)
    {
        p.translate(xTranslateButtons * width(), yTranslateHelpButton * height());
        p.scale(xScale55Buttons, yScale55Buttons);
        m_renderer->render(&p, "help_hover");
        p.resetMatrix();
    }

    if (m_overQuit)
    {
        p.translate(798.811 * m_xRatio, 556.803 * m_yRatio);
        p.scale(xScaleQuitButton, yScaleQuitButton);
        m_renderer->render(&p, "quit_hover");
        p.resetMatrix();
    }

    QString anagram = m_game->getAnagram();
    int afontSize = KFontUtils::adaptFontSize(p, anagram, m_blackboardRect.width(), m_blackboardRect.height() / 5);
    FixFontSize(afontSize);
    drawTextNew(p, anagram, Qt::AlignCenter, 10, 10, m_blackboardRect, true, afontSize);

    QString reveal = i18n(m_textRevealWord);
    m_cornerFontSize = KFontUtils::adaptFontSize(p, reveal, m_blackboardRect.width() / 3, m_blackboardRect.height() / 5);
    FixFontSize(m_cornerFontSize);

    drawTextNew(p, reveal, Qt::AlignBottom | Qt::AlignRight, 6, 0, m_blackboardRect, m_overReveal, m_cornerFontSize);
    drawTextNew(p, i18n(m_textHint), Qt::AlignBottom | Qt::AlignLeft, 6, 0, m_blackboardRect, m_overHint, m_cornerFontSize);

    // update these rects because we have access to the painter and thus the fontsize here
    QFont font = KGlobalSettings::generalFont();
    font.setPointSize(m_cornerFontSize);
    font.setBold(true);
    QFontMetrics fm(font);
    QRect r = innerRect(m_blackboardRect, 6, 0);
    m_hintRect = fm.boundingRect(r, Qt::AlignBottom|Qt::AlignLeft, i18n(m_textHint));
    m_hintBoxRect = QRect(int(684.813 * m_xRatio), int(319.896 * m_yRatio), int(xEyesScale * width()), int(yEyesScale * height()));
    r = innerRect(m_blackboardRect, 6, 0);
    m_revealRect = fm.boundingRect(r, Qt::AlignBottom|Qt::AlignRight, reveal);

    drawSwitcher(p, 9, 8);

    p.setPen(QPen(Qt::black, 3));

    //Draw the border of the input box
    QRect borderRect = m_inputBox->geometry();
    p.drawRoundRect(borderRect, 10, 5);
    int inputBoxFontSize = KFontUtils::adaptFontSize(p, "A", borderRect.width(), borderRect.height()) - 1;
    FixFontSize(inputBoxFontSize);
    QFont f = QFont();
    f.setPointSize(inputBoxFontSize);
    m_inputBox->setFont(f);

    //Draw the border of the Up arrow
    borderRect = m_upRect;
    p.fillRect(borderRect, m_fillColor);
    p.drawRoundRect(borderRect, 10, 5);

    QString upArrow = "up";
    if (m_overUp && !m_inputBox->text().isEmpty())
    {
        upArrow = "up_hover";
    }
    else if (m_inputBox->text().isEmpty())
    {
        upArrow = "up_disabled";
    }

    p.translate(m_inputBox->x() + m_inputBox->width() + 26 * m_xRatio, m_inputBox->y() + 12 * m_yRatio);
    p.scale(38 / kWindowWidth, 20 / kWindowHeight);
    m_renderer->render(&p, upArrow);
    p.resetMatrix();

    if (m_showHint)
    {
        p.translate(684.813 * m_xRatio, 319.896 * m_yRatio);
        p.scale(xEyesScale, yEyesScale);
        m_renderer->render(&p, m_hintOverlayName);
        p.resetMatrix();

        // do drawText with svg position and size
        QFont f = KGlobalSettings::generalFont();
        f.setWeight(QFont::Bold);
        p.setFont(f);
        QString hint = m_game->getHint();
        int fontSize = KFontUtils::adaptFontSize(p, hint, int(250 * m_xRatio), int(110 * m_yRatio));
        FixFontSize(fontSize);
        f.setPointSize(fontSize);
        p.setFont(f);
        p.drawText(int(694 * m_xRatio), int(330 * m_yRatio), int(250 * m_xRatio), int(110 * m_yRatio),
                Qt::TextWordWrap | Qt::AlignCenter, hint);
    }

    if (m_overHelp && !m_showHint)
    {
        if (m_overAboutApp)
        {
            p.translate(808.377 * m_xRatio, 335.352 * m_yRatio);
            p.scale(xScale57Buttons, yScale57Buttons);
            m_renderer->render(&p, "appicon_hover");
            p.resetMatrix();
            drawHelpText(p, i18n("About Kanagram"));
        }
        else
        {
            p.translate(808.377 * m_xRatio, 335.352 * m_yRatio);
            p.scale(xScale57Buttons, yScale57Buttons);
            m_renderer->render(&p, "appicon");
            p.resetMatrix();
        }
        if (m_overAboutKDE)
        {
            p.translate(865.877 * m_xRatio, 335.352 * m_yRatio);
            p.scale(xScale57Buttons, yScale57Buttons);
            m_renderer->render(&p, "kicon_hover");
            p.resetMatrix();
            drawHelpText(p, i18n("About KDE"));
        }
        else
        {
            p.translate(865.877 * m_xRatio, 335.352 * m_yRatio);
            p.scale(xScale57Buttons, yScale57Buttons);
            m_renderer->render(&p, "kicon");
            p.resetMatrix();
        }
        if (m_overHandbook)
        {
            p.translate(750.877 * m_xRatio, 335.352 * m_yRatio);
            p.scale(xScale57Buttons, yScale57Buttons);
            m_renderer->render(&p, "handbook_hover");
            p.resetMatrix();
            drawHelpText(p, i18n("Kanagram Handbook"));
        }
        else
        {
            p.translate(750.877 * m_xRatio, 335.352 * m_yRatio);
            p.scale(xScale57Buttons, yScale57Buttons);
            m_renderer->render(&p, "handbook");
            p.resetMatrix();
        }
    }
    else if (m_overNext)
    {
        drawHelpText(p, i18n(m_nextText));
    }
    else if (m_overConfig)
    {
        drawHelpText(p, i18n("Configure Kanagram"));
    }
    else if (m_overQuit)
    {
        drawHelpText(p, i18n("Quit Kanagram"));
    }

    QPainter p2(this);
    p2.drawPixmap(0, 0, buf);
}

Here is the call graph for this function:


Generated by  Doxygen 1.6.0   Back to index