10#if QT_CONFIG(textedit)
13#include <QStringBuilder>
15#include <QPixmapCache>
16#include <QStyleOption>
18#if QT_CONFIG(progressbar)
19#include <QProgressBar>
25#if QT_CONFIG(combobox)
28#if QT_CONFIG(itemviews)
29#include <QAbstractItemView>
30#include <QStyledItemDelegate>
32#if QT_CONFIG(listview)
35#include <QAbstractScrollArea>
36#if QT_CONFIG(scrollbar)
39#if QT_CONFIG(scroller)
107#if QT_CONFIG(textedit)
108 if (qobject_cast<QTextEdit*>(
widget)) {
114#if QT_CONFIG(progressbar)
125 if (qobject_cast<QSlider*>(
widget))
128#if QT_CONFIG(combobox)
134 list->setProperty(
"_pixmap_combobox_list",
true);
150 pix.margins.right(),
desc.margins.bottom());
155 if (
qstrcmp(
widget->metaObject()->className(),
"QComboBoxPrivateContainer") == 0)
158#if QT_CONFIG(scrollarea)
159 if (QAbstractScrollArea *
scrollArea = qobject_cast<QAbstractScrollArea*>(
widget)) {
160 scrollArea->viewport()->setAutoFillBackground(
false);
161#if QT_CONFIG(itemviews)
167#if QT_CONFIG(gestures) && QT_CONFIG(scroller)
172#if QT_CONFIG(scrollbar)
173 if (qobject_cast<QScrollBar*>(
widget))
176#if !QT_CONFIG(progressbar) && !QT_CONFIG(combobox)
197 qobject_cast<QSlider*>(
widget)
202 || qobject_cast<QComboBox*>(
widget)
208 if (
qstrcmp(
widget->metaObject()->className(),
"QComboBoxPrivateContainer") == 0)
211#if QT_CONFIG(gestures) && QT_CONFIG(scrollarea) && QT_CONFIG(scroller)
212 if (QAbstractScrollArea *
scrollArea = qobject_cast<QAbstractScrollArea*>(
widget))
237#if QT_CONFIG(textedit)
239 if (qobject_cast<const QTextEdit*>(
widget))
250#if QT_CONFIG(listview)
251 if (qobject_cast<const QListView*>(
widget))
282 if (
qstrcmp(
widget->metaObject()->className(),
"QComboBoxPrivateContainer") == 0) {
286 rect.adjust(-
pix.margins.left(), -
desc.margins.top(),
287 pix.margins.right(),
desc.margins.bottom());
360 -
desc.margins.right(), -
desc.margins.bottom());
400#if QT_CONFIG(textedit)
401 if (qobject_cast<const QTextEdit*>(
widget)) {
409 return d->pixmaps.value(
CB_Enabled).pixmap.width();
411 return d->pixmaps.value(
CB_Enabled).pixmap.height();
416 qMax(
pix.margins.top(),
pix.margins.bottom()));
419 return d->pixmaps.value(
RB_Enabled).pixmap.width();
421 return d->pixmaps.value(
RB_Enabled).pixmap.height();
426 qMax(
pix.margins.top(),
pix.margins.bottom()));
430 if (
const QStyleOptionSlider *slider =
431 qstyleoption_cast<const QStyleOptionSlider*>(
option)) {
436 ?
desc.size.height() :
desc.size.width();
440 if (
const QStyleOptionSlider *slider =
441 qstyleoption_cast<const QStyleOptionSlider*>(
option)) {
450 if (
const QStyleOptionSlider *slider =
451 qstyleoption_cast<const QStyleOptionSlider*>(
option)) {
460 if (
const QStyleOptionSlider *slider =
461 qstyleoption_cast<const QStyleOptionSlider*>(
option)) {
466 ?
desc.size.height() :
desc.size.width();
521 if (
QSlider *slider = qobject_cast<QSlider*>(watched)) {
522 switch (
event->type()) {
532#if QT_CONFIG(combobox)
533 if (
QComboBox *comboBox = qobject_cast<QComboBox*>(watched)) {
534 switch (
event->type()) {
537 comboBox->setProperty(
"_pixmapstyle_combobox_pressed",
true);
541 comboBox->setProperty(
"_pixmapstyle_combobox_pressed",
false);
543 if ( comboBox->view() ) {
544 if ( comboBox->view()->isVisible() || (!comboBox->isEnabled()))
545 comboBox->hidePopup();
547 comboBox->showPopup();
555 if (
qstrcmp(watched->metaObject()->className(),
"QComboBoxPrivateContainer") == 0) {
562 const bool up = yPopup < yCombo;
599 desc.margins = margins;
600 desc.tileRules = tileRules;
603 d->descriptors[control] =
desc;
618 d->descriptors[dest] =
d->descriptors.value(
source);
630 auto descriptor =
d->descriptors.constFind(control);
631 if (descriptor ==
d->descriptors.constEnd())
633 const QPixmap pix =
d->getCachedPixmap(control, descriptor.value(),
rect.size());
657 pix.margins = margins;
659 d->pixmaps[control] =
pix;
672 d->pixmaps[dest] =
d->pixmaps.value(
source);
703#if QT_CONFIG(combobox)
789 bool vertical =
false;
791 qstyleoption_cast<const QStyleOptionProgressBar *>(
option)) {
801 qstyleoption_cast<const QStyleOptionProgressBar *>(
option)) {
816 qstyleoption_cast<const QStyleOptionProgressBar*>(
option);
828 const auto availablePixels = vertical ?
option->rect.height() :
option->rect.width();
829 const auto pixelsPerStep = double(availablePixels) / totalSteps;
831 const auto progress =
static_cast<int>(progressSteps * pixelsPerStep);
856 const QStyleOptionSlider *slider = qstyleoption_cast<const QStyleOptionSlider*>(
option);
935 if (
const QStyleOptionSlider *slider =
936 qstyleoption_cast<const QStyleOptionSlider*>(
option)) {
938 if (slider->minimum == slider->maximum)
954 const QSize &contentsSize,
962 int w = contentsSize.
width();
964 w +=
desc.margins.left() +
desc.margins.right() + bm;
965 h +=
desc.margins.top() +
desc.margins.bottom() + bm;
967 return d->computeSize(
desc,
w,
h);
981 return d->computeSize(
desc,
w,
h);
985 const QSize &contentsSize,
990 bool vertical =
false;
992 qstyleoption_cast<const QStyleOptionProgressBar *>(
option)) {
1006 const QSize &contentsSize,
1009#if QT_CONFIG(slider)
1012 const QStyleOptionSlider *slider = qstyleoption_cast<const QStyleOptionSlider*>(
option);
1034 const QSize &contentsSize,
1046 const QSize &contentsSize,
1078 r.setRect(
r.right() -
pix.margins.right() -
pix.pixmap.
width(),
1079 r.top() +
pix.margins.top(),
1083 r.adjust(
desc.margins.left(),
desc.margins.right(),
1084 -
desc.margins.right(), -
desc.margins.bottom());
1085 r.setRight(
r.right() -
pix.margins.right() -
pix.margins.left() -
pix.pixmap.
width());
1098#if QT_CONFIG(slider)
1099 if (
const QStyleOptionSlider *slider =
1100 qstyleoption_cast<const QStyleOptionSlider*>(
option)) {
1102 ? slider->rect.
width() : slider->rect.height();
1104 / (slider->maximum - slider->minimum + slider->pageStep);
1106 / (slider->maximum - slider->minimum + slider->pageStep);
1156 const QColor transparent(0, 0, 0, 0);
1157 result.fill( transparent );
1175 % u
'@' % sizeString;
1198#include "moc_qpixmapstyle_p.cpp"
The QAbstractItemView class provides the basic functionality for item view classes.
The QApplication class manages the GUI application's control flow and main settings.
The QColor class provides colors based on RGB, HSV or CMYK values.
The QComboBox widget is a combined button and popup list.
The QCommonStyle class encapsulates the common Look and Feel of a GUI.
int pixelMetric(PixelMetric m, const QStyleOption *opt=nullptr, const QWidget *widget=nullptr) const override
\reimp
QSize sizeFromContents(ContentsType ct, const QStyleOption *opt, const QSize &contentsSize, const QWidget *widget=nullptr) const override
\reimp
QRect subElementRect(SubElement r, const QStyleOption *opt, const QWidget *widget=nullptr) const override
\reimp
void unpolish(QWidget *widget) override
\reimp
void drawControl(ControlElement element, const QStyleOption *opt, QPainter *p, const QWidget *w=nullptr) const override
\reimp
SubControl hitTestComplexControl(ComplexControl cc, const QStyleOptionComplex *opt, const QPoint &pt, const QWidget *w=nullptr) const override
\reimp
int styleHint(StyleHint sh, const QStyleOption *opt=nullptr, const QWidget *w=nullptr, QStyleHintReturn *shret=nullptr) const override
\reimp
void polish(QPalette &) override
\reimp
QRect subControlRect(ComplexControl cc, const QStyleOptionComplex *opt, SubControl sc, const QWidget *w=nullptr) const override
\reimp
void drawComplexControl(ComplexControl cc, const QStyleOptionComplex *opt, QPainter *p, const QWidget *w=nullptr) const override
\reimp
void drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, QPainter *p, const QWidget *w=nullptr) const override
\reimp
void setPixelSize(int)
Sets the font size to pixelSize pixels, with a maxiumum size of an unsigned 16-bit integer.
The QFrame class is the base class of widgets that can have a frame.
void installEventFilter(QObject *filterObj)
Installs an event filter filterObj on this object.
virtual bool eventFilter(QObject *watched, QEvent *event)
Filters events if this object has been installed as an event filter for the watched object.
void removeEventFilter(QObject *obj)
Removes an event filter object obj from this object.
QVariant property(const char *name) const
Returns the value of the object's name property.
bool setProperty(const char *name, const QVariant &value)
Sets the value of the object's name property to value.
The QPainter class performs low-level painting on widgets and other paint devices.
void drawPixmap(const QRectF &targetRect, const QPixmap &pixmap, const QRectF &sourceRect)
Draws the rectangular portion source of the given pixmap into the given target in the paint device.
The QPalette class contains color groups for each widget state.
void setBrush(ColorRole cr, const QBrush &brush)
Sets the brush for the given color role to the specified brush for all groups in the palette.
static bool find(const QString &key, QPixmap *pixmap)
Looks for a cached pixmap associated with the given key in the cache.
static bool insert(const QString &key, const QPixmap &pixmap)
Inserts a copy of the pixmap pixmap associated with the key into the cache.
QPixmap getCachedPixmap(QPixmapStyle::ControlDescriptor control, const QPixmapStyleDescriptor &desc, const QSize &size) const
QSize computeSize(const QPixmapStyleDescriptor &desc, int width, int height) const
static QPixmap scale(int w, int h, const QPixmap &pixmap, const QPixmapStyleDescriptor &desc)
The QPixmapStyle class provides mechanism for writing pixmap based styles.
void drawTextEdit(const QStyleOption *option, QPainter *painter, const QWidget *widget) const
QRect subControlRect(ComplexControl cc, const QStyleOptionComplex *option, SubControl sc, const QWidget *widget=nullptr) const override
\reimp
void drawSlider(const QStyleOptionComplex *option, QPainter *painter, const QWidget *widget) const
int styleHint(StyleHint hint, const QStyleOption *option, const QWidget *widget, QStyleHintReturn *returnData) const override
\reimp
void drawPushButton(const QStyleOption *option, QPainter *painter, const QWidget *widget) const
void drawLineEdit(const QStyleOption *option, QPainter *painter, const QWidget *widget) const
QRect subElementRect(SubElement element, const QStyleOption *option, const QWidget *widget=nullptr) const override
\reimp
int pixelMetric(PixelMetric metric, const QStyleOption *option=nullptr, const QWidget *widget=nullptr) const override
\reimp
void drawCheckBox(const QStyleOption *option, QPainter *painter, const QWidget *widget) const
void drawControl(ControlElement element, const QStyleOption *option, QPainter *painter, const QWidget *widget=nullptr) const override
\reimp
void copyPixmap(ControlPixmap source, ControlPixmap dest)
void drawPanelItemViewItem(const QStyleOption *option, QPainter *painter, const QWidget *widget) const
void drawProgressBarBackground(const QStyleOption *option, QPainter *painter, const QWidget *widget) const
QSize itemViewSizeFromContents(const QStyleOption *option, const QSize &contentsSize, const QWidget *widget) const
QSize progressBarSizeFromContents(const QStyleOption *option, const QSize &contentsSize, const QWidget *widget) const
void polish(QApplication *application) override
\reimp
bool eventFilter(QObject *watched, QEvent *event) override
\reimp
QSize lineEditSizeFromContents(const QStyleOption *option, const QSize &contentsSize, const QWidget *widget) const
void drawScrollBar(const QStyleOptionComplex *option, QPainter *painter, const QWidget *widget) const
QRect comboBoxSubControlRect(const QStyleOptionComplex *option, QPixmapStyle::SubControl sc, const QWidget *widget) const
void copyDescriptor(ControlDescriptor source, ControlDescriptor dest)
Copies the data associated with the source descriptor to the dest descriptor.
void drawProgressBarLabel(const QStyleOption *option, QPainter *painter, const QWidget *widget) const
void drawRadioButton(const QStyleOption *option, QPainter *painter, const QWidget *widget) const
QRect scrollBarSubControlRect(const QStyleOptionComplex *option, QPixmapStyle::SubControl sc, const QWidget *widget) const
void addPixmap(ControlPixmap control, const QString &fileName, QMargins margins=QMargins())
Use this function to style statically sized controls such as check boxes.
void unpolish(QApplication *application) override
\reimp
void drawComplexControl(ComplexControl cc, const QStyleOptionComplex *option, QPainter *painter, const QWidget *widget=nullptr) const override
\reimp
void addDescriptor(ControlDescriptor control, const QString &fileName, QMargins margins=QMargins(), QTileRules tileRules=QTileRules(Qt::RepeatTile, Qt::RepeatTile))
Associates the pixmap having the given fileName with the given control.
void drawPrimitive(PrimitiveElement element, const QStyleOption *option, QPainter *painter, const QWidget *widget=nullptr) const override
\reimp
~QPixmapStyle()
Destroys the QPixmapStyle object.
QSize sliderSizeFromContents(const QStyleOption *option, const QSize &contentsSize, const QWidget *widget) const
SubControl hitTestComplexControl(ComplexControl control, const QStyleOptionComplex *option, const QPoint &pos, const QWidget *widget) const override
\reimp
void drawComboBox(const QStyleOptionComplex *option, QPainter *painter, const QWidget *widget) const
QSize sizeFromContents(ContentsType type, const QStyleOption *option, const QSize &contentsSize, const QWidget *widget=nullptr) const override
\reimp
void drawCachedPixmap(ControlDescriptor control, const QRect &rect, QPainter *p) const
Draws the image associated with the current control on the given rect using the given painter.
QSize pushButtonSizeFromContents(const QStyleOption *option, const QSize &contentsSize, const QWidget *widget) const
void drawProgressBarFill(const QStyleOption *option, QPainter *painter, const QWidget *widget) const
QSize comboBoxSizeFromContents(const QStyleOption *option, const QSize &contentsSize, const QWidget *widget) const
Returns a copy of the pixmap that is transformed using the given transformation transform and transfo...
int height() const
Returns the height of the pixmap.
bool isNull() const
Returns true if this is a null pixmap; otherwise returns false.
int width() const
Returns the width of the pixmap.
constexpr qreal y() const noexcept
Returns the y coordinate of this point.
\inmodule QtCore\reentrant
The QProgressBar widget provides a horizontal or vertical progress bar.
int minimum
the progress bar's minimum value
int maximum
the progress bar's maximum value
bool invertedAppearance
whether or not a progress bar shows its progress inverted
\inmodule QtCore\reentrant
constexpr bool isValid() const noexcept
Returns true if the rectangle is valid, otherwise returns false.
constexpr int bottom() const noexcept
Returns the y-coordinate of the rectangle's bottom edge.
constexpr void setRight(int pos) noexcept
Sets the right edge of the rectangle to the given x coordinate.
constexpr int top() const noexcept
Returns the y-coordinate of the rectangle's top edge.
constexpr void setBottom(int pos) noexcept
Sets the bottom edge of the rectangle to the given y coordinate.
constexpr void setLeft(int pos) noexcept
Sets the left edge of the rectangle to the given x coordinate.
constexpr int left() const noexcept
Returns the x-coordinate of the rectangle's left edge.
constexpr QSize size() const noexcept
Returns the size of the rectangle.
constexpr int width() const noexcept
Returns the width of the rectangle.
constexpr void moveTop(int pos) noexcept
Moves the rectangle vertically, leaving the rectangle's top edge at the given y coordinate.
constexpr int right() const noexcept
Returns the x-coordinate of the rectangle's right edge.
constexpr void setTop(int pos) noexcept
Sets the top edge of the rectangle to the given y coordinate.
constexpr int height() const noexcept
Returns the height.
constexpr int width() const noexcept
Returns the width.
The QSlider widget provides a vertical or horizontal slider.
\macro QT_RESTRICTED_CAST_FROM_ASCII
static QString number(int, int base=10)
This is an overloaded member function, provided for convenience. It differs from the above function o...
\variable QStyleOptionGraphicsItem::exposedRect
\variable QStyleOptionMenuItem::menuItemType
\variable QStyleOptionButton::features
The QStyleOption class stores the parameters used by QStyle functions.
ContentsType
This enum describes the available contents types.
virtual QPalette standardPalette() const
Returns the style's standard palette.
virtual QRect subControlRect(ComplexControl cc, const QStyleOptionComplex *opt, SubControl sc, const QWidget *widget=nullptr) const =0
Returns the rectangle containing the specified subControl of the given complex control (with the styl...
StyleHint
This enum describes the available style hints.
ControlElement
This enum represents a control element.
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.
PixelMetric
This enum describes the various available pixel metrics.
@ PM_ExclusiveIndicatorHeight
@ PM_ButtonShiftHorizontal
@ PM_CheckBoxLabelSpacing
@ PM_SliderControlThickness
@ PM_RadioButtonLabelSpacing
@ PM_ExclusiveIndicatorWidth
ComplexControl
This enum describes the available complex controls.
PrimitiveElement
This enum describes the various primitive elements.
@ PE_IndicatorRadioButton
virtual int pixelMetric(PixelMetric metric, const QStyleOption *option=nullptr, const QWidget *widget=nullptr) const =0
Returns the value of the given pixel metric.
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.
SubElement
This enum represents a sub-area of a widget.
const QStyle * proxy() const
SubControl
This enum describes the available sub controls.
The QStyledItemDelegate class provides display and editing facilities for data items from a model.
bool toBool() const
Returns the variant as a bool if the variant has userType() Bool.
Combined button and popup list for selecting options.
@ WA_TranslucentBackground
Q_CORE_EXPORT int qstrcmp(const char *str1, const char *str2)
Q_WIDGETS_EXPORT void qDrawBorderPixmap(QPainter *painter, const QRect &targetRect, const QMargins &targetMargins, const QPixmap &pixmap, const QRect &sourceRect, const QMargins &sourceMargins, const QTileRules &rules=QTileRules(), QDrawBorderPixmap::DrawingHints hints=QDrawBorderPixmap::DrawingHints())
constexpr const T & qMin(const T &a, const T &b)
constexpr const T & qMax(const T &a, const T &b)
GLuint64 GLenum void * handle
GLfloat GLfloat GLfloat w
[0]
GLint GLsizei GLsizei height
GLenum GLuint GLintptr GLsizeiptr size
[1]
GLenum GLuint GLenum GLsizei length
GLint GLenum GLsizei GLsizei GLsizei GLint border
GLenum GLenum GLsizei const GLuint GLboolean enabled
GLfloat GLfloat GLfloat GLfloat h
GLsizei GLsizei GLchar * source
GLdouble GLdouble GLdouble GLdouble q
GLenum GLenum GLenum GLenum GLenum scale
SSL_CTX int(* cb)(SSL *ssl, unsigned char **out, unsigned char *outlen, const unsigned char *in, unsigned int inlen, void *arg)
static QT_BEGIN_NAMESPACE QVariant hint(QPlatformIntegration::StyleHint h)
#define QT_CONFIG(feature)
The QTileRules class provides the rules used to draw a pixmap or image split into nine segments.