Exemplo n.º 1
0
void MessageBarIcon::paint( QPainter * painter,
             const QStyleOptionGraphicsItem * option, QWidget * widget ){

    QGraphicsPixmapItem::paint(painter, option, widget);
    painter->save();
    QRectF b = boundingRect();
    QFont fnt = m_item.getDisplayFont();
    QFontMetrics fm(fnt);
    int fnt_h = fm.height();
    QRect r(0,0,0,0);
    r.setTop(b.height() - ( fnt_h + ((MessageIconWidget*)parent())->getInnerPadding()));
    r.setBottom(b.bottom());
    r.setWidth(b.width());
//    QBrush brush1(QColor(255, 20, 25, 255));
//    brush1.setStyle(Qt::SolidPattern);
//    painter->setBrush(brush1);
//    painter->drawRect(r);

    painter->setClipRect(r);

    //qDebug() << "test onto rect: " << r;
    drawHtmlLine(painter, fnt, r, m_item.formattedName());

    painter->restore();

}
Exemplo n.º 2
0
void drawBottomHtmlLine(QPainter *painter, const QFont font, QRect rect, QString text){
    QRect r = rect;
    QFontInfo fi(font);
    int height = fi.pixelSize();
    r.moveTop(r.bottom() - height);
    drawHtmlLine(painter, font, r, text) ;

}
Exemplo n.º 3
0
int drawJustField(QPainter *painter, QFont font,
                      QString htmlField, QRect rect){

    //rightRect.moveRight(rect.right() - rect.width()*(1 - FIELD_NAME_RIGHTSPACE_RATIO));
    htmlField = tagAs(htmlField, "b");
    htmlField = tagAs(htmlField, "u");

    int fieldNameFontSize = fontSize4Width(
            crudeHtmlFragmentToPlainText(htmlField), rect.size(), font);
    QString txt = htmlFontSizeFormat(htmlField, fieldNameFontSize);
    if(painter){
        drawHtmlLine(painter, font, rect, txt);
    }
    return rect.height() ;

}
Exemplo n.º 4
0
int drawFieldAndValue(QPainter *painter, QFont font,
                       QString htmlField, QString htmlFieldValue, QRect rect){

    QRect rightRect = rect;
    rightRect.moveRight(rect.right() - rect.width()*(1 - FIELD_NAME_RIGHTSPACE_RATIO));

    int fieldNameFontSize = fontSize4Width(
            crudeHtmlFragmentToPlainText(htmlField), rightRect.size(), font);
    QString txt = htmlFontSizeFormat(htmlField, fieldNameFontSize) + " " + htmlFieldValue;
    bool breakLine = (fieldNameFontSize < FIELD_NAME_FONT_STANDARDSIZE);
    if(painter){
        drawHtmlLine(painter, font, rect, txt, breakLine);
    }
    return fieldNameFontSize + UI_FIELD_FONT_MARGIN;

}
Exemplo n.º 5
0
int drawFieldLabel(QPainter *painter, QFont font,
                       QString htmlFieldLabel, QRect rect,
                       bool bottomAligned){

    int fieldNameFontSize = fontSize4Width(
            crudeHtmlFragmentToPlainText(htmlFieldLabel), rect.size(), font);
    font.setPointSize(fieldNameFontSize);
    QFontMetrics fm(font);
    rect.setHeight(fm.height()+ fm.leading()*2+10);
    if(bottomAligned){
        drawBottomHtmlLine(painter, font, rect, htmlFieldLabel);
    } else {
        drawHtmlLine(painter, font, rect, htmlFieldLabel);
    }
    return rect.height();
}
Exemplo n.º 6
0
void IndividualIcon::paint( QPainter * painter,
             const QStyleOptionGraphicsItem * option, QWidget * ){

    //QGraphicsPixmapItem::paint(painter, option, widget);

    QRectF b = boundingRect();
    QIcon ic = m_item.getActualIcon();
    QRect iconRect;
    iconRect.setTopLeft(b.topLeft().toPoint());
    iconRect.setWidth(UI_DEFAULT_MINI_ICON_SIZE);
    iconRect.setHeight(UI_DEFAULT_MINI_ICON_SIZE);

    ic.paint(painter, iconRect);
    painter->save();
    if(this->isSelected()){
        QBrush brush1(option->palette.highlight());
        brush1.setStyle(Qt::SolidPattern);
        painter->setBrush(brush1);
        painter->drawRect(b);
    }
    QFont fnt = m_item.getDisplayFont();
//    QFontMetrics fm(fnt);
//    int fnt_h = fm.height();
    QRect r(0,0,0,0);
    r.setTop(b.height());
    r.setBottom(b.bottom());
    r.setWidth(b.width());


    painter->setClipRect(r);

    //qDebug() << "test onto rect: " << r;
    drawHtmlLine(painter, fnt, r, m_item.formattedName());

    painter->restore();

}
Exemplo n.º 7
0
void drawHtmlRightAligned(QPainter *painter, const QFont font, QRect rect, QString text){
    drawHtmlLine(painter, font, rect, text, false, true);

}