9#include <QtCore/private/qobject_p.h>
10#include <QtGui/qguiapplication.h>
31 Q_DECLARE_PUBLIC(QStyle)
41 const qreal pixelRatio = qApp->devicePixelRatio();
42 QImage cacheImage = QImage(size * pixelRatio, QImage::Format_ARGB32_Premultiplied);
43 cacheImage.setDevicePixelRatio(pixelRatio);
49 const qreal pixelRatio = qApp->devicePixelRatio();
50 QPixmap cachePixmap = QPixmap(size * pixelRatio);
51 cachePixmap.setDevicePixelRatio(pixelRatio);
55#define BEGIN_STYLE_PIXMAPCACHE(a)
56 QRect rect = option->rect;
57 QPixmap internalPixmapCache;
59 QPainter *p = painter;
60 QString unique = QStyleHelper::uniqueName((a), option, option->rect.size());
61 int txType = painter->deviceTransform().type() | painter->worldTransform().type();
62 bool doPixmapCache = (!option->rect.isEmpty())
63 && ((txType <= QTransform::TxTranslate) || (painter->deviceTransform().type() == QTransform::TxScale));
64 if (doPixmapCache && QPixmapCache::find(unique, &internalPixmapCache)) {
65 painter->drawPixmap(option->rect.topLeft(), internalPixmapCache);
68 rect.setRect(0
, 0
, option->rect.width(), option->rect.height());
69 imageCache = styleCacheImage(option->rect.size());
71 p = new QPainter(&imageCache);
74#define END_STYLE_PIXMAPCACHE
78 internalPixmapCache = QPixmap::fromImage(imageCache);
79 painter->drawPixmap(option->rect.topLeft(), internalPixmapCache);
80 QPixmapCache::insert(unique, internalPixmapCache);
const QStyle * proxy() const
virtual QPixmap standardPixmap(StandardPixmap standardPixmap, const QStyleOption *opt=nullptr) const =0
virtual QRect itemPixmapRect(const QRect &r, int flags, const QPixmap &pixmap) const
Returns the area within the given rectangle in which to draw the specified pixmap according to the de...
virtual QPalette standardPalette() const
Returns the style's standard palette.
virtual QSize sizeFromContents(ContentsType ct, const QStyleOption *opt, const QSize &contentsSize) const =0
static Qt::Alignment visualAlignment(Qt::LayoutDirection direction, Qt::Alignment alignment)
Transforms an alignment of Qt::AlignLeft or Qt::AlignRight without Qt::AlignAbsolute into Qt::AlignLe...
virtual int pixelMetric(PixelMetric metric, const QStyleOption *option=nullptr) const =0
virtual ~QStyle()
Destroys the style object.
virtual void drawItemPixmap(QPainter *painter, const QRect &rect, int alignment, const QPixmap &pixmap) const
Draws the given pixmap in the specified rectangle, according to the specified alignment,...
virtual void drawComplexControl(ComplexControl cc, const QStyleOptionComplex *opt, QPainter *p) const =0
virtual void drawControl(ControlElement element, const QStyleOption *opt, QPainter *p) const =0
virtual QFont font(ControlElement element, const QStyle::State state) const =0
QStyle()
Constructs a style object.
static QRect alignedRect(Qt::LayoutDirection direction, Qt::Alignment alignment, const QSize &size, const QRect &rectangle)
Returns a new rectangle of the specified size that is aligned to the given rectangle according to the...
virtual void drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, QPainter *p) const =0
static int sliderPositionFromValue(int min, int max, int val, int space, bool upsideDown=false)
Converts the given logicalValue to a pixel position.
virtual QRect subControlRect(ComplexControl cc, const QStyleOptionComplex *opt, SubControl sc) const =0
static QRect visualRect(Qt::LayoutDirection direction, const QRect &boundingRect, const QRect &logicalRect)
Returns the given logicalRectangle converted to screen coordinates based on the specified direction.
virtual QRect subElementRect(SubElement subElement, const QStyleOption *option) const =0
static int sliderValueFromPosition(int min, int max, int pos, int space, bool upsideDown=false)
Converts the given pixel position to a logical value.
virtual QPixmap generatedIconPixmap(QIcon::Mode iconMode, const QPixmap &pixmap, const QStyleOption *opt) const =0
virtual int styleHint(StyleHint stylehint, const QStyleOption *opt=nullptr, QStyleHintReturn *returnData=nullptr) const =0
@ State_KeyboardFocusChange
virtual QIcon standardIcon(StandardPixmap standardIcon, const QStyleOption *option=nullptr) const =0
virtual void drawItemText(QPainter *painter, const QRect &rect, int flags, const QPalette &pal, bool enabled, const QString &text, QPalette::ColorRole textRole=QPalette::NoRole) const
Draws the given text in the specified rectangle using the provided painter and palette.
virtual QMargins ninePatchMargins(ComplexControl cc, const QStyleOptionComplex *opt, const QSize &imageSize) const =0
virtual SubControl hitTestComplexControl(ComplexControl cc, const QStyleOptionComplex *opt, const QPoint &pt) const =0
virtual QMargins ninePatchMargins(ControlElement ce, const QStyleOption *opt, const QSize &imageSize) const =0
static QPoint visualPos(Qt::LayoutDirection direction, const QRect &boundingRect, const QPoint &logicalPos)
Returns the given logicalPosition converted to screen coordinates based on the specified direction.
QPixmap styleCachePixmap(const QSize &size)
QImage styleCacheImage(const QSize &size)
Combined button and popup list for selecting options.