9#include <private/qpaintengineex_p.h>
12#include <private/qhexstring_p.h>
23 for ( ; m_level > 0; --m_level)
88 int lineWidth,
int midLineWidth)
90 if (
Q_UNLIKELY(!
p || lineWidth < 0 || midLineWidth < 0)) {
91 qWarning(
"qDrawShadeLine: Invalid parameters");
94 PainterStateGuard painterGuard(
p);
95 const qreal devicePixelRatio =
p->device()->devicePixelRatio();
98 const qreal inverseScale =
qreal(1) / devicePixelRatio;
99 p->scale(inverseScale, inverseScale);
104 lineWidth =
qRound(devicePixelRatio * lineWidth);
105 midLineWidth =
qRound(devicePixelRatio * midLineWidth);
106 p->translate(0.5, 0.5);
108 int tlw = lineWidth*2 + midLineWidth;
109 QPen oldPen =
p->pen();
124 for (
i=0;
i<lineWidth;
i++) {
130 if (midLineWidth > 0) {
132 for (
i=0;
i<midLineWidth;
i++)
133 p->drawLine(
x1+lineWidth,
y+lineWidth+
i,
134 x2-lineWidth,
y+lineWidth+
i);
140 for (
i=0;
i<lineWidth;
i++) {
141 a.setPoints(3,
x1+
i,
y+tlw-
i-1,
155 for (
i=0;
i<lineWidth;
i++) {
156 a.setPoints(3,
x+
i,
y2,
161 if (midLineWidth > 0) {
163 for (
i=0;
i<midLineWidth;
i++)
164 p->drawLine(
x+lineWidth+
i,
y1+lineWidth,
x+lineWidth+
i,
y2);
170 for (
i=0;
i<lineWidth;
i++) {
171 a.setPoints(3,
x+lineWidth,
y2-
i,
173 x+tlw-
i-1,
y1+lineWidth);
215 int lineWidth,
int midLineWidth,
218 if (
w == 0 ||
h == 0)
220 if (
Q_UNLIKELY(
w < 0 ||
h < 0 || lineWidth < 0 || midLineWidth < 0)) {
221 qWarning(
"qDrawShadeRect: Invalid parameters");
225 PainterStateGuard painterGuard(
p);
226 const qreal devicePixelRatio =
p->device()->devicePixelRatio();
229 const qreal inverseScale =
qreal(1) / devicePixelRatio;
230 p->scale(inverseScale, inverseScale);
233 w = devicePixelRatio *
w;
234 h = devicePixelRatio *
h;
235 lineWidth =
qRound(devicePixelRatio * lineWidth);
236 midLineWidth =
qRound(devicePixelRatio * midLineWidth);
237 p->translate(0.5, 0.5);
240 QPen oldPen =
p->pen();
247 if (lineWidth == 1 && midLineWidth == 0) {
257 p->drawLines(lines, 4);
259 int m = lineWidth+midLineWidth;
261 for (
i=0;
i<lineWidth;
i++) {
266 p->drawLines(lines, 4);
271 for (
i=0;
i<midLineWidth;
i++) {
272 p->drawRect(
x1+lineWidth+
i,
y1+lineWidth+
i,
w-
j-1,
h-
j-1);
280 for (
i=0;
i<lineWidth;
i++) {
285 p->drawLines(lines, 4);
291 int tlw = lineWidth + midLineWidth;
294 p->drawRect(
x+tlw,
y+tlw,
w-2*tlw,
h-2*tlw);
295 p->setBrush(oldBrush);
333 if (
w == 0 ||
h == 0)
336 qWarning(
"qDrawShadePanel: Invalid parameters");
339 PainterStateGuard painterGuard(
p);
340 const qreal devicePixelRatio =
p->device()->devicePixelRatio();
341 bool isTranslated =
false;
344 const qreal inverseScale =
qreal(1) / devicePixelRatio;
345 p->scale(inverseScale, inverseScale);
348 w = devicePixelRatio *
w;
349 h = devicePixelRatio *
h;
350 lineWidth =
qRound(devicePixelRatio * lineWidth);
351 p->translate(0.5, 0.5);
358 if (
fill->color() == shade)
360 if (
fill->color() == light)
363 QPen oldPen =
p->pen();
365 lines.reserve(2*lineWidth);
376 for (
i=0;
i<lineWidth;
i++) {
381 for (
i=0;
i<lineWidth;
i++) {
393 for (
i=0;
i<lineWidth;
i++) {
398 y2 =
y+
h-lineWidth-1;
399 for (
i=0;
i<lineWidth;
i++) {
405 p->translate(-0.5, -0.5);
406 p->fillRect(
x+lineWidth,
y+lineWidth,
w-lineWidth*2,
h-lineWidth*2, *
fill);
427 int x,
int y,
int w,
int h,
435 PainterStateGuard painterGuard(
p);
436 const qreal devicePixelRatio =
p->device()->devicePixelRatio();
437 bool isTranslated =
false;
440 const qreal inverseScale =
qreal(1) / devicePixelRatio;
441 p->scale(inverseScale, inverseScale);
444 w = devicePixelRatio *
w;
445 h = devicePixelRatio *
h;
446 p->translate(0.5, 0.5);
450 QPen oldPen =
p->pen();
453 p->drawPolyline(
a, 3);
456 p->drawPolyline(
b, 3);
457 if (
w > 4 &&
h > 4) {
460 p->drawPolyline(
c, 3);
463 p->drawPolyline(
d, 3);
466 p->translate(-0.5, -0.5);
577 if (
w == 0 ||
h == 0)
580 qWarning(
"qDrawPlainRect: Invalid parameters");
583 PainterStateGuard painterGuard(
p);
584 const qreal devicePixelRatio =
p->device()->devicePixelRatio();
587 const qreal inverseScale =
qreal(1) / devicePixelRatio;
588 p->scale(inverseScale, inverseScale);
591 w = devicePixelRatio *
w;
592 h = devicePixelRatio *
h;
593 lineWidth =
qRound(devicePixelRatio * lineWidth);
594 p->translate(0.5, 0.5);
597 QPen oldPen =
p->pen();
601 for (
int i=0;
i<lineWidth;
i++)
602 p->drawRect(
x+
i,
y+
i,
w-
i*2 - 1,
h-
i*2 - 1);
606 p->drawRect(
x+lineWidth,
y+lineWidth,
w-lineWidth*2,
h-lineWidth*2);
609 p->setBrush(oldBrush);
644 if (
w == 0 ||
h == 0)
647 qWarning(
"qDrawPlainRect: Invalid parameters");
650 PainterStateGuard painterGuard(
p);
651 const qreal devicePixelRatio =
p->device()->devicePixelRatio();
654 const qreal inverseScale =
qreal(1) / devicePixelRatio;
655 p->scale(inverseScale, inverseScale);
658 w = devicePixelRatio *
w;
659 h = devicePixelRatio *
h;
660 lineWidth =
qRound(devicePixelRatio * lineWidth);
661 p->translate(0.5, 0.5);
667 for (
int i=0;
i<lineWidth;
i++) {
675 p->drawRoundedRect(
x+lineWidth,
y+lineWidth,
w-lineWidth*2,
h-lineWidth*2,
rx,
ry);
718 int lineWidth,
int midLineWidth)
721 lineWidth, midLineWidth);
757 int lineWidth,
int midLineWidth,
761 lineWidth, midLineWidth,
fill);
974 , QDrawBorderPixmap::DrawingHints hints
986 const int sourceCenterTop = sourceRect.
top() + sourceMargins.top();
987 const int sourceCenterLeft = sourceRect.
left() + sourceMargins.left();
988 const int sourceCenterBottom = sourceRect.
bottom() - sourceMargins.bottom() + 1;
989 const int sourceCenterRight = sourceRect.
right() - sourceMargins.right() + 1;
990 const int sourceCenterWidth = sourceCenterRight - sourceCenterLeft;
991 const int sourceCenterHeight = sourceCenterBottom - sourceCenterTop;
993 const int targetCenterTop = targetRect.top() + targetMargins.top();
994 const int targetCenterLeft = targetRect.left() + targetMargins.left();
995 const int targetCenterBottom = targetRect.bottom() - targetMargins.bottom() + 1;
996 const int targetCenterRight = targetRect.right() - targetMargins.right() + 1;
997 const int targetCenterWidth = targetCenterRight - targetCenterLeft;
998 const int targetCenterHeight = targetCenterBottom - targetCenterTop;
1000 QVarLengthArray<qreal, 16> xTarget;
1001 QVarLengthArray<qreal, 16> yTarget;
1006 columns =
qMax(3, 2 +
qCeil(targetCenterWidth /
qreal(sourceCenterWidth)));
1008 rows =
qMax(3, 2 +
qCeil(targetCenterHeight /
qreal(sourceCenterHeight)));
1010 xTarget.resize(columns + 1);
1011 yTarget.resize(rows + 1);
1020 xTarget[0] = targetRect.left();
1021 xTarget[1] = targetCenterLeft;
1022 xTarget[columns - 1] = targetCenterRight;
1023 xTarget[columns] = targetRect.left() + targetRect.width();
1025 yTarget[0] = targetRect.top();
1026 yTarget[1] = targetCenterTop;
1027 yTarget[rows - 1] = targetCenterBottom;
1028 yTarget[rows] = targetRect.top() + targetRect.height();
1030 qreal dx = targetCenterWidth;
1031 qreal dy = targetCenterHeight;
1033 switch (rules.horizontal) {
1035 dx = targetCenterWidth;
1038 dx = sourceCenterWidth;
1041 dx = targetCenterWidth /
qreal(columns - 2);
1045 for (
int i = 2;
i < columns - 1; ++
i)
1046 xTarget[
i] = xTarget[
i - 1] + dx;
1048 switch (rules.vertical) {
1050 dy = targetCenterHeight;
1053 dy = sourceCenterHeight;
1056 dy = targetCenterHeight /
qreal(rows - 2);
1060 for (
int i = 2;
i < rows - 1; ++
i)
1061 yTarget[
i] = yTarget[
i - 1] + dy;
1064 if (targetMargins.top() > 0 && targetMargins.left() > 0 && sourceMargins.top() > 0 && sourceMargins.left() > 0) {
1065 d.x = (0.5 * (xTarget[1] + xTarget[0]));
1066 d.y = (0.5 * (yTarget[1] + yTarget[0]));
1067 d.sourceLeft = sourceRect.
left();
1068 d.sourceTop = sourceRect.
top();
1069 d.width = sourceMargins.left();
1070 d.height = sourceMargins.top();
1071 d.scaleX =
qreal(xTarget[1] - xTarget[0]) /
d.width;
1072 d.scaleY =
qreal(yTarget[1] - yTarget[0]) /
d.height;
1074 opaqueData.append(
d);
1076 translucentData.append(
d);
1078 if (targetMargins.top() > 0 && targetMargins.right() > 0 && sourceMargins.top() > 0 && sourceMargins.right() > 0) {
1079 d.x = (0.5 * (xTarget[columns] + xTarget[columns - 1]));
1080 d.y = (0.5 * (yTarget[1] + yTarget[0]));
1081 d.sourceLeft = sourceCenterRight;
1082 d.sourceTop = sourceRect.
top();
1083 d.width = sourceMargins.right();
1084 d.height = sourceMargins.top();
1085 d.scaleX =
qreal(xTarget[columns] - xTarget[columns - 1]) /
d.width;
1086 d.scaleY =
qreal(yTarget[1] - yTarget[0]) /
d.height;
1088 opaqueData.append(
d);
1090 translucentData.append(
d);
1092 if (targetMargins.bottom() > 0 && targetMargins.left() > 0 && sourceMargins.bottom() > 0 && sourceMargins.left() > 0) {
1093 d.x = (0.5 * (xTarget[1] + xTarget[0]));
1094 d.y =(0.5 * (yTarget[rows] + yTarget[rows - 1]));
1095 d.sourceLeft = sourceRect.
left();
1096 d.sourceTop = sourceCenterBottom;
1097 d.width = sourceMargins.left();
1098 d.height = sourceMargins.bottom();
1099 d.scaleX =
qreal(xTarget[1] - xTarget[0]) /
d.width;
1100 d.scaleY =
qreal(yTarget[rows] - yTarget[rows - 1]) /
d.height;
1102 opaqueData.append(
d);
1104 translucentData.append(
d);
1106 if (targetMargins.bottom() > 0 && targetMargins.right() > 0 && sourceMargins.bottom() > 0 && sourceMargins.right() > 0) {
1107 d.x = (0.5 * (xTarget[columns] + xTarget[columns - 1]));
1108 d.y = (0.5 * (yTarget[rows] + yTarget[rows - 1]));
1109 d.sourceLeft = sourceCenterRight;
1110 d.sourceTop = sourceCenterBottom;
1111 d.width = sourceMargins.right();
1112 d.height = sourceMargins.bottom();
1113 d.scaleX =
qreal(xTarget[columns] - xTarget[columns - 1]) /
d.width;
1114 d.scaleY =
qreal(yTarget[rows] - yTarget[rows - 1]) /
d.height;
1116 opaqueData.append(
d);
1118 translucentData.append(
d);
1122 if (targetCenterWidth > 0 && sourceCenterWidth > 0) {
1123 if (targetMargins.top() > 0 && sourceMargins.top() > 0) {
1125 d.sourceLeft = sourceCenterLeft;
1126 d.sourceTop = sourceRect.
top();
1127 d.width = sourceCenterWidth;
1128 d.height = sourceMargins.top();
1129 d.y = (0.5 * (yTarget[1] + yTarget[0]));
1130 d.scaleX = dx /
d.width;
1131 d.scaleY =
qreal(yTarget[1] - yTarget[0]) /
d.height;
1132 for (
int i = 1;
i < columns - 1; ++
i) {
1133 d.x = (0.5 * (xTarget[
i + 1] + xTarget[
i]));
1137 data[
data.size() - 1].width = ((xTarget[columns - 1] - xTarget[columns - 2]) /
d.scaleX);
1139 if (targetMargins.bottom() > 0 && sourceMargins.bottom() > 0) {
1141 d.sourceLeft = sourceCenterLeft;
1142 d.sourceTop = sourceCenterBottom;
1143 d.width = sourceCenterWidth;
1144 d.height = sourceMargins.bottom();
1145 d.y = (0.5 * (yTarget[rows] + yTarget[rows - 1]));
1146 d.scaleX = dx /
d.width;
1147 d.scaleY =
qreal(yTarget[rows] - yTarget[rows - 1]) /
d.height;
1148 for (
int i = 1;
i < columns - 1; ++
i) {
1149 d.x = (0.5 * (xTarget[
i + 1] + xTarget[
i]));
1153 data[
data.size() - 1].width = ((xTarget[columns - 1] - xTarget[columns - 2]) /
d.scaleX);
1158 if (targetCenterHeight > 0 && sourceCenterHeight > 0) {
1159 if (targetMargins.left() > 0 && sourceMargins.left() > 0) {
1161 d.sourceLeft = sourceRect.
left();
1162 d.sourceTop = sourceCenterTop;
1163 d.width = sourceMargins.left();
1164 d.height = sourceCenterHeight;
1165 d.x = (0.5 * (xTarget[1] + xTarget[0]));
1166 d.scaleX =
qreal(xTarget[1] - xTarget[0]) /
d.width;
1167 d.scaleY = dy /
d.height;
1168 for (
int i = 1;
i < rows - 1; ++
i) {
1169 d.y = (0.5 * (yTarget[
i + 1] + yTarget[
i]));
1173 data[
data.size() - 1].height = ((yTarget[rows - 1] - yTarget[rows - 2]) /
d.scaleY);
1175 if (targetMargins.right() > 0 && sourceMargins.right() > 0) {
1177 d.sourceLeft = sourceCenterRight;
1178 d.sourceTop = sourceCenterTop;
1179 d.width = sourceMargins.right();
1180 d.height = sourceCenterHeight;
1181 d.x = (0.5 * (xTarget[columns] + xTarget[columns - 1]));
1182 d.scaleX =
qreal(xTarget[columns] - xTarget[columns - 1]) /
d.width;
1183 d.scaleY = dy /
d.height;
1184 for (
int i = 1;
i < rows - 1; ++
i) {
1185 d.y = (0.5 * (yTarget[
i + 1] + yTarget[
i]));
1189 data[
data.size() - 1].height = ((yTarget[rows - 1] - yTarget[rows - 2]) /
d.scaleY);
1194 if (targetCenterWidth > 0 && targetCenterHeight > 0 && sourceCenterWidth > 0 && sourceCenterHeight > 0) {
1196 d.sourceLeft = sourceCenterLeft;
1197 d.sourceTop = sourceCenterTop;
1198 d.width = sourceCenterWidth;
1199 d.height = sourceCenterHeight;
1200 d.scaleX = dx /
d.width;
1201 d.scaleY = dy /
d.height;
1203 qreal repeatWidth = (xTarget[columns - 1] - xTarget[columns - 2]) /
d.scaleX;
1204 qreal repeatHeight = (yTarget[rows - 1] - yTarget[rows - 2]) /
d.scaleY;
1206 for (
int j = 1;
j < rows - 1; ++
j) {
1207 d.y = (0.5 * (yTarget[
j + 1] + yTarget[
j]));
1208 for (
int i = 1;
i < columns - 1; ++
i) {
1209 d.x = (0.5 * (xTarget[
i + 1] + xTarget[
i]));
1213 data[
data.size() - 1].width = repeatWidth;
1216 for (
int i = 1;
i < columns - 1; ++
i)
1217 data[
data.size() -
i].height = repeatHeight;
1221 if (opaqueData.size())
1223 if (translucentData.size())
const QColor & color() const
Returns the brush color.
The QColor class provides colors based on RGB, HSV or CMYK values.
\inmodule QtCore\compares equality \compareswith equality QLine \endcompareswith
virtual Type type() const =0
Reimplement this function to return the paint engine \l{Type}.
This class is used in conjunction with the QPainter::drawPixmapFragments() function to specify how a ...
The QPainter class performs low-level painting on widgets and other paint devices.
void drawPixmapFragments(const PixmapFragment *fragments, int fragmentCount, const QPixmap &pixmap, PixmapFragmentHints hints=PixmapFragmentHints())
QPaintEngine * paintEngine() const
Returns the paint engine that the painter is currently operating on if the painter is active; otherwi...
QTransform combinedTransform() const
Returns the transformation matrix combining the current window/viewport and world transformation.
void setRenderHint(RenderHint hint, bool on=true)
Sets the given render hint on the painter if on is true; otherwise clears the render hint.
bool testRenderHint(RenderHint hint) const
The QPalette class contains color groups for each widget state.
const QBrush & button() const
Returns the button brush of the current color group.
const QBrush & dark() const
Returns the dark brush of the current color group.
const QBrush & shadow() const
Returns the shadow brush of the current color group.
const QBrush & light() const
Returns the light brush of the current color group.
const QColor & color(ColorGroup cg, ColorRole cr) const
Returns the color in the specified color group, used for the given color role.
const QBrush & mid() const
Returns the mid brush of the current color group.
const QBrush & midlight() const
Returns the midlight brush of the current color group.
Returns a copy of the pixmap that is transformed using the given transformation transform and transfo...
\inmodule QtCore\reentrant
The QPolygon class provides a list of points using integer precision.
Q_GUI_EXPORT void setPoints(int nPoints, const int *points)
Resizes the polygon to nPoints and populates it with the given points.
\inmodule QtCore\reentrant
\inmodule QtCore\reentrant
constexpr int bottom() const noexcept
Returns the y-coordinate of the rectangle's bottom edge.
constexpr int top() const noexcept
Returns the y-coordinate of the rectangle's top edge.
constexpr int left() const noexcept
Returns the x-coordinate of the rectangle's left edge.
constexpr int right() const noexcept
Returns the x-coordinate of the rectangle's right edge.
PainterStateGuard(QPainter *p)
Combined button and popup list for selecting options.
static void qDrawWinShades(QPainter *p, int x, int y, int w, int h, const QColor &c1, const QColor &c2, const QColor &c3, const QColor &c4, const QBrush *fill)
void qDrawShadePanel(QPainter *p, int x, int y, int w, int h, const QPalette &pal, bool sunken, int lineWidth, const QBrush *fill)
void qDrawShadeLine(QPainter *p, int x1, int y1, int x2, int y2, const QPalette &pal, bool sunken, int lineWidth, int midLineWidth)
void qDrawWinPanel(QPainter *p, int x, int y, int w, int h, const QPalette &pal, bool sunken, const QBrush *fill)
void qDrawWinButton(QPainter *p, int x, int y, int w, int h, const QPalette &pal, bool sunken, const QBrush *fill)
QVarLengthArray< QPainter::PixmapFragment, 16 > QPixmapFragmentsArray
void qDrawPlainRoundedRect(QPainter *p, int x, int y, int w, int h, qreal rx, qreal ry, const QColor &c, int lineWidth, const QBrush *fill)
void qDrawShadeRect(QPainter *p, int x, int y, int w, int h, const QPalette &pal, bool sunken, int lineWidth, int midLineWidth, const QBrush *fill)
void qDrawPlainRect(QPainter *p, int x, int y, int w, int h, const QColor &c, int lineWidth, const QBrush *fill)
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())
bool qFuzzyCompare(qfloat16 p1, qfloat16 p2) noexcept
int qRound(qfloat16 d) noexcept
constexpr const T & qMax(const T &a, const T &b)
GLboolean GLboolean GLboolean b
GLint GLint GLint GLint GLint x
[0]
GLfloat GLfloat GLfloat w
[0]
GLboolean GLboolean GLboolean GLboolean a
[7]
GLuint GLfloat GLfloat GLfloat GLfloat y1
GLuint GLfloat GLfloat GLfloat x1
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
GLfloat GLfloat GLfloat GLfloat h
GLfixed GLfixed GLfixed y2
The QTileRules class provides the rules used to draw a pixmap or image split into nine segments.