Esempio n. 1
0
void tst_QStaticText::plainTextVsRichText()
{
    QPixmap imagePlainText(1000, 1000);
    imagePlainText.fill(Qt::white);
    {
        QPainter p(&imagePlainText);

        QStaticText staticText;
        staticText.setText("FOObar");
        staticText.setTextFormat(Qt::PlainText);

        p.drawStaticText(10, 10, staticText);
    }

    QPixmap imageRichText(1000, 1000);
    imageRichText.fill(Qt::white);
    {
        QPainter p(&imageRichText);

        QStaticText staticText;
        staticText.setText("<html><body>FOObar</body></html>");
        staticText.setTextFormat(Qt::RichText);

        p.drawStaticText(10, 10, staticText);
    }

#if defined(DEBUG_SAVE_IMAGE)
    imagePlainText.save("plainTextVsRichText_imagePlainText.png");
    imageRichText.save("plainTextVsRichText_imageRichText.png");
#endif

    QCOMPARE(imagePlainText, imageRichText);
}
Esempio n. 2
0
void B6PCalendarWidget::paintCell(QPainter *painter, const QRect &rect, const QDate &date) const
{
    QCalendarWidget::paintCell(painter, rect, date);
    PlanificacionDiaPtr planificacion = model->getByDay(date, false);
    if ((planificacion != PlanificacionDiaPtr()) && (rect.width() > 50) && (rect.height() > 50))
    {     // When the conditions are matched, passed QDate is drawn as we like.
        int hsPlanificadas = 0;
        int hsEstimadas = 0;
        QString estado = ""; //<b>" + QString::number(date.day()) + "</b>";
        QString estimado = "";
        QString planificado = "";
        hsPlanificadas = planificacion->HorasPlanificadas();
        EstimacionDiaPtr estimacion = planificacion->Estimacion();
        if (estimacion != EstimacionDiaPtr())
        {
            hsEstimadas = estimacion->EstimacionHoras().value();
        }

        estado = planificacion->Estado();
        estimado = QString("E:%1").arg(hsEstimadas);
        planificado = QString("P:%2").arg(hsPlanificadas);

        painter->save();
        painter->setPen(QColor(64, 64, 64, 192));

        QFont font = painter->font();
        font.setPixelSize(12);
        painter->setFont(font);

        QTextOption option;
        option.setAlignment(Qt::AlignLeft | Qt::AlignTop);
        QStaticText text;
        text.setTextOption(option);
        text.setText(estado);
        painter->drawStaticText(rect.left(), rect.top(), text);

        option.setAlignment(Qt::AlignLeft | Qt::AlignBottom);
        text.setText(estimado);
        painter->drawStaticText(rect.left(), rect.bottom() - 13, text);

        option.setAlignment(Qt::AlignLeft | Qt::AlignBottom);
        text.setText(planificado);
        painter->drawStaticText(rect.right() - rect.width() / 2,
                                rect.bottom() - 13, text);

        painter->restore();
    }
}
Esempio n. 3
0
void koregui::FrameBufferStageItem::paint(QPainter* painter,
                                     const QStyleOptionGraphicsItem* option,
                                     QWidget* widget) {
  QBrush b;
  QPen p;
  QFont font("Arial");
  QStaticText text;
 
  p.setStyle(Qt::PenStyle::NoPen);
  b.setColor((isSelected())?QColor(86,86,86):QColor(44,44,44));
  b.setStyle(Qt::BrushStyle::SolidPattern);
  painter->setPen(p);
  painter->setBrush(b);
  painter->drawRect(0, 0, _bufferwidth, _bufferheight);
 
  font.setBold(true);
  font.setPointSize(12);
  painter->setFont(font);
 
  text.setText(_name.c_str());
  p.setColor(QColor(255,255,255));
  p.setStyle(Qt::PenStyle::SolidLine);
  painter->setPen(p);
  painter->drawStaticText(10,10, text);
  painter->drawImage(_bufferwidth - 26, 10, QImage("./assets/icons/gear.png"));
}
Esempio n. 4
0
void tst_QStaticText::richTextOverridesPen()
{
    QFont font = QApplication::font();
    font.setStyleStrategy(QFont::NoAntialias);

    QFontMetricsF fm(font);
    QPixmap image(qCeil(fm.width("XXXXX")), qCeil(fm.height()));
    image.fill(Qt::white);
    {
        QPainter p(&image);
        p.setFont(font);
        p.setPen(Qt::green);

        QStaticText staticText;
        staticText.setText("<html><body><font color=\"#ff0000\">XXXXX</font></body></html>");
        staticText.setTextFormat(Qt::RichText);
        p.drawStaticText(0, 0, staticText);
    }

    QImage img = image.toImage();
    for (int x=0; x<img.width(); ++x) {
        for (int y=0; y<img.height(); ++y) {
            QRgb pixel = img.pixel(x, y);
            QVERIFY(pixel == QColor(Qt::white).rgba()
                    || pixel == QColor(Qt::red).rgba());
        }
    }
}
static PyObject *meth_QStaticText_setText(PyObject *sipSelf, PyObject *sipArgs)
{
    PyObject *sipParseErr = NULL;

    {
        const QString* a0;
        int a0State = 0;
        QStaticText *sipCpp;

        if (sipParseArgs(&sipParseErr, sipArgs, "BJ1", &sipSelf, sipType_QStaticText, &sipCpp, sipType_QString,&a0, &a0State))
        {
            Py_BEGIN_ALLOW_THREADS
            sipCpp->setText(*a0);
            Py_END_ALLOW_THREADS
            sipReleaseType(const_cast<QString *>(a0),sipType_QString,a0State);

            Py_INCREF(Py_None);
            return Py_None;
        }
    }

    /* Raise an exception if the arguments couldn't be parsed. */
    sipNoMethod(sipParseErr, sipName_QStaticText, sipName_setText, doc_QStaticText_setText);

    return NULL;
}
Esempio n. 6
0
void koregui::NodeItem::paint(QPainter* painter,
                              const QStyleOptionGraphicsItem* option,
                              QWidget* widget) {
  QBrush b;
  QPen p;
  QFont font("Arial");
  QStaticText text;

  text.setText(_sceneNode->getName().c_str());
  p.setStyle(Qt::PenStyle::NoPen);
  painter->setPen(p);

  b.setStyle(Qt::BrushStyle::SolidPattern);
  b.setColor((isSelected())?QColor(86,86,86):QColor(44,44,44));
  painter->setBrush(b);
  painter->drawRect(0, 0, _nodewidth, _nodeheight);

  font.setBold(true);
  font.setPointSize(12);
  painter->setFont(font);

  p.setColor(QColor(255,255,255));
  p.setStyle(Qt::PenStyle::SolidLine);
  painter->setPen(p);
  painter->drawStaticText(10,10, text);
}
Esempio n. 7
0
void koregui::ShaderPassItem::paint(QPainter* painter,
                                const QStyleOptionGraphicsItem* option,
                                QWidget* widget) {
  QBrush b;
  QPen p;
  QFont font("Arial");
  QStaticText text;

  p.setStyle(Qt::PenStyle::NoPen);
  b.setColor((isSelected())?QColor(86,86,86):QColor(66,66,66));
  b.setStyle(Qt::BrushStyle::SolidPattern);
  painter->setPen(p);
  painter->setBrush(b);
  painter->drawRect(0, 0, _shaderwidth, _shaderheight);

  font.setBold(true);
  font.setPointSize(12);
  painter->setFont(font);
  painter->drawImage(_shaderwidth - 26, 10, QImage("./assets/icons/gear.png"));

  text.setText(_name.c_str());
  p.setColor(QColor(255,255,255));
  p.setStyle(Qt::PenStyle::SolidLine);
  painter->setPen(p);
  painter->drawStaticText(10,10, text);

  font.setFamily("Consolas");
  font.setPointSize(9);
  p.setColor(QColor(200,200,200));
  painter->setPen(p);
  painter->setFont(font);

  int tmpheight = 40;
  for (uint i = 0; i<_attributes.size(); i++) {
    text.setText(_attributes[i]->getInput()->name.c_str());
     painter->drawStaticText(12,tmpheight + 30 * i, text);
  }
  tmpheight += 30 * _attributes.size();
  for (uint i = 0; i<_uniforms.size(); i++) {
    text.setText(_uniforms[i]->getInput()->name.c_str());
    painter->drawStaticText(12,tmpheight + 30 * i, text);
  }
}
Esempio n. 8
0
void tst_QStaticText::setFont()
{
    QFont font = QApplication::font();
    font.setBold(true);
    font.setPointSize(28);

    QPixmap imageDrawText(1000, 1000);
    imageDrawText.fill(Qt::white);
    {
        QPainter p(&imageDrawText);
        p.drawText(QRectF(0, 0, 1000, 1000), 0, "Lorem ipsum dolor sit amet, consectetur adipiscing elit.");

        p.setFont(font);
        p.drawText(QRectF(11, 120, 1000, 1000), 0, "Lorem ipsum dolor sit amet, consectetur adipiscing elit.");
    }

    QPixmap imageDrawStaticText(1000, 1000);
    imageDrawStaticText.fill(Qt::white);
    {
        QPainter p(&imageDrawStaticText);

        QStaticText text;
        text.setText("Lorem ipsum dolor sit amet, consectetur adipiscing elit.");
        text.setTextFormat(Qt::PlainText);

        p.drawStaticText(0, 0, text);

        p.setFont(font);
        p.drawStaticText(11, 120, text);
    }

#if defined(DEBUG_SAVE_IMAGE)
    imageDrawText.save("setFont_imageDrawText.png");
    imageDrawStaticText.save("setFont_imageDrawStaticText.png");
#endif

    QCOMPARE(imageDrawStaticText, imageDrawText);
}