Qt 4.8
Public Types | Public Functions | Public Variables | List of all members
QRenderRule Class Reference

Public Types

enum  { Margin = 1, Border = 2, Padding = 4, All =Margin|Border|Padding }
 

Public Functions

QSize adjustSize (const QSize &sz)
 
const QStyleSheetBackgroundDatabackground () const
 
bool baseStyleCanDraw () const
 
const QStyleSheetBorderDataborder () const
 
QPainterPath borderClip (QRect rect)
 
QRect borderRect (const QRect &r) const
 
const QStyleSheetBoxDatabox () const
 
QRect boxRect (const QRect &r, int flags=All) const
 
QSize boxSize (const QSize &s, int flags=All) const
 
void configurePalette (QPalette *, QPalette::ColorGroup, const QWidget *, bool)
 
void configurePalette (QPalette *p, QPalette::ColorRole fr, QPalette::ColorRole br)
 
QRect contentsRect (const QRect &r) const
 
QSize contentsSize () const
 
QSize contentsSize (const QSize &sz) const
 
void drawBackground (QPainter *, const QRect &, const QPoint &=QPoint(0, 0))
 
void drawBackgroundImage (QPainter *, const QRect &, QPoint=QPoint(0, 0))
 
void drawBorder (QPainter *, const QRect &)
 
void drawBorderImage (QPainter *, const QRect &)
 
void drawFrame (QPainter *, const QRect &)
 
void drawImage (QPainter *p, const QRect &rect)
 
void drawOutline (QPainter *, const QRect &)
 
void drawRule (QPainter *, const QRect &)
 
void fixupBorder (int)
 
const QStyleSheetGeometryDatageometry () const
 
bool hasBackground () const
 
bool hasBorder () const
 
bool hasBox () const
 
bool hasContentsSize () const
 
bool hasDrawable () const
 
bool hasGeometry () const
 
bool hasGradientBackground () const
 
bool hasImage () const
 
bool hasNativeBorder () const
 
bool hasNativeOutline () const
 
bool hasOutline () const
 
bool hasPalette () const
 
bool hasPosition () const
 
bool hasStyleHint (const QString &sh) const
 
QSize minimumContentsSize () const
 
QSize minimumSize () const
 
QRect originRect (const QRect &rect, Origin origin) const
 
const QStyleSheetOutlineDataoutline () const
 
QRect outlineRect (const QRect &r) const
 
QRect paddingRect (const QRect &r) const
 
const QStyleSheetPaletteDatapalette () const
 
const QStyleSheetPositionDataposition () const
 
 QRenderRule ()
 
 QRenderRule (const QVector< QCss::Declaration > &, const QWidget *)
 
void setClip (QPainter *p, const QRect &rect)
 
QSize size () const
 
QSize size (const QSize &sz) const
 
QVariant styleHint (const QString &sh) const
 
void unsetClip (QPainter *)
 
 ~QRenderRule ()
 

Public Variables

QSharedDataPointer< QStyleSheetBoxDatab
 
QSharedDataPointer< QStyleSheetBorderDatabd
 
QSharedDataPointer< QStyleSheetBackgroundDatabg
 
QPainterPath clipPath
 
int clipset
 
QBrush defaultBackground
 
int features
 
QFont font
 
QSharedDataPointer< QStyleSheetGeometryDatageo
 
bool hasFont
 
QSharedDataPointer< QStyleSheetImageDataimg
 
QSharedDataPointer< QStyleSheetOutlineDataou
 
QSharedDataPointer< QStyleSheetPositionDatap
 
QSharedDataPointer< QStyleSheetPaletteDatapal
 
QHash< QString, QVariantstyleHints
 

Detailed Description

Definition at line 468 of file qstylesheetstyle.cpp.

Enumerations

◆ anonymous enum

anonymous enum
Enumerator
Margin 
Border 
Padding 
All 

Definition at line 480 of file qstylesheetstyle.cpp.

Constructors and Destructors

◆ QRenderRule() [1/2]

QRenderRule::QRenderRule ( )
inline

Definition at line 471 of file qstylesheetstyle.cpp.

Referenced by QStyleSheetStyle::renderRule().

471 : features(0), hasFont(false), pal(0), b(0), bg(0), bd(0), ou(0), geo(0), p(0), img(0), clipset(0) { }
QSharedDataPointer< QStyleSheetOutlineData > ou
QSharedDataPointer< QStyleSheetGeometryData > geo
QSharedDataPointer< QStyleSheetPositionData > p
QSharedDataPointer< QStyleSheetBorderData > bd
QSharedDataPointer< QStyleSheetBackgroundData > bg
QSharedDataPointer< QStyleSheetImageData > img
QSharedDataPointer< QStyleSheetBoxData > b
QSharedDataPointer< QStyleSheetPaletteData > pal

◆ QRenderRule() [2/2]

QRenderRule::QRenderRule ( const QVector< QCss::Declaration > &  declarations,
const QWidget widget 
)

Definition at line 863 of file qstylesheetstyle.cpp.

