⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 qpainter.cpp

📁 qt-x11-opensource-src-4.1.4.tar.gz源码
💻 CPP
📖 第 1 页 / 共 5 页
字号:
QFontMetrics QPainter::fontMetrics() const{    Q_D(const QPainter);    return QFontMetrics(d->state->font);}/*!    Returns the font info for the painter if the painter is    active. Otherwise, the return value is undefined.    \sa font(), isActive(), {QPainter#Settings}{Settings}*/QFontInfo QPainter::fontInfo() const{    Q_D(const QPainter);    return QFontInfo(d->state->font);}/*!    Returns the currently set brush origin.    \sa setBrushOrigin(), {QPainter#Settings}{Settings}*/QPoint QPainter::brushOrigin() const{    Q_D(const QPainter);    return QPointF(d->state->bgOrigin).toPoint();}/*!    \fn void QPainter::setBrushOrigin(const QPointF &position)    Sets the brush origin to \a position.    The brush origin specifies the (0, 0) coordinate of the painter's    brush. This setting only applies to pattern brushes and pixmap    brushes.    Note that while the brushOrigin() was necessary to adopt the    parent's background for a widget in Qt 3, this is no longer the    case since the Qt 4 painter doesn't paint the background unless    you explicitly tell it to do so by setting the widget's \l    {QWidget::autoFillBackground}{autoFillBackground} property to    true.    \sa brushOrigin(), {QPainter#Settings}{Settings}*/void QPainter::setBrushOrigin(const QPointF &p){    Q_D(QPainter);#ifdef QT_DEBUG_DRAW    if (qt_show_painter_debug_output)        printf("QPainter::setBrushOrigin(), (%.2f,%.2f)\n", p.x(), p.y());#endif    d->state->bgOrigin = p;    d->state->dirtyFlags |= QPaintEngine::DirtyBrushOrigin;}/*!    \fn void QPainter::setBrushOrigin(const QPoint &position)    \overload    Sets the brush's origin to the given \a position.*//*!    \fn void QPainter::setBrushOrigin(int x, int y)    \overload    Sets the brush's origin to point (\a x, \a y).*//*!    \enum QPainter::CompositionMode    Defines the Porter-Duff rules for digital image    compositing. Composition modes are used to specify how the pixels    in one image, the source, are merged with the pixel in another    image, the destination.     \image qpainter-compositionmode1.png     \image qpainter-compositionmode2.png    The most common type is SourceOver (often referred to as just    alpha blending) where the source pixel is blended on top of the    destination pixel in such a way that the alpha component of the    source defines the translucency of the pixel.    Composition modes will only work when the paint device is a QImage    in Format_ARGB32_Premultiplied or Format_ARGB32, where the    premultiplied version is the preferred format.    When a composition mode is set it applies to all painting    operator, pens, brushes, gradients and pixmap/image drawing.    \value CompositionMode_SourceOver This is the default mode. The    alpha of the source is used to blend the pixel on top of the    destination.    \value CompositionMode_DestinationOver The alpha of the    destination is used to blend it on top of the source pixels. This    mode is the inverse of CompositionMode_SourceOver.    \value CompositionMode_Clear The pixels in the destination are    cleared (set to fully transparent) independent of the source.    \value CompositionMode_Source The output is the source    pixel. (This means a basic copy operation and is identical to    SourceOver when the source pixel is opaque).    \value CompositionMode_Destination The output is the destination    pixel. This means that the blending has no effect. This mode is    the inverse of CompositionMode_Source.    \value CompositionMode_SourceIn The output is the source, where    the alpha is reduced by that of the destination.    \value CompositionMode_DestinationIn The output is the    destination, where the alpha is reduced by that of the    source. This mode is the inverse of CompositionMode_SourceIn.    \value CompositionMode_SourceOut The output is the source, where    the alpha is reduced by the inverse of destination.    \value CompositionMode_DestinationOut The output is the    destination, where the alpha is reduced by the inverse of the    source. This mode is the inverse of CompositionMode_SourceOut.    \value CompositionMode_SourceAtop The source pixel is blended on    top of the destination, with the alpha of the source pixel reduced    by the alpha of the destination pixel.    \value CompositionMode_DestinationAtop The destination pixel is    blended on top of the source, with the alpha of the destination    pixel is reduced by the alpha of the destination pixel. This mode    is the inverse of CompositionMode_SourceAtop.    \value CompositionMode_Xor The source, which alpha is reduced with    the inverse of the destination alpha, is merged with the    destination, which alpha is reduced by the inverse of the source    alpha. CompositionMode_Xor is not the same as the bitwise Xor.    \sa compositionMode(), setCompositionMode(), {QPainter#Composition    Modes}{Composition Modes}*//*!    Sets the composition mode to the given  \a mode.    \warning You can only set the composition mode for QPainter    objects that operates on a QImage.    \sa compositionMode()*/void QPainter::setCompositionMode(CompositionMode mode){    Q_D(QPainter);    if (!isActive()) {        qWarning("QPainter::setCompositionMode(), painter not active");        return;    } else if (!d->engine->hasFeature(QPaintEngine::PorterDuff)) {        qWarning("QPainter::setCompositionMode(), composition modes not supported on device");        return;    }    d->state->composition_mode = mode;    d->state->dirtyFlags |= QPaintEngine::DirtyCompositionMode;}/*!  Returns the current composition mode.  \sa CompositionMode, setCompositionMode()*/QPainter::CompositionMode QPainter::compositionMode() const{    Q_D(const QPainter);    return d->state->composition_mode;}/*!    Returns the current background brush.    \sa setBackground(), {QPainter#Settings}{Settings}*/const QBrush &QPainter::background() const{    Q_D(const QPainter);    return d->state->bgBrush;}/*!    Returns true if clipping has been set; otherwise returns false.    \sa setClipping(), {QPainter#Clipping}{Clipping}*/bool QPainter::hasClipping() const{    Q_D(const QPainter);    return d->state->clipEnabled && d->state->clipOperation != Qt::NoClip;}/*!    Enables clipping if  \a enable is true, or disables clipping if  \a    enable is false.    \sa hasClipping(), {QPainter#Clipping}{Clipping}*/void QPainter::setClipping(bool enable){    Q_D(QPainter);#ifdef QT_DEBUG_DRAW    if (qt_show_painter_debug_output)        printf("QPainter::setClipping(), enable=%s, was=%s\n",               enable ? "on" : "off",               hasClipping() ? "on" : "off");#endif    if (!isActive()) {        qWarning("QPainter::setClipping(), painter not active, state will be reset by begin");        return;    }    if (hasClipping() == enable)        return;    // we can't enable clipping if we don't have a clip    if (enable        && (d->state->clipInfo.isEmpty() || d->state->clipInfo.last().operation == Qt::NoClip))        return;    if (enable)        d->state->clipEnabled = true;    else        d->state->clipEnabled = false;    d->state->dirtyFlags |= QPaintEngine::DirtyClipEnabled;    d->updateState(d->state);}/*!    Returns the currently set clip region. Note that the clip region    is given in logical coordinates.    \sa setClipRegion(), clipPath(), setClipping()*/QRegion QPainter::clipRegion() const{    if (!isActive()) {        qWarning("QPainter::clipRegion(), painter not active");        return QRegion();    }    Q_D(const QPainter);    QRegion region;    bool lastWasNothing = true;    if (!d->txinv)        const_cast<QPainter *>(this)->d_ptr->updateInvMatrix();    for (int i=0; i<d->state->clipInfo.size(); ++i) {        const QPainterClipInfo &info = d->state->clipInfo.at(i);        QRegion other;        switch (info.clipType) {        case QPainterClipInfo::RegionClip: {            QMatrix matrix = (info.matrix * d->invMatrix);            if (lastWasNothing) {                region = info.region * matrix;                lastWasNothing = false;                continue;            }            if (info.operation == Qt::IntersectClip)                region &= info.region * matrix;            else if (info.operation == Qt::UniteClip)                region |= info.region * matrix;            else if (info.operation == Qt::NoClip) {                lastWasNothing = true;                region = QRegion();            } else                region = info.region * matrix;            break;        }        case QPainterClipInfo::PathClip: {            QMatrix matrix = (info.matrix * d->invMatrix);            if (lastWasNothing) {                region = QRegion((info.path * matrix).toFillPolygon().toPolygon(),                                 info.path.fillRule());                lastWasNothing = false;                continue;            }            if (info.operation == Qt::IntersectClip) {                region &= QRegion((info.path * matrix).toFillPolygon().toPolygon(),                                  info.path.fillRule());            } else if (info.operation == Qt::UniteClip) {                region |= QRegion((info.path * matrix).toFillPolygon().toPolygon(),                                  info.path.fillRule());            } else if (info.operation == Qt::NoClip) {                lastWasNothing = true;                region = QRegion();            } else {                region = QRegion((info.path * matrix).toFillPolygon().toPolygon(),                                 info.path.fillRule());            }            break;        }        }    }    return region;}/*!    Returns the currently clip as a path. Note that the clip path is    given in logical coordinates.    \sa setClipPath(), clipRegion(), setClipping()*/QPainterPath QPainter::clipPath() const{    // ### Since we do not support path intersections and path unions yet,    // we just use clipRegion() here...    if (!isActive()) {        qWarning("QPainter::clipPath(), painter not active");        return QPainterPath();    }    Q_D(const QPainter);    // No clip, return empty    if (d->state->clipInfo.size() == 0) {        return QPainterPath();    } else {        // Update inverse matrix, used below.        if (!d->txinv)            const_cast<QPainter *>(this)->d_ptr->updateInvMatrix();        // For the simple case avoid conversion.        if (d->state->clipInfo.size() == 1            && d->state->clipInfo.at(0).clipType == QPainterClipInfo::PathClip) {            QMatrix matrix = (d->state->clipInfo.at(0).matrix * d->invMatrix);            return d->state->clipInfo.at(0).path * matrix;        // Fallback to clipRegion() for now, since we don't have isect/unite for paths        } else {            QPainterPath path;            path.addRegion(clipRegion());            return path;        }    }}/*!    \fn void QPainter::setClipRect(const QRectF &rectangle, Qt::ClipOperation operation)    Enables clipping, and sets the clip region to the given \a    rectangle using the given clip \a operation. The default operation    is to replace the current clip rectangle.    Note that the clip rectangle is specified in logical (painter)    coordinates.    \sa clipRegion(), setClipping(), {QPainter#Clipping}{Clipping}*/void QPainter::setClipRect(const QRectF &rect, Qt::ClipOperation op){    QPainterPath path;    path.addRect(rect);    setClipPath(path, op);}/*!    \fn void QPainter::setClipRect(const QRect &rectangle, Qt::ClipOperation operation)    \overload    Enables clipping, and sets the clip region to the given \a rectangle using the given    clip \a operation.*//*!    \fn void QPainter::setClipRect(int x, int y, int width, int height, Qt::ClipOperation operation)    Enables clipping, and sets the clip region to the rectangle beginning at (\a x, \a y)    with the given \a width and \a height.*//*!    \fn void QPainter::setClipRegion(const QRegion &region, Qt::ClipOperation operation)    Sets the clip region to the givne \a region using the given clip    \a operation. The default clip operation is to replace the current    clip region.    Note that the clip region is given in logical coordinates.    \sa clipRegion(), setClipRect(), {QPainter#Clipping}{Clipping}*/void QPainter::setClipRegion(const QRegion &r, Qt::ClipOperation op)

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -