Logo Search packages:      
Sourcecode: qt4-x11 version File versions  Download package

QRect QStyle::itemPixmapRect ( const QRect rectangle,
int  alignment,
const QPixmap pixmap 
) const [virtual, inherited]

Returns the area within the given rectangle in which to draw the specified pixmap according to the defined alignment.

Reimplemented in QCleanlooksStyle.

Definition at line 442 of file qstyle.cpp.

References QRect::getRect(), QPixmap::height(), QApplication::isRightToLeft(), and QPixmap::width().

Referenced by QCleanlooksStyle::itemPixmapRect(), and QCommonStyle::subElementRect().

{
    QRect result;
    int x, y, w, h;
    rect.getRect(&x, &y, &w, &h);
    if ((alignment & Qt::AlignVCenter) == Qt::AlignVCenter)
        y += h/2 - pixmap.height()/2;
    else if ((alignment & Qt::AlignBottom) == Qt::AlignBottom)
        y += h - pixmap.height();
    if ((alignment & Qt::AlignRight) == Qt::AlignRight)
        x += w - pixmap.width();
    else if ((alignment & Qt::AlignHCenter) == Qt::AlignHCenter)
        x += w/2 - pixmap.width()/2;
    else if ((alignment & Qt::AlignLeft) != Qt::AlignLeft && QApplication::isRightToLeft())
        x += w - pixmap.width();
    result = QRect(x, y, pixmap.width(), pixmap.height());
    return result;
}


Generated by  Doxygen 1.6.0   Back to index