864 : features(0), hasFont(false), pal(0), b(0), bg(0), bd(0), ou(0), geo(0), p(0), img(0), clipset(0)
865 {
866  QPalette palette = QApplication::palette(); // ###: ideally widget's palette
867  ValueExtractor v(declarations, palette);
868  features = v.extractStyleFeatures();
869 
870  int w = -1, h = -1, minw = -1, minh = -1, maxw = -1, maxh = -1;
871  if (v.extractGeometry(&w, &h, &minw, &minh, &maxw, &maxh))
872  geo = new QStyleSheetGeometryData(w, h, minw, minh, maxw, maxh);
873 
874  int left = 0, top = 0, right = 0, bottom = 0;
875  Origin origin = Origin_Unknown;
876  Qt::Alignment position = 0;
878  Qt::Alignment textAlignment = 0;
879  if (v.extractPosition(&left, &top, &right, &bottom, &origin, &position, &mode, &textAlignment))
880  p = new QStyleSheetPositionData(left, top, right, bottom, origin, position, mode, textAlignment);
881 
882  int margins[4], paddings[4], spacing = -1;
883  for (int i = 0; i < 4; i++)
884  margins[i] = paddings[i] = 0;
885  if (v.extractBox(margins, paddings, &spacing))
886  b = new QStyleSheetBoxData(margins, paddings, spacing);
887 
888  int borders[4];
889  QBrush colors[4];
890  QCss::BorderStyle styles[4];
891  QSize radii[4];
892  for (int i = 0; i < 4; i++) {
893  borders[i] = 0;
894  styles[i] = BorderStyle_None;
895  }
896  if (v.extractBorder(borders, colors, styles, radii))
897  bd = new QStyleSheetBorderData(borders, colors, styles, radii);
898 
899  int offsets[4];
900  for (int i = 0; i < 4; i++) {
901  borders[i] = offsets[i] = 0;
902  styles[i] = BorderStyle_None;
903  }
904  if (v.extractOutline(borders, colors, styles, radii, offsets))
905  ou = new QStyleSheetOutlineData(borders, colors, styles, radii, offsets);
906 
907  QBrush brush;
908  QString uri;
909  Repeat repeat = Repeat_XY;
910  Qt::Alignment alignment = Qt::AlignTop | Qt::AlignLeft;
911  Attachment attachment = Attachment_Scroll;
912  origin = Origin_Padding;
913  Origin clip = Origin_Border;
914  if (v.extractBackground(&brush, &uri, &repeat, &alignment, &origin, &attachment, &clip))
915  bg = new QStyleSheetBackgroundData(brush, QPixmap(uri), repeat, alignment, origin, attachment, clip);
916 
917  QBrush sfg, fg;
918  QBrush sbg, abg;
919  if (v.extractPalette(&fg, &sfg, &sbg, &abg))
920  pal = new QStyleSheetPaletteData(fg, sfg, sbg, abg);
921 
922  QIcon icon;
923  alignment = Qt::AlignCenter;
924  QSize size;
925  if (v.extractImage(&icon, &alignment, &size))
926  img = new QStyleSheetImageData(icon, alignment, size);
927 
928  int adj = -255;
929  hasFont = v.extractFont(&font, &adj);
930 
931 #ifndef QT_NO_TOOLTIP
932  if (widget && qstrcmp(widget->metaObject()->className(), "QTipLabel") == 0)
933  palette = QToolTip::palette();
934 #endif
935 
936  for (int i = 0; i < declarations.count(); i++) {
937  const Declaration& decl = declarations.at(i);
938  if (decl.d->propertyId == BorderImage) {
939  QString uri;
940  QCss::TileMode horizStretch, vertStretch;
941  int cuts[4];
942 
943  decl.borderImageValue(&uri, cuts, &horizStretch, &vertStretch);
944  if (uri.isEmpty() || uri == QLatin1String("none")) {
945  if (bd && bd->bi)
946  bd->bi->pixmap = QPixmap();
947  } else {
948  if (!bd)
950  if (!bd->bi)
952 
954  bi->pixmap = QPixmap(uri);
955  for (int i = 0; i < 4; i++)
956  bi->cuts[i] = cuts[i];
957  bi->horizStretch = horizStretch;
958  bi->vertStretch = vertStretch;
959  }
960  } else if (decl.d->propertyId == QtBackgroundRole) {
961  if (bg && bg->brush.style() != Qt::NoBrush)
962  continue;
963  int role = decl.d->values.at(0).variant.toInt();
964  if (role >= Value_FirstColorRole && role <= Value_LastColorRole)
966  } else if (decl.d->property.startsWith(QLatin1String("qproperty-"), Qt::CaseInsensitive)) {
967  // intentionally left blank...
968  } else if (decl.d->propertyId == UnknownProperty) {
969  bool knownStyleHint = false;
970  for (int i = 0; i < numKnownStyleHints; i++) {
972  if (decl.d->property.compare(styleHint) == 0) {
973  QString hintName = QString(styleHint);
974  QVariant hintValue;
975  if (hintName.endsWith(QLatin1String("alignment"))) {
976  hintValue = (int) decl.alignmentValue();
977  } else if (hintName.endsWith(QLatin1String("color"))) {
978  hintValue = (int) decl.colorValue().rgba();
979  } else if (hintName.endsWith(QLatin1String("size"))) {
980  hintValue = decl.sizeValue();
981  } else if (hintName.endsWith(QLatin1String("icon"))) {
982  hintValue = decl.iconValue();
983  } else if (hintName == QLatin1String("button-layout")
984  && decl.d->values.count() != 0 && decl.d->values.at(0).type == Value::String) {
985  hintValue = subControlLayout(decl.d->values.at(0).variant.toString());
986  } else {
987  int integer;
988  decl.intValue(&integer);
989  hintValue = integer;
990  }
991  styleHints[decl.d->property] = hintValue;
992  knownStyleHint = true;
993  break;
994  }
995  }
996  if (!knownStyleHint)
997  qDebug("Unknown property %s", qPrintable(decl.d->property));
998  }
999  }
1000 
1001  if (widget) {
1003  if (!style)
1004  style = qobject_cast<QStyleSheetStyle *>(widget->style());
1005  if (style)
1006  fixupBorder(style->nativeFrameWidth(widget));
1007 
1008  }
1009  if (hasBorder() && border()->hasBorderImage())
1011 }
The QVariant class acts like a union for the most common Qt data types.
Definition: qvariant.h:92
T qobject_cast(QObject *object)
Definition: qobject.h:375
QColor colorValue(const QPalette &=QPalette()) const
QVariant styleHint(const QString &sh) const
QSharedDataPointer< QStyleSheetOutlineData > ou
ColorRole
The ColorRole enum defines the different symbolic color roles used in current GUIs.
Definition: qpalette.h:93
static QList< QVariant > subControlLayout(const QString &layout)
static const int numKnownStyleHints
int count(const T &t) const
Returns the number of occurrences of value in the vector.
Definition: qvector.h:742
QSharedDataPointer< QStyleSheetGeometryData > geo
static QPalette palette()
Returns the palette used to render tooltips.
Definition: qtooltip.cpp:557
QSize sizeValue() const
QSharedDataPointer< QStyleSheetPositionData > p
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
static QPalette palette()
Returns the application palette.
PositionMode
Definition: qcssparser_p.h:331
The QString class provides a Unicode character string.
Definition: qstring.h:83
const QColor & color(ColorGroup cg, ColorRole cr) const
Returns the color in the specified color group, used for the given color role.
Definition: qpalette.h:107
Q_CORE_EXPORT QTextStream & right(QTextStream &s)
QStyle * style() const
Definition: qwidget.cpp:2742
QSharedDataPointer< QStyleSheetBorderData > bd
QIcon iconValue() const
QExplicitlySharedDataPointer< DeclarationData > d
Definition: qcssparser_p.h:430
Q_CORE_EXPORT void qDebug(const char *,...)
const QStyleSheetPaletteData * palette() const
QSharedDataPointer< QStyleSheetBackgroundData > bg
const QStyleSheetPositionData * position() const
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
Definition: qstring.h:704
void borderImageValue(QString *image, int *cuts, TileMode *h, TileMode *v) const
void fixupBorder(int)
bool intValue(int *i, const char *unit=0) const
QSharedDataPointer< QStyleSheetImageData > img
The QLatin1String class provides a thin wrapper around an US-ASCII/Latin-1 encoded string literal...
Definition: qstring.h:654
QBrush defaultBackground
QSharedDataPointer< QStyleSheetBoxData > b
The BorderImage element provides an image that can be used as a border.
QHash< QString, QVariant > styleHints
Qt::BrushStyle style() const
Returns the brush style.
Definition: qbrush.h:182
const T & at(int i) const
Returns the item at index position i in the vector.
Definition: qvector.h:350
QSharedDataPointer< QStyleSheetBorderImageData > bi
The QBrush class defines the fill pattern of shapes drawn by QPainter.
Definition: qbrush.h:76
static const QStyleSheetStyle * globalStyleSheetStyle
bool hasBorder() const
const QStyleSheetBorderData * border() const
const char * className() const
Returns the class name.
Definition: qobjectdefs.h:491
The QPixmap class is an off-screen image representation that can be used as a paint device...
Definition: qpixmap.h:71
The QSize class defines the size of a two-dimensional object using integer point precision.
Definition: qsize.h:53
int qstrcmp(const QByteArray &str1, const char *str2)
Definition: qbytearray.cpp:336
QRgb rgba() const
Returns the RGB value of the color, including its alpha.
Definition: qcolor.cpp:1019
bool endsWith(const QString &s, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Returns true if the string ends with s; otherwise returns false.
Definition: qstring.cpp:3796
static const char * knownStyleHints[]
QSize size() const
#define qPrintable(string)
Definition: qglobal.h:1750
Q_CORE_EXPORT QTextStream & left(QTextStream &s)
QSharedDataPointer< QStyleSheetPaletteData > pal
int nativeFrameWidth(const QWidget *)
Qt::Alignment alignmentValue() const
virtual const QMetaObject * metaObject() const
Returns a pointer to the meta-object of this object.
The QPalette class contains color groups for each widget state.
Definition: qpalette.h:61
The QIcon class provides scalable icons in different modes and states.
Definition: qicon.h:60

◆ ~QRenderRule()

QRenderRule::~QRenderRule ( )
inline

Definition at line 473 of file qstylesheetstyle.cpp.

473 { }

Functions

◆ adjustSize()

QSize QRenderRule::adjustSize ( const QSize sz)
inline

Definition at line 558 of file qstylesheetstyle.cpp.

Referenced by QStyleSheetStyle::sizeFromContents().

559  {
560  if (!geo)
561  return sz;
562  QSize csz = contentsSize();
563  if (csz.width() == -1) csz.setWidth(sz.width());
564  if (csz.height() == -1) csz.setHeight(sz.height());
565  if (geo->maxWidth != -1 && csz.width() > geo->maxWidth) csz.setWidth(geo->maxWidth);
566  if (geo->maxHeight != -1 && csz.height() > geo->maxHeight) csz.setHeight(geo->maxHeight);
567  csz=csz.expandedTo(QSize(geo->minWidth, geo->minHeight));
568  return csz;
569  }
QSharedDataPointer< QStyleSheetGeometryData > geo
QSize expandedTo(const QSize &) const
Returns a size holding the maximum width and height of this size and the given otherSize.
Definition: qsize.h:187
void setHeight(int h)
Sets the height to the given height.
Definition: qsize.h:135
QSize contentsSize() const
void setWidth(int w)
Sets the width to the given width.
Definition: qsize.h:132
int width() const
Returns the width.
Definition: qsize.h:126
int height() const
Returns the height.
Definition: qsize.h:129
The QSize class defines the size of a two-dimensional object using integer point precision.
Definition: qsize.h:53

◆ background()

const QStyleSheetBackgroundData* QRenderRule::background ( ) const
inline

◆ baseStyleCanDraw()

bool QRenderRule::baseStyleCanDraw ( ) const
inline

Definition at line 520 of file qstylesheetstyle.cpp.

Referenced by QStyleSheetStyle::drawControl(), QStyleSheetStyle::drawPrimitive(), QStyleSheetStyle::sizeFromContents(), QStyleSheetStyle::subControlRect(), and QStyleSheetStyle::subElementRect().

520  {
521  if (!hasBackground() || (background()->brush.style() == Qt::NoBrush && bg->pixmap.isNull()))
522  return true;
523  if (bg && !bg->pixmap.isNull())
524  return false;
525  if (hasGradientBackground())
528  }
bool hasGradientBackground() const
const QStyleSheetBackgroundData * background() const
bool hasBackground() const
QSharedDataPointer< QStyleSheetBackgroundData > bg
bool isNull() const
Returns true if this is a null pixmap; otherwise returns false.
Definition: qpixmap.cpp:615

◆ border()

const QStyleSheetBorderData* QRenderRule::border ( ) const
inline

◆ borderClip()

QPainterPath QRenderRule::borderClip ( QRect  rect)

Definition at line 1237 of file qstylesheetstyle.cpp.

Referenced by drawBackground(), and setClip().

1238 {
1239  if (!hasBorder())
1240  return QPainterPath();
1241 
1242  QSize tlr, trr, blr, brr;
1243  qNormalizeRadii(r, bd->radii, &tlr, &trr, &blr, &brr);
1244  if (tlr.isNull() && trr.isNull() && blr.isNull() && brr.isNull())
1245  return QPainterPath();
1246 
1247  const QRectF rect(r);
1248  const int *borders = border()->borders;
1249  QPainterPath path;
1250  qreal curY = rect.y() + borders[TopEdge]/qreal(2.0);
1251  path.moveTo(rect.x() + tlr.width(), curY);
1252  path.lineTo(rect.right() - trr.width(), curY);
1253  qreal curX = rect.right() - borders[RightEdge]/qreal(2.0);
1254  path.arcTo(curX - 2*trr.width() + borders[RightEdge], curY,
1255  trr.width()*2 - borders[RightEdge], trr.height()*2 - borders[TopEdge], 90, -90);
1256 
1257  path.lineTo(curX, rect.bottom() - brr.height());
1258  curY = rect.bottom() - borders[BottomEdge]/qreal(2.0);
1259  path.arcTo(curX - 2*brr.width() + borders[RightEdge], curY - 2*brr.height() + borders[BottomEdge],
1260  brr.width()*2 - borders[RightEdge], brr.height()*2 - borders[BottomEdge], 0, -90);
1261 
1262  path.lineTo(rect.x() + blr.width(), curY);
1263  curX = rect.left() + borders[LeftEdge]/qreal(2.0);
1264  path.arcTo(curX, rect.bottom() - 2*blr.height() + borders[BottomEdge]/2,
1265  blr.width()*2 - borders[LeftEdge], blr.height()*2 - borders[BottomEdge], 270, -90);
1266 
1267  path.lineTo(curX, rect.top() + tlr.height());
1268  path.arcTo(curX, rect.top() + borders[TopEdge]/2,
1269  tlr.width()*2 - borders[LeftEdge], tlr.height()*2 - borders[TopEdge], 180, -90);
1270 
1271  path.closeSubpath();
1272  return path;
1273 }
double qreal
Definition: qglobal.h:1193
The QPainterPath class provides a container for painting operations, enabling graphical shapes to be ...
Definition: qpainterpath.h:67
void closeSubpath()
Closes the current subpath by drawing a line to the beginning of the subpath, automatically starting ...
int left() const
Returns the x-coordinate of the rectangle&#39;s left edge.
Definition: qrect.h:240
void qNormalizeRadii(const QRect &br, const QSize *radii, QSize *tlr, QSize *trr, QSize *blr, QSize *brr)
Definition: qcssutil.cpp:316
int bottom() const
Returns the y-coordinate of the rectangle&#39;s bottom edge.
Definition: qrect.h:249
void moveTo(const QPointF &p)
Moves the current point to the given point, implicitly starting a new subpath and closing the previou...
QSharedDataPointer< QStyleSheetBorderData > bd
void lineTo(const QPointF &p)
Adds a straight line from the current position to the given endPoint.
int width() const
Returns the width.
Definition: qsize.h:126
The QRectF class defines a rectangle in the plane using floating point precision. ...
Definition: qrect.h:511
int top() const
Returns the y-coordinate of the rectangle&#39;s top edge.
Definition: qrect.h:243
int right() const
Returns the x-coordinate of the rectangle&#39;s right edge.
Definition: qrect.h:246
int y() const
Returns the y-coordinate of the rectangle&#39;s top edge.
Definition: qrect.h:255
bool hasBorder() const
void arcTo(const QRectF &rect, qreal startAngle, qreal arcLength)
Creates an arc that occupies the given rectangle, beginning at the specified startAngle and extending...
int x() const
Returns the x-coordinate of the rectangle&#39;s left edge.
Definition: qrect.h:252
const QStyleSheetBorderData * border() const
int height() const
Returns the height.
Definition: qsize.h:129
bool isNull() const
Returns true if both the width and height is 0; otherwise returns false.
Definition: qsize.h:117
The QSize class defines the size of a two-dimensional object using integer point precision.
Definition: qsize.h:53

◆ borderRect()

QRect QRenderRule::borderRect ( const QRect r) const

Definition at line 1013 of file qstylesheetstyle.cpp.

Referenced by drawBackgroundImage(), QStyleSheetStyle::drawControl(), drawFrame(), originRect(), outlineRect(), paddingRect(), QStyleSheetStyle::subControlRect(), and QStyleSheetStyle::subElementRect().

1014 {
1015  if (!hasBox())
1016  return r;
1017  const int* m = box()->margins;
1018  return r.adjusted(m[LeftEdge], m[TopEdge], -m[RightEdge], -m[BottomEdge]);
1019 }
QRect adjusted(int x1, int y1, int x2, int y2) const
Returns a new rectangle with dx1, dy1, dx2 and dy2 added respectively to the existing coordinates of ...
Definition: qrect.h:431
const QStyleSheetBoxData * box() const
bool hasBox() const

◆ box()

const QStyleSheetBoxData* QRenderRule::box ( ) const
inline

Definition at line 498 of file qstylesheetstyle.cpp.

Referenced by borderRect(), boxRect(), contentsRect(), and QStyleSheetStyle::pixelMetric().

498 { return b; }
QSharedDataPointer< QStyleSheetBoxData > b

◆ boxRect()

QRect QRenderRule::boxRect ( const QRect r,
int  flags = All 
) const

Definition at line 1048 of file qstylesheetstyle.cpp.

Referenced by boxSize(), and QStyleSheetStyle::drawComplexControl().

1049 {
1050  QRect r = cr;
1051  if (hasBox()) {
1052  if (flags & Margin) {
1053  const int *m = box()->margins;
1054  r.adjust(-m[LeftEdge], -m[TopEdge], m[RightEdge], m[BottomEdge]);
1055  }
1056  if (flags & Padding) {
1057  const int *p = box()->paddings;
1058  r.adjust(-p[LeftEdge], -p[TopEdge], p[RightEdge], p[BottomEdge]);
1059  }
1060  }
1061  if (hasBorder() && (flags & Border)) {
1062  const int *b = border()->borders;
1063  r.adjust(-b[LeftEdge], -b[TopEdge], b[RightEdge], b[BottomEdge]);
1064  }
1065  return r;
1066 }
QSharedDataPointer< QStyleSheetPositionData > p
const QStyleSheetBoxData * box() const
void adjust(int x1, int y1, int x2, int y2)
Adds dx1, dy1, dx2 and dy2 respectively to the existing coordinates of the rectangle.
Definition: qrect.h:434
QSharedDataPointer< QStyleSheetBoxData > b
bool hasBorder() const
bool hasBox() const
const QStyleSheetBorderData * border() const
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58

◆ boxSize()

QSize QRenderRule::boxSize ( const QSize s,
int  flags = All 
) const

Definition at line 1068 of file qstylesheetstyle.cpp.

Referenced by QStyleSheetStyle::setGeometry(), and QStyleSheetStyle::sizeFromContents().

1069 {
1070  QSize bs = boxRect(QRect(QPoint(0, 0), cs), flags).size();
1071  if (cs.width() < 0) bs.setWidth(-1);
1072  if (cs.height() < 0) bs.setHeight(-1);
1073  return bs;
1074 }
QRect boxRect(const QRect &r, int flags=All) const
void setHeight(int h)
Sets the height to the given height.
Definition: qsize.h:135
void setWidth(int w)
Sets the width to the given width.
Definition: qsize.h:132
QSize size() const
Returns the size of the rectangle.
Definition: qrect.h:309
The QPoint class defines a point in the plane using integer precision.
Definition: qpoint.h:53
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
The QSize class defines the size of a two-dimensional object using integer point precision.
Definition: qsize.h:53

◆ configurePalette() [1/2]

void QRenderRule::configurePalette ( QPalette p,
QPalette::ColorGroup  cg,
const QWidget w,
bool  embedded 
)

Definition at line 1373 of file qstylesheetstyle.cpp.

Referenced by QStyleSheetStyle::drawComplexControl(), QStyleSheetStyle::drawControl(), QStyleSheetStyle::drawPrimitive(), QStyleSheetStyle::setPalette(), and QStyleSheetStyle::styleSheetPalette().

1374 {
1375  if (bg && bg->brush.style() != Qt::NoBrush) {
1376  p->setBrush(cg, QPalette::Base, bg->brush); // for windows, windowxp
1377  p->setBrush(cg, QPalette::Button, bg->brush); // for plastique
1378  p->setBrush(cg, w->backgroundRole(), bg->brush);
1379  p->setBrush(cg, QPalette::Window, bg->brush);
1380  }
1381 
1382  if (embedded) {
1383  /* For embedded widgets (ComboBox, SpinBox and ScrollArea) we want the embedded widget
1384  * to be transparent when we have a transparent background or border image */
1385  if ((hasBackground() && background()->isTransparent())
1386  || (hasBorder() && border()->hasBorderImage() && !border()->borderImage()->pixmap.isNull()))
1387  p->setBrush(cg, w->backgroundRole(), Qt::NoBrush);
1388  }
1389 
1390  if (!hasPalette())
1391  return;
1392 
1393  if (pal->foreground.style() != Qt::NoBrush) {
1395  p->setBrush(cg, w->foregroundRole(), pal->foreground);
1398  }
1405 }
const QStyleSheetBackgroundData * background() const
bool hasBackground() const
QPalette::ColorRole backgroundRole() const
Returns the background role of the widget.
Definition: qwidget.cpp:4677
QSharedDataPointer< QStyleSheetBackgroundData > bg
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...
Definition: qpalette.h:206
QPalette::ColorRole foregroundRole() const
Returns the foreground role.
Definition: qwidget.cpp:4728
Qt::BrushStyle style() const
Returns the brush style.
Definition: qbrush.h:182
bool hasBorder() const
const QStyleSheetBorderData * border() const
bool hasPalette() const
QSharedDataPointer< QStyleSheetPaletteData > pal

◆ configurePalette() [2/2]

void QRenderRule::configurePalette ( QPalette p,
QPalette::ColorRole  fr,
QPalette::ColorRole  br 
)

Definition at line 1342 of file qstylesheetstyle.cpp.

1343 {
1344  if (bg && bg->brush.style() != Qt::NoBrush) {
1345  if (br != QPalette::NoRole)
1346  p->setBrush(br, bg->brush);
1348  if (bg->brush.style() == Qt::SolidPattern) {
1351  p->setBrush(QPalette::Dark, bg->brush.color().darker(150));
1353  }
1354  }
1355 
1356  if (!hasPalette())
1357  return;
1358 
1359  if (pal->foreground.style() != Qt::NoBrush) {
1360  if (fr != QPalette::NoRole)
1361  p->setBrush(fr, pal->foreground);
1364  }
1371 }
const QColor & color() const
Returns the brush color.
Definition: qbrush.h:183
QColor darker(int f=200) const
Returns a darker (or lighter) color, but does not change this object.
Definition: qcolor.h:301
QSharedDataPointer< QStyleSheetBackgroundData > bg
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...
Definition: qpalette.h:206
Qt::BrushStyle style() const
Returns the brush style.
Definition: qbrush.h:182
bool hasPalette() const
QColor lighter(int f=150) const
Returns a lighter (or darker) color, but does not change this object.
Definition: qcolor.h:298
QSharedDataPointer< QStyleSheetPaletteData > pal

◆ contentsRect()

QRect QRenderRule::contentsRect ( const QRect r) const

Definition at line 1039 of file qstylesheetstyle.cpp.

Referenced by QStyleSheetStyle::drawComplexControl(), QStyleSheetStyle::drawControl(), drawRule(), originRect(), QStyleSheetStyle::subControlRect(), QStyleSheetStyle::subElementRect(), and QStyleSheetStyle::titleBarLayout().

1040 {
1041  QRect pr = paddingRect(r);
1042  if (!hasBox())
1043  return pr;
1044  const int *p = box()->paddings;
1045  return pr.adjusted(p[LeftEdge], p[TopEdge], -p[RightEdge], -p[BottomEdge]);
1046 }
QRect adjusted(int x1, int y1, int x2, int y2) const
Returns a new rectangle with dx1, dy1, dx2 and dy2 added respectively to the existing coordinates of ...
Definition: qrect.h:431
QSharedDataPointer< QStyleSheetPositionData > p
const QStyleSheetBoxData * box() const
bool hasBox() const
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
QRect paddingRect(const QRect &r) const

◆ contentsSize() [1/2]

QSize QRenderRule::contentsSize ( ) const
inline

Definition at line 543 of file qstylesheetstyle.cpp.

544  { return geo ? QSize(geo->width, geo->height)
545  : ((img && img->size.isValid()) ? img->size : QSize()); }
QSharedDataPointer< QStyleSheetGeometryData > geo
QSharedDataPointer< QStyleSheetImageData > img
The QSize class defines the size of a two-dimensional object using integer point precision.
Definition: qsize.h:53
QSize size() const

◆ contentsSize() [2/2]

QSize QRenderRule::contentsSize ( const QSize sz) const
inline

Definition at line 546 of file qstylesheetstyle.cpp.

547  {
548  QSize csz = contentsSize();
549  if (csz.width() == -1) csz.setWidth(sz.width());
550  if (csz.height() == -1) csz.setHeight(sz.height());
551  return csz;
552  }
void setHeight(int h)
Sets the height to the given height.
Definition: qsize.h:135
QSize contentsSize() const
void setWidth(int w)
Sets the width to the given width.
Definition: qsize.h:132
int width() const
Returns the width.
Definition: qsize.h:126
int height() const
Returns the height.
Definition: qsize.h:129
The QSize class defines the size of a two-dimensional object using integer point precision.
Definition: qsize.h:53

◆ drawBackground()

void QRenderRule::drawBackground ( QPainter p,
const QRect rect,
const QPoint off = QPoint(0, 0) 
)

Definition at line 1297 of file qstylesheetstyle.cpp.

Referenced by drawFrame(), and QStyleSheetStyle::drawPrimitive().

1298 {
1299  QBrush brush = hasBackground() ? background()->brush : QBrush();
1300  if (brush.style() == Qt::NoBrush)
1301  brush = defaultBackground;
1302 
1303  if (brush.style() != Qt::NoBrush) {
1304  Origin origin = hasBackground() ? background()->clip : Origin_Border;
1305  // ### fix for gradients
1306  const QPainterPath &borderPath = borderClip(originRect(rect, origin));
1307  if (!borderPath.isEmpty()) {
1308  // Drawn intead of being used as clipping path for better visual quality
1309  bool wasAntialiased = p->renderHints() & QPainter::Antialiasing;
1311  p->fillPath(borderPath, brush);
1312  p->setRenderHint(QPainter::Antialiasing, wasAntialiased);
1313  } else {
1314  p->fillRect(originRect(rect, origin), brush);
1315  }
1316  }
1317 
1318  drawBackgroundImage(p, rect, off);
1319 }
bool isEmpty() const
Returns true if either there are no elements in this path, or if the only element is a MoveToElement;...
Definition: qpainterpath.h:392
The QPainterPath class provides a container for painting operations, enabling graphical shapes to be ...
Definition: qpainterpath.h:67
const QStyleSheetBackgroundData * background() const
bool hasBackground() const
QPainterPath borderClip(QRect rect)
QRect originRect(const QRect &rect, Origin origin) const
void setRenderHint(RenderHint hint, bool on=true)
Sets the given render hint on the painter if on is true; otherwise clears the render hint...
Definition: qpainter.cpp:7620
void fillPath(const QPainterPath &path, const QBrush &brush)
Fills the given path using the given brush.
Definition: qpainter.cpp:3456
void drawBackgroundImage(QPainter *, const QRect &, QPoint=QPoint(0, 0))
QBrush defaultBackground
Qt::BrushStyle style() const
Returns the brush style.
Definition: qbrush.h:182
The QBrush class defines the fill pattern of shapes drawn by QPainter.
Definition: qbrush.h:76
RenderHints renderHints() const
Returns a flag that specifies the rendering hints that are set for this painter.
Definition: qpainter.cpp:7675
void fillRect(const QRectF &, const QBrush &)
Fills the given rectangle with the brush specified.
Definition: qpainter.cpp:7420

◆ drawBackgroundImage()

void QRenderRule::drawBackgroundImage ( QPainter p,
const QRect rect,
QPoint  off = QPoint(0, 0) 
)

Definition at line 1157 of file qstylesheetstyle.cpp.

Referenced by drawBackground().

1158 {
1159  if (!hasBackground())
1160  return;
1161 
1162  const QPixmap& bgp = background()->pixmap;
1163  if (bgp.isNull())
1164  return;
1165 
1166  setClip(p, borderRect(rect));
1167 
1168  if (background()->origin != background()->clip) {
1169  p->save();
1170  p->setClipRect(originRect(rect, background()->clip), Qt::IntersectClip);
1171  }
1172 
1173  if (background()->attachment == Attachment_Fixed)
1174  off = QPoint(0, 0);
1175 
1176  QRect r = originRect(rect, background()->origin);
1178  QRect inter = aligned.translated(-off).intersected(r);
1179 
1180  switch (background()->repeat) {
1181  case Repeat_Y:
1182  p->drawTiledPixmap(inter.x(), r.y(), inter.width(), r.height(), bgp,
1183  inter.x() - aligned.x() + off.x(),
1184  bgp.height() - int(aligned.y() - r.y()) % bgp.height() + off.y());
1185  break;
1186  case Repeat_X:
1187  p->drawTiledPixmap(r.x(), inter.y(), r.width(), inter.height(), bgp,
1188  bgp.width() - int(aligned.x() - r.x())%bgp.width() + off.x(),
1189  inter.y() - aligned.y() + off.y());
1190  break;
1191  case Repeat_XY:
1192  p->drawTiledPixmap(r, bgp,
1193  QPoint(bgp.width() - int(aligned.x() - r.x())% bgp.width() + off.x(),
1194  bgp.height() - int(aligned.y() - r.y())%bgp.height() + off.y()));
1195  break;
1196  case Repeat_None:
1197  default:
1198  p->drawPixmap(inter.x(), inter.y(), bgp, inter.x() - aligned.x() + off.x(),
1199  inter.y() - aligned.y() + off.y(), inter.width(), inter.height());
1200  break;
1201  }
1202 
1203 
1204  if (background()->origin != background()->clip)
1205  p->restore();
1206 
1207  unsetClip(p);
1208 }
QRect borderRect(const QRect &r) const
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...
Definition: qstyle.cpp:2120
void setClip(QPainter *p, const QRect &rect)
int width() const
Returns the width of the pixmap.
Definition: qpixmap.cpp:630
QSize size() const
Returns the size of the pixmap.
Definition: qpixmap.cpp:661
void setClipRect(const QRectF &, Qt::ClipOperation op=Qt::ReplaceClip)
Enables clipping, and sets the clip region to the given rectangle using the given clip operation...
Definition: qpainter.cpp:2801
const QStyleSheetBackgroundData * background() const
void restore()
Restores the current painter state (pops a saved state off the stack).
Definition: qpainter.cpp:1620
QRect translated(int dx, int dy) const
Returns a copy of the rectangle that is translated dx along the x axis and dy along the y axis...
Definition: qrect.h:328
int width() const
Returns the width of the rectangle.
Definition: qrect.h:303
bool hasBackground() const
QRect intersected(const QRect &other) const
Returns the intersection of this rectangle and the given rectangle.
Definition: qrect.h:481
int height() const
Returns the height of the rectangle.
Definition: qrect.h:306
void save()
Saves the current painter state (pushes the state onto a stack).
Definition: qpainter.cpp:1590
void unsetClip(QPainter *)
QRect originRect(const QRect &rect, Origin origin) const
const QStyleSheetPositionData * position() const
void drawTiledPixmap(const QRectF &rect, const QPixmap &pm, const QPointF &offset=QPointF())
Draws a tiled pixmap, inside the given rectangle with its origin at the given position.
Definition: qpainter.cpp:7146
int y() const
Returns the y-coordinate of the rectangle&#39;s top edge.
Definition: qrect.h:255
int x() const
Returns the x-coordinate of the rectangle&#39;s left edge.
Definition: qrect.h:252
The QPoint class defines a point in the plane using integer precision.
Definition: qpoint.h:53
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
int y() const
Returns the y coordinate of this point.
Definition: qpoint.h:131
The QPixmap class is an off-screen image representation that can be used as a paint device...
Definition: qpixmap.h:71
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...
Definition: qpainter.cpp:5619
int height() const
Returns the height of the pixmap.
Definition: qpixmap.cpp:645
int x() const
Returns the x coordinate of this point.
Definition: qpoint.h:128
bool isNull() const
Returns true if this is a null pixmap; otherwise returns false.
Definition: qpixmap.cpp:615

◆ drawBorder()

void QRenderRule::drawBorder ( QPainter p,
const QRect rect 
)

Definition at line 1221 of file qstylesheetstyle.cpp.

Referenced by drawFrame().

1222 {
1223  if (!hasBorder())
1224  return;
1225 
1226  if (border()->hasBorderImage()) {
1227  drawBorderImage(p, rect);
1228  return;
1229  }
1230 
1231  bool wasAntialiased = p->renderHints() & QPainter::Antialiasing;
1233  qDrawBorder(p, rect, bd->styles, bd->borders, bd->colors, bd->radii);
1234  p->setRenderHint(QPainter::Antialiasing, wasAntialiased);
1235 }
void drawBorderImage(QPainter *, const QRect &)
QSharedDataPointer< QStyleSheetBorderData > bd
void setRenderHint(RenderHint hint, bool on=true)
Sets the given render hint on the painter if on is true; otherwise clears the render hint...
Definition: qpainter.cpp:7620
QCss::BorderStyle styles[4]
bool hasBorder() const
const QStyleSheetBorderData * border() const
void qDrawBorder(QPainter *p, const QRect &rect, const QCss::BorderStyle *styles, const int *borders, const QBrush *colors, const QSize *radii)
Definition: qcssutil.cpp:348
RenderHints renderHints() const
Returns a flag that specifies the rendering hints that are set for this painter.
Definition: qpainter.cpp:7675

◆ drawBorderImage()

void QRenderRule::drawBorderImage ( QPainter p,
const QRect rect 
)

Definition at line 1119 of file qstylesheetstyle.cpp.

Referenced by drawBorder().

1120 {
1121  setClip(p, rect);
1122  static const Qt::TileRule tileMode2TileRule[] = {
1124 
1125  const QStyleSheetBorderImageData *borderImageData = border()->borderImage();
1126  const int *targetBorders = border()->borders;
1127  const int *sourceBorders = borderImageData->cuts;
1128  QMargins sourceMargins(sourceBorders[LeftEdge], sourceBorders[TopEdge],
1129  sourceBorders[RightEdge], sourceBorders[BottomEdge]);
1130  QMargins targetMargins(targetBorders[LeftEdge], targetBorders[TopEdge],
1131  targetBorders[RightEdge], targetBorders[BottomEdge]);
1132 
1133  bool wasSmoothPixmapTransform = p->renderHints() & QPainter::SmoothPixmapTransform;
1135  qDrawBorderPixmap(p, rect, targetMargins, borderImageData->pixmap,
1136  QRect(QPoint(), borderImageData->pixmap.size()), sourceMargins,
1137  QTileRules(tileMode2TileRule[borderImageData->horizStretch], tileMode2TileRule[borderImageData->vertStretch]));
1138  p->setRenderHint(QPainter::SmoothPixmapTransform, wasSmoothPixmapTransform);
1139  unsetClip(p);
1140 }
const QStyleSheetBorderImageData * borderImage() const
void setClip(QPainter *p, const QRect &rect)
QSize size() const
Returns the size of the pixmap.
Definition: qpixmap.cpp:661
TileRule
Definition: qnamespace.h:198
void unsetClip(QPainter *)
void setRenderHint(RenderHint hint, bool on=true)
Sets the given render hint on the painter if on is true; otherwise clears the render hint...
Definition: qpainter.cpp:7620
void qDrawBorderPixmap(QPainter *painter, const QRect &targetRect, const QMargins &targetMargins, const QPixmap &pixmap, const QRect &sourceRect, const QMargins &sourceMargins, const QTileRules &rules, QDrawBorderPixmap::DrawingHints hints)
Draws the indicated sourceRect rectangle from the given pixmap into the given targetRect rectangle...
Definition: qdrawutil.cpp:1106
Holds the rules used to draw a pixmap or image split into nine segments, similar to [CSS3 border-imag...
Definition: qdrawutil.h:136
The QPoint class defines a point in the plane using integer precision.
Definition: qpoint.h:53
const QStyleSheetBorderData * border() const
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
RenderHints renderHints() const
Returns a flag that specifies the rendering hints that are set for this painter.
Definition: qpainter.cpp:7675
The QMargins class defines the four margins of a rectangle.
Definition: qmargins.h:53

◆ drawFrame()

void QRenderRule::drawFrame ( QPainter p,
const QRect rect 
)

Definition at line 1321 of file qstylesheetstyle.cpp.

Referenced by drawRule().

1322 {
1323  drawBackground(p, rect);
1324  if (hasBorder())
1325  drawBorder(p, borderRect(rect));
1326 }
QRect borderRect(const QRect &r) const
void drawBorder(QPainter *, const QRect &)
void drawBackground(QPainter *, const QRect &, const QPoint &=QPoint(0, 0))
bool hasBorder() const

◆ drawImage()

void QRenderRule::drawImage ( QPainter p,
const QRect rect 
)

Definition at line 1328 of file qstylesheetstyle.cpp.

Referenced by drawRule().

1329 {
1330  if (!hasImage())
1331  return;
1332  img->icon.paint(p, rect, img->alignment);
1333 }
bool hasImage() const
QSharedDataPointer< QStyleSheetImageData > img
void paint(QPainter *painter, const QRect &rect, Qt::Alignment alignment=Qt::AlignCenter, Mode mode=Normal, State state=Off) const
Uses the painter to paint the icon with specified alignment, required mode, and state into the rectan...
Definition: qicon.cpp:744

◆ drawOutline()

void QRenderRule::drawOutline ( QPainter p,
const QRect rect 
)

Definition at line 1210 of file qstylesheetstyle.cpp.

1211 {
1212  if (!hasOutline())
1213  return;
1214 
1215  bool wasAntialiased = p->renderHints() & QPainter::Antialiasing;
1217  qDrawBorder(p, rect, ou->styles, ou->borders, ou->colors, ou->radii);
1218  p->setRenderHint(QPainter::Antialiasing, wasAntialiased);
1219 }
QSharedDataPointer< QStyleSheetOutlineData > ou
bool hasOutline() const
void setRenderHint(RenderHint hint, bool on=true)
Sets the given render hint on the painter if on is true; otherwise clears the render hint...
Definition: qpainter.cpp:7620
QCss::BorderStyle styles[4]
void qDrawBorder(QPainter *p, const QRect &rect, const QCss::BorderStyle *styles, const int *borders, const QBrush *colors, const QSize *radii)
Definition: qcssutil.cpp:348
RenderHints renderHints() const
Returns a flag that specifies the rendering hints that are set for this painter.
Definition: qpainter.cpp:7675

◆ drawRule()

void QRenderRule::drawRule ( QPainter p,
const QRect rect 
)

Definition at line 1335 of file qstylesheetstyle.cpp.

Referenced by QStyleSheetStyle::drawComplexControl(), QStyleSheetStyle::drawControl(), and QStyleSheetStyle::drawPrimitive().

1336 {
1337  drawFrame(p, rect);
1338  drawImage(p, contentsRect(rect));
1339 }
QRect contentsRect(const QRect &r) const
void drawImage(QPainter *p, const QRect &rect)
void drawFrame(QPainter *, const QRect &)

◆ fixupBorder()

void QRenderRule::fixupBorder ( int  nativeWidth)

Definition at line 1076 of file qstylesheetstyle.cpp.

Referenced by QRenderRule().

1077 {
1078  if (bd == 0)
1079  return;
1080 
1081  if (!bd->hasBorderImage() || bd->bi->pixmap.isNull()) {
1082  bd->bi = 0;
1083  // ignore the color, border of edges that have none border-style
1084  QBrush color = pal ? pal->foreground : QBrush();
1085  const bool hasRadius = bd->radii[0].isValid() || bd->radii[1].isValid()
1086  || bd->radii[2].isValid() || bd->radii[3].isValid();
1087  for (int i = 0; i < 4; i++) {
1088  if ((bd->styles[i] == BorderStyle_Native) && hasRadius)
1089  bd->styles[i] = BorderStyle_None;
1090 
1091  switch (bd->styles[i]) {
1092  case BorderStyle_None:
1093  // border-style: none forces width to be 0
1094  bd->colors[i] = QBrush();
1095  bd->borders[i] = 0;
1096  break;
1097  case BorderStyle_Native:
1098  if (bd->borders[i] == 0)
1099  bd->borders[i] = nativeWidth;
1100  // intentional fall through
1101  default:
1102  if (!bd->colors[i].style() != Qt::NoBrush) // auto-acquire 'color'
1103  bd->colors[i] = color;
1104  break;
1105  }
1106  }
1107 
1108  return;
1109  }
1110 
1111  // inspect the border image
1113  if (bi->cuts[0] == -1) {
1114  for (int i = 0; i < 4; i++) // assume, cut = border
1115  bi->cuts[i] = int(border()->borders[i]);
1116  }
1117 }
QSharedDataPointer< QStyleSheetBorderData > bd
QCss::BorderStyle styles[4]
Qt::BrushStyle style() const
Returns the brush style.
Definition: qbrush.h:182
QSharedDataPointer< QStyleSheetBorderImageData > bi
The QBrush class defines the fill pattern of shapes drawn by QPainter.
Definition: qbrush.h:76
const QStyleSheetBorderData * border() const
bool isValid() const
Returns true if both the width and height is equal to or greater than 0; otherwise returns false...
Definition: qsize.h:123
bool isNull() const
Returns true if this is a null pixmap; otherwise returns false.
Definition: qpixmap.cpp:615
QSharedDataPointer< QStyleSheetPaletteData > pal

◆ geometry()

const QStyleSheetGeometryData* QRenderRule::geometry ( ) const
inline

Definition at line 502 of file qstylesheetstyle.cpp.

Referenced by QStyleSheetStyle::setGeometry().

502 { return geo; }
QSharedDataPointer< QStyleSheetGeometryData > geo

◆ hasBackground()

bool QRenderRule::hasBackground ( ) const
inline

Definition at line 506 of file qstylesheetstyle.cpp.

Referenced by configurePalette(), drawBackground(), drawBackgroundImage(), QStyleSheetStyle::drawComplexControl(), QStyleSheetStyle::drawControl(), QStyleSheetStyle::drawPrimitive(), and QStyleSheetStyle::polish().

506 { return bg != 0 && (!bg->pixmap.isNull() || bg->brush.style() != Qt::NoBrush); }
QSharedDataPointer< QStyleSheetBackgroundData > bg
Qt::BrushStyle style() const
Returns the brush style.
Definition: qbrush.h:182
bool isNull() const
Returns true if this is a null pixmap; otherwise returns false.
Definition: qpixmap.cpp:615

◆ hasBorder()

bool QRenderRule::hasBorder ( ) const
inline

◆ hasBox()

bool QRenderRule::hasBox ( ) const
inline

◆ hasContentsSize()

bool QRenderRule::hasContentsSize ( ) const
inline

Definition at line 553 of file qstylesheetstyle.cpp.

Referenced by QStyleSheetStyle::drawControl(), QStyleSheetStyle::pixelMetric(), QStyleSheetStyle::positionRect(), QStyleSheetStyle::sizeFromContents(), QStyleSheetStyle::subControlRect(), and QStyleSheetStyle::subElementRect().

554  { return (geo && (geo->width != -1 || geo->height != -1)) || (img && img->size.isValid()); }
QSharedDataPointer< QStyleSheetGeometryData > geo
QSharedDataPointer< QStyleSheetImageData > img
bool isValid() const
Returns true if both the width and height is equal to or greater than 0; otherwise returns false...
Definition: qsize.h:123

◆ hasDrawable()

bool QRenderRule::hasDrawable ( ) const
inline

◆ hasGeometry()

bool QRenderRule::hasGeometry ( ) const
inline

◆ hasGradientBackground()

bool QRenderRule::hasGradientBackground ( ) const
inline

Definition at line 507 of file qstylesheetstyle.cpp.

507  { return bg && bg->brush.style() >= Qt::LinearGradientPattern
QSharedDataPointer< QStyleSheetBackgroundData > bg
Qt::BrushStyle style() const
Returns the brush style.
Definition: qbrush.h:182

◆ hasImage()

bool QRenderRule::hasImage ( ) const
inline

Definition at line 536 of file qstylesheetstyle.cpp.

Referenced by drawImage().

536 { return img != 0; }
QSharedDataPointer< QStyleSheetImageData > img

◆ hasNativeBorder()

bool QRenderRule::hasNativeBorder ( ) const
inline

◆ hasNativeOutline()

bool QRenderRule::hasNativeOutline ( ) const
inline

Definition at line 515 of file qstylesheetstyle.cpp.

515  {
516  return (ou == 0
517  || (!ou->hasBorderImage() && ou->styles[0] == BorderStyle_Native));
518  }
QSharedDataPointer< QStyleSheetOutlineData > ou
QCss::BorderStyle styles[4]

◆ hasOutline()

bool QRenderRule::hasOutline ( ) const
inline

Definition at line 532 of file qstylesheetstyle.cpp.

Referenced by drawOutline(), and outlineRect().

532 { return ou != 0; }
QSharedDataPointer< QStyleSheetOutlineData > ou

◆ hasPalette()

bool QRenderRule::hasPalette ( ) const
inline

◆ hasPosition()

bool QRenderRule::hasPosition ( ) const
inline

◆ hasStyleHint()

bool QRenderRule::hasStyleHint ( const QString sh) const
inline

Definition at line 577 of file qstylesheetstyle.cpp.

Referenced by QStyleSheetStyle::pixelMetric(), QStyleSheetStyle::standardIconImplementation(), QStyleSheetStyle::standardPixmap(), and QStyleSheetStyle::styleHint().

577 { return styleHints.contains(sh); }
bool contains(const Key &key) const
Returns true if the hash contains an item with the key; otherwise returns false.
Definition: qhash.h:872
QHash< QString, QVariant > styleHints

◆ minimumContentsSize()

QSize QRenderRule::minimumContentsSize ( ) const
inline

Definition at line 538 of file qstylesheetstyle.cpp.

Referenced by QStyleSheetStyle::pixelMetric(), and QStyleSheetStyle::positionRect().

539  { return geo ? QSize(geo->minWidth, geo->minHeight) : QSize(0, 0); }
QSharedDataPointer< QStyleSheetGeometryData > geo
The QSize class defines the size of a two-dimensional object using integer point precision.
Definition: qsize.h:53

◆ minimumSize()

QSize QRenderRule::minimumSize ( ) const
inline

Definition at line 540 of file qstylesheetstyle.cpp.

Referenced by QStyleSheetStyle::pixelMetric().

541  { return boxSize(minimumContentsSize()); }
QSize minimumContentsSize() const
QSize boxSize(const QSize &s, int flags=All) const

◆ originRect()

QRect QRenderRule::originRect ( const QRect rect,
Origin  origin 
) const

Definition at line 1142 of file qstylesheetstyle.cpp.

Referenced by drawBackground(), drawBackgroundImage(), QStyleSheetStyle::positionRect(), and QStyleSheetStyle::subControlRect().

1143 {
1144  switch (origin) {
1145  case Origin_Padding:
1146  return paddingRect(rect);
1147  case Origin_Border:
1148  return borderRect(rect);
1149  case Origin_Content:
1150  return contentsRect(rect);
1151  case Origin_Margin:
1152  default:
1153  return rect;
1154  }
1155 }
QRect borderRect(const QRect &r) const
QRect contentsRect(const QRect &r) const
QRect paddingRect(const QRect &r) const

◆ outline()

const QStyleSheetOutlineData* QRenderRule::outline ( ) const
inline

Definition at line 501 of file qstylesheetstyle.cpp.

Referenced by outlineRect().

501 { return ou; }
QSharedDataPointer< QStyleSheetOutlineData > ou

◆ outlineRect()

QRect QRenderRule::outlineRect ( const QRect r) const

Definition at line 1021 of file qstylesheetstyle.cpp.

1022 {
1023  QRect br = borderRect(r);
1024  if (!hasOutline())
1025  return br;
1026  const int *b = outline()->borders;
1027  return r.adjusted(b[LeftEdge], b[TopEdge], -b[RightEdge], -b[BottomEdge]);
1028 }
QRect borderRect(const QRect &r) const
QRect adjusted(int x1, int y1, int x2, int y2) const
Returns a new rectangle with dx1, dy1, dx2 and dy2 added respectively to the existing coordinates of ...
Definition: qrect.h:431
bool hasOutline() const
QSharedDataPointer< QStyleSheetBoxData > b
const QStyleSheetOutlineData * outline() const
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58

◆ paddingRect()

QRect QRenderRule::paddingRect ( const QRect r) const

Definition at line 1030 of file qstylesheetstyle.cpp.

Referenced by contentsRect(), and originRect().

1031 {
1032  QRect br = borderRect(r);
1033  if (!hasBorder())
1034  return br;
1035  const int *b = border()->borders;
1036  return br.adjusted(b[LeftEdge], b[TopEdge], -b[RightEdge], -b[BottomEdge]);
1037 }
QRect borderRect(const QRect &r) const
QRect adjusted(int x1, int y1, int x2, int y2) const
Returns a new rectangle with dx1, dy1, dx2 and dy2 added respectively to the existing coordinates of ...
Definition: qrect.h:431
QSharedDataPointer< QStyleSheetBoxData > b
bool hasBorder() const
const QStyleSheetBorderData * border() const
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58

◆ palette()

const QStyleSheetPaletteData* QRenderRule::palette ( ) const
inline

Definition at line 497 of file qstylesheetstyle.cpp.

Referenced by QStyleSheetStyle::drawComplexControl(), QRenderRule(), and QStyleSheetStyle::styleHint().

497 { return pal; }
QSharedDataPointer< QStyleSheetPaletteData > pal

◆ position()

const QStyleSheetPositionData* QRenderRule::position ( ) const
inline

◆ setClip()

void QRenderRule::setClip ( QPainter p,
const QRect rect 
)
Warning
This function is not part of the public interface. Clip the painter to the border (in case we are using radius border)

Definition at line 1278 of file qstylesheetstyle.cpp.

Referenced by drawBackgroundImage(), and drawBorderImage().

1279 {
1280  if (clipset++)
1281  return;
1282  clipPath = borderClip(rect);
1283  if (!clipPath.isEmpty()) {
1284  p->save();
1286  }
1287 }
bool isEmpty() const
Returns true if either there are no elements in this path, or if the only element is a MoveToElement;...
Definition: qpainterpath.h:392
QPainterPath borderClip(QRect rect)
void save()
Saves the current painter state (pushes the state onto a stack).
Definition: qpainter.cpp:1590
QPainterPath clipPath
void setClipPath(const QPainterPath &path, Qt::ClipOperation op=Qt::ReplaceClip)
Enables clipping, and sets the clip path for the painter to the given path, with the clip operation...
Definition: qpainter.cpp:3365

◆ size() [1/2]

QSize QRenderRule::size ( ) const
inline

◆ size() [2/2]

QSize QRenderRule::size ( const QSize sz) const
inline

Definition at line 557 of file qstylesheetstyle.cpp.

557 { return boxSize(contentsSize(sz)); }
QSize contentsSize() const
QSize boxSize(const QSize &s, int flags=All) const

◆ styleHint()

QVariant QRenderRule::styleHint ( const QString sh) const
inline

◆ unsetClip()

void QRenderRule::unsetClip ( QPainter p)

Definition at line 1289 of file qstylesheetstyle.cpp.

Referenced by drawBackgroundImage(), and drawBorderImage().

1290 {
1291  if (--clipset)
1292  return;
1293  if (!clipPath.isEmpty())
1294  p->restore();
1295 }
bool isEmpty() const
Returns true if either there are no elements in this path, or if the only element is a MoveToElement;...
Definition: qpainterpath.h:392
void restore()
Restores the current painter state (pops a saved state off the stack).
Definition: qpainter.cpp:1620
QPainterPath clipPath

Properties

◆ b

Definition at line 583 of file qstylesheetstyle.cpp.

Referenced by boxRect(), outlineRect(), paddingRect(), and QRenderRule().

◆ bd

Definition at line 585 of file qstylesheetstyle.cpp.

Referenced by borderClip(), drawBorder(), fixupBorder(), and QRenderRule().

◆ bg

◆ clipPath

QPainterPath QRenderRule::clipPath

Definition at line 595 of file qstylesheetstyle.cpp.

Referenced by setClip(), and unsetClip().

◆ clipset

int QRenderRule::clipset

Definition at line 594 of file qstylesheetstyle.cpp.

Referenced by setClip(), and unsetClip().

◆ defaultBackground

QBrush QRenderRule::defaultBackground

Definition at line 572 of file qstylesheetstyle.cpp.

Referenced by drawBackground(), and QRenderRule().

◆ features

int QRenderRule::features

Definition at line 571 of file qstylesheetstyle.cpp.

Referenced by QRenderRule().

◆ font

QFont QRenderRule::font

◆ geo

◆ hasFont

bool QRenderRule::hasFont

Definition at line 574 of file qstylesheetstyle.cpp.

Referenced by QStyleSheetStyle::drawControl(), and QRenderRule().

◆ img

Definition at line 589 of file qstylesheetstyle.cpp.

Referenced by drawImage(), QRenderRule(), and QStyleSheetStyle::subControlRect().

◆ ou

Definition at line 586 of file qstylesheetstyle.cpp.

Referenced by drawOutline(), and QRenderRule().

◆ p

◆ pal

Definition at line 582 of file qstylesheetstyle.cpp.

Referenced by configurePalette(), fixupBorder(), and QRenderRule().

◆ styleHints

QHash<QString, QVariant> QRenderRule::styleHints

Definition at line 576 of file qstylesheetstyle.cpp.

Referenced by QRenderRule().


The documentation for this class was generated from the following file: