| Absolute File Name: | /home/qt/qt5_coco/qt5/qtbase/src/gui/painting/qcssutil.cpp |
| Source code | Switch to Preprocessed file |
| Line | Source | Count | ||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | /**************************************************************************** | - | ||||||||||||||||||
| 2 | ** | - | ||||||||||||||||||
| 3 | ** Copyright (C) 2016 The Qt Company Ltd. | - | ||||||||||||||||||
| 4 | ** Contact: https://www.qt.io/licensing/ | - | ||||||||||||||||||
| 5 | ** | - | ||||||||||||||||||
| 6 | ** This file is part of the QtGui module of the Qt Toolkit. | - | ||||||||||||||||||
| 7 | ** | - | ||||||||||||||||||
| 8 | ** $QT_BEGIN_LICENSE:LGPL$ | - | ||||||||||||||||||
| 9 | ** Commercial License Usage | - | ||||||||||||||||||
| 10 | ** Licensees holding valid commercial Qt licenses may use this file in | - | ||||||||||||||||||
| 11 | ** accordance with the commercial license agreement provided with the | - | ||||||||||||||||||
| 12 | ** Software or, alternatively, in accordance with the terms contained in | - | ||||||||||||||||||
| 13 | ** a written agreement between you and The Qt Company. For licensing terms | - | ||||||||||||||||||
| 14 | ** and conditions see https://www.qt.io/terms-conditions. For further | - | ||||||||||||||||||
| 15 | ** information use the contact form at https://www.qt.io/contact-us. | - | ||||||||||||||||||
| 16 | ** | - | ||||||||||||||||||
| 17 | ** GNU Lesser General Public License Usage | - | ||||||||||||||||||
| 18 | ** Alternatively, this file may be used under the terms of the GNU Lesser | - | ||||||||||||||||||
| 19 | ** General Public License version 3 as published by the Free Software | - | ||||||||||||||||||
| 20 | ** Foundation and appearing in the file LICENSE.LGPL3 included in the | - | ||||||||||||||||||
| 21 | ** packaging of this file. Please review the following information to | - | ||||||||||||||||||
| 22 | ** ensure the GNU Lesser General Public License version 3 requirements | - | ||||||||||||||||||
| 23 | ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. | - | ||||||||||||||||||
| 24 | ** | - | ||||||||||||||||||
| 25 | ** GNU General Public License Usage | - | ||||||||||||||||||
| 26 | ** Alternatively, this file may be used under the terms of the GNU | - | ||||||||||||||||||
| 27 | ** General Public License version 2.0 or (at your option) the GNU General | - | ||||||||||||||||||
| 28 | ** Public license version 3 or any later version approved by the KDE Free | - | ||||||||||||||||||
| 29 | ** Qt Foundation. The licenses are as published by the Free Software | - | ||||||||||||||||||
| 30 | ** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 | - | ||||||||||||||||||
| 31 | ** included in the packaging of this file. Please review the following | - | ||||||||||||||||||
| 32 | ** information to ensure the GNU General Public License requirements will | - | ||||||||||||||||||
| 33 | ** be met: https://www.gnu.org/licenses/gpl-2.0.html and | - | ||||||||||||||||||
| 34 | ** https://www.gnu.org/licenses/gpl-3.0.html. | - | ||||||||||||||||||
| 35 | ** | - | ||||||||||||||||||
| 36 | ** $QT_END_LICENSE$ | - | ||||||||||||||||||
| 37 | ** | - | ||||||||||||||||||
| 38 | ****************************************************************************/ | - | ||||||||||||||||||
| 39 | - | |||||||||||||||||||
| 40 | #include "qcssutil_p.h" | - | ||||||||||||||||||
| 41 | #include "private/qcssparser_p.h" | - | ||||||||||||||||||
| 42 | #include "qpainter.h" | - | ||||||||||||||||||
| 43 | #include <qmath.h> | - | ||||||||||||||||||
| 44 | - | |||||||||||||||||||
| 45 | #ifndef QT_NO_CSSPARSER | - | ||||||||||||||||||
| 46 | - | |||||||||||||||||||
| 47 | QT_BEGIN_NAMESPACE | - | ||||||||||||||||||
| 48 | - | |||||||||||||||||||
| 49 | using namespace QCss; | - | ||||||||||||||||||
| 50 | - | |||||||||||||||||||
| 51 | static QPen qPenFromStyle(const QBrush& b, qreal width, BorderStyle s) | - | ||||||||||||||||||
| 52 | { | - | ||||||||||||||||||
| 53 | Qt::PenStyle ps = Qt::NoPen; | - | ||||||||||||||||||
| 54 | - | |||||||||||||||||||
| 55 | switch (s) { | - | ||||||||||||||||||
| 56 | case BorderStyle_Dotted: never executed: case BorderStyle_Dotted: | 0 | ||||||||||||||||||
| 57 | ps = Qt::DotLine; | - | ||||||||||||||||||
| 58 | break; never executed: break; | 0 | ||||||||||||||||||
| 59 | case BorderStyle_Dashed: never executed: case BorderStyle_Dashed: | 0 | ||||||||||||||||||
| 60 | ps = width == 1 ? Qt::DotLine : Qt::DashLine;
| 0 | ||||||||||||||||||
| 61 | break; never executed: break; | 0 | ||||||||||||||||||
| 62 | case BorderStyle_DotDash: never executed: case BorderStyle_DotDash: | 0 | ||||||||||||||||||
| 63 | ps = Qt::DashDotLine; | - | ||||||||||||||||||
| 64 | break; never executed: break; | 0 | ||||||||||||||||||
| 65 | case BorderStyle_DotDotDash: never executed: case BorderStyle_DotDotDash: | 0 | ||||||||||||||||||
| 66 | ps = Qt::DashDotDotLine; | - | ||||||||||||||||||
| 67 | break; never executed: break; | 0 | ||||||||||||||||||
| 68 | case BorderStyle_Inset: never executed: case BorderStyle_Inset: | 0 | ||||||||||||||||||
| 69 | case BorderStyle_Outset: never executed: case BorderStyle_Outset: | 0 | ||||||||||||||||||
| 70 | case BorderStyle_Solid: never executed: case BorderStyle_Solid: | 0 | ||||||||||||||||||
| 71 | ps = Qt::SolidLine; | - | ||||||||||||||||||
| 72 | break; never executed: break; | 0 | ||||||||||||||||||
| 73 | default: never executed: default: | 0 | ||||||||||||||||||
| 74 | break; never executed: break; | 0 | ||||||||||||||||||
| 75 | } | - | ||||||||||||||||||
| 76 | - | |||||||||||||||||||
| 77 | return QPen(b, width, ps, Qt::FlatCap); never executed: return QPen(b, width, ps, Qt::FlatCap); | 0 | ||||||||||||||||||
| 78 | } | - | ||||||||||||||||||
| 79 | - | |||||||||||||||||||
| 80 | void qDrawRoundedCorners(QPainter *p, qreal x1, qreal y1, qreal x2, qreal y2, | - | ||||||||||||||||||
| 81 | const QSizeF& r1, const QSizeF& r2, | - | ||||||||||||||||||
| 82 | Edge edge, BorderStyle s, QBrush c) | - | ||||||||||||||||||
| 83 | { | - | ||||||||||||||||||
| 84 | const qreal pw = (edge == TopEdge || edge == BottomEdge) ? y2-y1 : x2-x1;
| 0 | ||||||||||||||||||
| 85 | if (s == BorderStyle_Double) {
| 0 | ||||||||||||||||||
| 86 | qreal wby3 = pw/3; | - | ||||||||||||||||||
| 87 | switch (edge) { | - | ||||||||||||||||||
| 88 | case TopEdge: never executed: case TopEdge: | 0 | ||||||||||||||||||
| 89 | case BottomEdge: never executed: case BottomEdge: | 0 | ||||||||||||||||||
| 90 | qDrawRoundedCorners(p, x1, y1, x2, y1+wby3, r1, r2, edge, BorderStyle_Solid, c); | - | ||||||||||||||||||
| 91 | qDrawRoundedCorners(p, x1, y2-wby3, x2, y2, r1, r2, edge, BorderStyle_Solid, c); | - | ||||||||||||||||||
| 92 | break; never executed: break; | 0 | ||||||||||||||||||
| 93 | case LeftEdge: never executed: case LeftEdge: | 0 | ||||||||||||||||||
| 94 | qDrawRoundedCorners(p, x1, y1+1, x1+wby3, y2, r1, r2, LeftEdge, BorderStyle_Solid, c); | - | ||||||||||||||||||
| 95 | qDrawRoundedCorners(p, x2-wby3, y1+1, x2, y2, r1, r2, LeftEdge, BorderStyle_Solid, c); | - | ||||||||||||||||||
| 96 | break; never executed: break; | 0 | ||||||||||||||||||
| 97 | case RightEdge: never executed: case RightEdge: | 0 | ||||||||||||||||||
| 98 | qDrawRoundedCorners(p, x1, y1+1, x1+wby3, y2, r1, r2, RightEdge, BorderStyle_Solid, c); | - | ||||||||||||||||||
| 99 | qDrawRoundedCorners(p, x2-wby3, y1+1, x2, y2, r1, r2, RightEdge, BorderStyle_Solid, c); | - | ||||||||||||||||||
| 100 | break; never executed: break; | 0 | ||||||||||||||||||
| 101 | default: never executed: default: | 0 | ||||||||||||||||||
| 102 | break; never executed: break; | 0 | ||||||||||||||||||
| 103 | } | - | ||||||||||||||||||
| 104 | return; never executed: return; | 0 | ||||||||||||||||||
| 105 | } else if (s == BorderStyle_Ridge || s == BorderStyle_Groove) {
| 0 | ||||||||||||||||||
| 106 | BorderStyle s1, s2; | - | ||||||||||||||||||
| 107 | if (s == BorderStyle_Groove) {
| 0 | ||||||||||||||||||
| 108 | s1 = BorderStyle_Inset; | - | ||||||||||||||||||
| 109 | s2 = BorderStyle_Outset; | - | ||||||||||||||||||
| 110 | } else { never executed: end of block | 0 | ||||||||||||||||||
| 111 | s1 = BorderStyle_Outset; | - | ||||||||||||||||||
| 112 | s2 = BorderStyle_Inset; | - | ||||||||||||||||||
| 113 | } never executed: end of block | 0 | ||||||||||||||||||
| 114 | int pwby2 = qRound(pw/2); | - | ||||||||||||||||||
| 115 | switch (edge) { | - | ||||||||||||||||||
| 116 | case TopEdge: never executed: case TopEdge: | 0 | ||||||||||||||||||
| 117 | qDrawRoundedCorners(p, x1, y1, x2, y1 + pwby2, r1, r2, TopEdge, s1, c); | - | ||||||||||||||||||
| 118 | qDrawRoundedCorners(p, x1, y1 + pwby2, x2, y2, r1, r2, TopEdge, s2, c); | - | ||||||||||||||||||
| 119 | break; never executed: break; | 0 | ||||||||||||||||||
| 120 | case BottomEdge: never executed: case BottomEdge: | 0 | ||||||||||||||||||
| 121 | qDrawRoundedCorners(p, x1, y1 + pwby2, x2, y2, r1, r2, BottomEdge, s1, c); | - | ||||||||||||||||||
| 122 | qDrawRoundedCorners(p, x1, y1, x2, y2-pwby2, r1, r2, BottomEdge, s2, c); | - | ||||||||||||||||||
| 123 | break; never executed: break; | 0 | ||||||||||||||||||
| 124 | case LeftEdge: never executed: case LeftEdge: | 0 | ||||||||||||||||||
| 125 | qDrawRoundedCorners(p, x1, y1, x1 + pwby2, y2, r1, r2, LeftEdge, s1, c); | - | ||||||||||||||||||
| 126 | qDrawRoundedCorners(p, x1 + pwby2, y1, x2, y2, r1, r2, LeftEdge, s2, c); | - | ||||||||||||||||||
| 127 | break; never executed: break; | 0 | ||||||||||||||||||
| 128 | case RightEdge: never executed: case RightEdge: | 0 | ||||||||||||||||||
| 129 | qDrawRoundedCorners(p, x1 + pwby2, y1, x2, y2, r1, r2, RightEdge, s1, c); | - | ||||||||||||||||||
| 130 | qDrawRoundedCorners(p, x1, y1, x2 - pwby2, y2, r1, r2, RightEdge, s2, c); | - | ||||||||||||||||||
| 131 | break; never executed: break; | 0 | ||||||||||||||||||
| 132 | default: never executed: default: | 0 | ||||||||||||||||||
| 133 | break; never executed: break; | 0 | ||||||||||||||||||
| 134 | } | - | ||||||||||||||||||
| 135 | } else if ((s == BorderStyle_Outset && (edge == TopEdge || edge == LeftEdge))
| 0 | ||||||||||||||||||
| 136 | || (s == BorderStyle_Inset && (edge == BottomEdge || edge == RightEdge)))
| 0 | ||||||||||||||||||
| 137 | c = c.color().lighter(); never executed: c = c.color().lighter(); | 0 | ||||||||||||||||||
| 138 | - | |||||||||||||||||||
| 139 | p->save(); | - | ||||||||||||||||||
| 140 | qreal pwby2 = pw/2; | - | ||||||||||||||||||
| 141 | p->setBrush(Qt::NoBrush); | - | ||||||||||||||||||
| 142 | QPen pen = qPenFromStyle(c, pw, s); | - | ||||||||||||||||||
| 143 | pen.setCapStyle(Qt::SquareCap); // this eliminates the offby1 errors that we might hit below | - | ||||||||||||||||||
| 144 | p->setPen(pen); | - | ||||||||||||||||||
| 145 | switch (edge) { | - | ||||||||||||||||||
| 146 | case TopEdge: never executed: case TopEdge: | 0 | ||||||||||||||||||
| 147 | if (!r1.isEmpty())
| 0 | ||||||||||||||||||
| 148 | p->drawArc(QRectF(x1 - r1.width() + pwby2, y1 + pwby2, never executed: p->drawArc(QRectF(x1 - r1.width() + pwby2, y1 + pwby2, 2*r1.width() - pw, 2*r1.height() - pw), 135*16, -45*16); | 0 | ||||||||||||||||||
| 149 | 2*r1.width() - pw, 2*r1.height() - pw), 135*16, -45*16); never executed: p->drawArc(QRectF(x1 - r1.width() + pwby2, y1 + pwby2, 2*r1.width() - pw, 2*r1.height() - pw), 135*16, -45*16); | 0 | ||||||||||||||||||
| 150 | if (!r2.isEmpty())
| 0 | ||||||||||||||||||
| 151 | p->drawArc(QRectF(x2 - r2.width() + pwby2, y1 + pwby2, never executed: p->drawArc(QRectF(x2 - r2.width() + pwby2, y1 + pwby2, 2*r2.width() - pw, 2*r2.height() - pw), 45*16, 45*16); | 0 | ||||||||||||||||||
| 152 | 2*r2.width() - pw, 2*r2.height() - pw), 45*16, 45*16); never executed: p->drawArc(QRectF(x2 - r2.width() + pwby2, y1 + pwby2, 2*r2.width() - pw, 2*r2.height() - pw), 45*16, 45*16); | 0 | ||||||||||||||||||
| 153 | break; never executed: break; | 0 | ||||||||||||||||||
| 154 | case BottomEdge: never executed: case BottomEdge: | 0 | ||||||||||||||||||
| 155 | if (!r1.isEmpty())
| 0 | ||||||||||||||||||
| 156 | p->drawArc(QRectF(x1 - r1.width() + pwby2, y2 - 2*r1.height() + pwby2, never executed: p->drawArc(QRectF(x1 - r1.width() + pwby2, y2 - 2*r1.height() + pwby2, 2*r1.width() - pw, 2*r1.height() - pw), -90 * 16, -45 * 16); | 0 | ||||||||||||||||||
| 157 | 2*r1.width() - pw, 2*r1.height() - pw), -90 * 16, -45 * 16); never executed: p->drawArc(QRectF(x1 - r1.width() + pwby2, y2 - 2*r1.height() + pwby2, 2*r1.width() - pw, 2*r1.height() - pw), -90 * 16, -45 * 16); | 0 | ||||||||||||||||||
| 158 | if (!r2.isEmpty())
| 0 | ||||||||||||||||||
| 159 | p->drawArc(QRectF(x2 - r2.width() + pwby2, y2 - 2*r2.height() + pwby2, never executed: p->drawArc(QRectF(x2 - r2.width() + pwby2, y2 - 2*r2.height() + pwby2, 2*r2.width() - pw, 2*r2.height() - pw), -90 * 16, 45 * 16); | 0 | ||||||||||||||||||
| 160 | 2*r2.width() - pw, 2*r2.height() - pw), -90 * 16, 45 * 16); never executed: p->drawArc(QRectF(x2 - r2.width() + pwby2, y2 - 2*r2.height() + pwby2, 2*r2.width() - pw, 2*r2.height() - pw), -90 * 16, 45 * 16); | 0 | ||||||||||||||||||
| 161 | break; never executed: break; | 0 | ||||||||||||||||||
| 162 | case LeftEdge: never executed: case LeftEdge: | 0 | ||||||||||||||||||
| 163 | if (!r1.isEmpty())
| 0 | ||||||||||||||||||
| 164 | p->drawArc(QRectF(x1 + pwby2, y1 - r1.height() + pwby2, never executed: p->drawArc(QRectF(x1 + pwby2, y1 - r1.height() + pwby2, 2*r1.width() - pw, 2*r1.height() - pw), 135*16, 45*16); | 0 | ||||||||||||||||||
| 165 | 2*r1.width() - pw, 2*r1.height() - pw), 135*16, 45*16); never executed: p->drawArc(QRectF(x1 + pwby2, y1 - r1.height() + pwby2, 2*r1.width() - pw, 2*r1.height() - pw), 135*16, 45*16); | 0 | ||||||||||||||||||
| 166 | if (!r2.isEmpty())
| 0 | ||||||||||||||||||
| 167 | p->drawArc(QRectF(x1 + pwby2, y2 - r2.height() + pwby2, never executed: p->drawArc(QRectF(x1 + pwby2, y2 - r2.height() + pwby2, 2*r2.width() - pw, 2*r2.height() - pw), 180*16, 45*16); | 0 | ||||||||||||||||||
| 168 | 2*r2.width() - pw, 2*r2.height() - pw), 180*16, 45*16); never executed: p->drawArc(QRectF(x1 + pwby2, y2 - r2.height() + pwby2, 2*r2.width() - pw, 2*r2.height() - pw), 180*16, 45*16); | 0 | ||||||||||||||||||
| 169 | break; never executed: break; | 0 | ||||||||||||||||||
| 170 | case RightEdge: never executed: case RightEdge: | 0 | ||||||||||||||||||
| 171 | if (!r1.isEmpty())
| 0 | ||||||||||||||||||
| 172 | p->drawArc(QRectF(x2 - 2*r1.width() + pwby2, y1 - r1.height() + pwby2, never executed: p->drawArc(QRectF(x2 - 2*r1.width() + pwby2, y1 - r1.height() + pwby2, 2*r1.width() - pw, 2*r1.height() - pw), 45*16, -45*16); | 0 | ||||||||||||||||||
| 173 | 2*r1.width() - pw, 2*r1.height() - pw), 45*16, -45*16); never executed: p->drawArc(QRectF(x2 - 2*r1.width() + pwby2, y1 - r1.height() + pwby2, 2*r1.width() - pw, 2*r1.height() - pw), 45*16, -45*16); | 0 | ||||||||||||||||||
| 174 | if (!r2.isEmpty())
| 0 | ||||||||||||||||||
| 175 | p->drawArc(QRectF(x2 - 2*r2.width() + pwby2, y2 - r2.height() + pwby2, never executed: p->drawArc(QRectF(x2 - 2*r2.width() + pwby2, y2 - r2.height() + pwby2, 2*r2.width() - pw, 2*r2.height() - pw), 315*16, 45*16); | 0 | ||||||||||||||||||
| 176 | 2*r2.width() - pw, 2*r2.height() - pw), 315*16, 45*16); never executed: p->drawArc(QRectF(x2 - 2*r2.width() + pwby2, y2 - r2.height() + pwby2, 2*r2.width() - pw, 2*r2.height() - pw), 315*16, 45*16); | 0 | ||||||||||||||||||
| 177 | break; never executed: break; | 0 | ||||||||||||||||||
| 178 | default: never executed: default: | 0 | ||||||||||||||||||
| 179 | break; never executed: break; | 0 | ||||||||||||||||||
| 180 | } | - | ||||||||||||||||||
| 181 | p->restore(); | - | ||||||||||||||||||
| 182 | } never executed: end of block | 0 | ||||||||||||||||||
| 183 | - | |||||||||||||||||||
| 184 | - | |||||||||||||||||||
| 185 | void qDrawEdge(QPainter *p, qreal x1, qreal y1, qreal x2, qreal y2, qreal dw1, qreal dw2, | - | ||||||||||||||||||
| 186 | QCss::Edge edge, QCss::BorderStyle style, QBrush c) | - | ||||||||||||||||||
| 187 | { | - | ||||||||||||||||||
| 188 | p->save(); | - | ||||||||||||||||||
| 189 | const qreal width = (edge == TopEdge || edge == BottomEdge) ? (y2-y1) : (x2-x1);
| 0 | ||||||||||||||||||
| 190 | - | |||||||||||||||||||
| 191 | if (width <= 2 && style == BorderStyle_Double)
| 0 | ||||||||||||||||||
| 192 | style = BorderStyle_Solid; never executed: style = BorderStyle_Solid; | 0 | ||||||||||||||||||
| 193 | - | |||||||||||||||||||
| 194 | switch (style) { | - | ||||||||||||||||||
| 195 | case BorderStyle_Inset: never executed: case BorderStyle_Inset: | 0 | ||||||||||||||||||
| 196 | case BorderStyle_Outset: never executed: case BorderStyle_Outset: | 0 | ||||||||||||||||||
| 197 | if ((style == BorderStyle_Outset && (edge == TopEdge || edge == LeftEdge))
| 0 | ||||||||||||||||||
| 198 | || (style == BorderStyle_Inset && (edge == BottomEdge || edge == RightEdge)))
| 0 | ||||||||||||||||||
| 199 | c = c.color().lighter(); never executed: c = c.color().lighter(); | 0 | ||||||||||||||||||
| 200 | // fall through! | - | ||||||||||||||||||
| 201 | case BorderStyle_Solid: { code before this statement never executed: case BorderStyle_Solid:never executed: case BorderStyle_Solid: | 0 | ||||||||||||||||||
| 202 | p->setPen(Qt::NoPen); | - | ||||||||||||||||||
| 203 | p->setBrush(c); | - | ||||||||||||||||||
| 204 | if (width == 1 || (dw1 == 0 && dw2 == 0)) {
| 0 | ||||||||||||||||||
| 205 | p->drawRect(QRectF(x1, y1, x2-x1, y2-y1)); | - | ||||||||||||||||||
| 206 | } else { // draw trapezoid never executed: end of block | 0 | ||||||||||||||||||
| 207 | QPolygonF quad; | - | ||||||||||||||||||
| 208 | switch (edge) { | - | ||||||||||||||||||
| 209 | case TopEdge: never executed: case TopEdge: | 0 | ||||||||||||||||||
| 210 | quad << QPointF(x1, y1) << QPointF(x1 + dw1, y2) | - | ||||||||||||||||||
| 211 | << QPointF(x2 - dw2, y2) << QPointF(x2, y1); | - | ||||||||||||||||||
| 212 | break; never executed: break; | 0 | ||||||||||||||||||
| 213 | case BottomEdge: never executed: case BottomEdge: | 0 | ||||||||||||||||||
| 214 | quad << QPointF(x1 + dw1, y1) << QPointF(x1, y2) | - | ||||||||||||||||||
| 215 | << QPointF(x2, y2) << QPointF(x2 - dw2, y1); | - | ||||||||||||||||||
| 216 | break; never executed: break; | 0 | ||||||||||||||||||
| 217 | case LeftEdge: never executed: case LeftEdge: | 0 | ||||||||||||||||||
| 218 | quad << QPointF(x1, y1) << QPointF(x1, y2) | - | ||||||||||||||||||
| 219 | << QPointF(x2, y2 - dw2) << QPointF(x2, y1 + dw1); | - | ||||||||||||||||||
| 220 | break; never executed: break; | 0 | ||||||||||||||||||
| 221 | case RightEdge: never executed: case RightEdge: | 0 | ||||||||||||||||||
| 222 | quad << QPointF(x1, y1 + dw1) << QPointF(x1, y2 - dw2) | - | ||||||||||||||||||
| 223 | << QPointF(x2, y2) << QPointF(x2, y1); | - | ||||||||||||||||||
| 224 | break; never executed: break; | 0 | ||||||||||||||||||
| 225 | default: never executed: default: | 0 | ||||||||||||||||||
| 226 | break; never executed: break; | 0 | ||||||||||||||||||
| 227 | } | - | ||||||||||||||||||
| 228 | p->drawConvexPolygon(quad); | - | ||||||||||||||||||
| 229 | } never executed: end of block | 0 | ||||||||||||||||||
| 230 | break; never executed: break; | 0 | ||||||||||||||||||
| 231 | } | - | ||||||||||||||||||
| 232 | case BorderStyle_Dotted: never executed: case BorderStyle_Dotted: | 0 | ||||||||||||||||||
| 233 | case BorderStyle_Dashed: never executed: case BorderStyle_Dashed: | 0 | ||||||||||||||||||
| 234 | case BorderStyle_DotDash: never executed: case BorderStyle_DotDash: | 0 | ||||||||||||||||||
| 235 | case BorderStyle_DotDotDash: never executed: case BorderStyle_DotDotDash: | 0 | ||||||||||||||||||
| 236 | p->setPen(qPenFromStyle(c, width, style)); | - | ||||||||||||||||||
| 237 | if (width == 1)
| 0 | ||||||||||||||||||
| 238 | p->drawLine(QLineF(x1, y1, x2 - 1, y2 - 1)); never executed: p->drawLine(QLineF(x1, y1, x2 - 1, y2 - 1)); | 0 | ||||||||||||||||||
| 239 | else if (edge == TopEdge || edge == BottomEdge)
| 0 | ||||||||||||||||||
| 240 | p->drawLine(QLineF(x1 + width/2, (y1 + y2)/2, x2 - width/2, (y1 + y2)/2)); never executed: p->drawLine(QLineF(x1 + width/2, (y1 + y2)/2, x2 - width/2, (y1 + y2)/2)); | 0 | ||||||||||||||||||
| 241 | else | - | ||||||||||||||||||
| 242 | p->drawLine(QLineF((x1+x2)/2, y1 + width/2, (x1+x2)/2, y2 - width/2)); never executed: p->drawLine(QLineF((x1+x2)/2, y1 + width/2, (x1+x2)/2, y2 - width/2)); | 0 | ||||||||||||||||||
| 243 | break; never executed: break; | 0 | ||||||||||||||||||
| 244 | - | |||||||||||||||||||
| 245 | case BorderStyle_Double: { never executed: case BorderStyle_Double: | 0 | ||||||||||||||||||
| 246 | int wby3 = qRound(width/3); | - | ||||||||||||||||||
| 247 | int dw1by3 = qRound(dw1/3); | - | ||||||||||||||||||
| 248 | int dw2by3 = qRound(dw2/3); | - | ||||||||||||||||||
| 249 | switch (edge) { | - | ||||||||||||||||||
| 250 | case TopEdge: never executed: case TopEdge: | 0 | ||||||||||||||||||
| 251 | qDrawEdge(p, x1, y1, x2, y1 + wby3, dw1by3, dw2by3, TopEdge, BorderStyle_Solid, c); | - | ||||||||||||||||||
| 252 | qDrawEdge(p, x1 + dw1 - dw1by3, y2 - wby3, x2 - dw2 + dw1by3, y2, | - | ||||||||||||||||||
| 253 | dw1by3, dw2by3, TopEdge, BorderStyle_Solid, c); | - | ||||||||||||||||||
| 254 | break; never executed: break; | 0 | ||||||||||||||||||
| 255 | case LeftEdge: never executed: case LeftEdge: | 0 | ||||||||||||||||||
| 256 | qDrawEdge(p, x1, y1, x1 + wby3, y2, dw1by3, dw2by3, LeftEdge, BorderStyle_Solid, c); | - | ||||||||||||||||||
| 257 | qDrawEdge(p, x2 - wby3, y1 + dw1 - dw1by3, x2, y2 - dw2 + dw2by3, dw1by3, dw2by3, | - | ||||||||||||||||||
| 258 | LeftEdge, BorderStyle_Solid, c); | - | ||||||||||||||||||
| 259 | break; never executed: break; | 0 | ||||||||||||||||||
| 260 | case BottomEdge: never executed: case BottomEdge: | 0 | ||||||||||||||||||
| 261 | qDrawEdge(p, x1 + dw1 - dw1by3, y1, x2 - dw2 + dw2by3, y1 + wby3, dw1by3, dw2by3, | - | ||||||||||||||||||
| 262 | BottomEdge, BorderStyle_Solid, c); | - | ||||||||||||||||||
| 263 | qDrawEdge(p, x1, y2 - wby3, x2, y2, dw1by3, dw2by3, BottomEdge, BorderStyle_Solid, c); | - | ||||||||||||||||||
| 264 | break; never executed: break; | 0 | ||||||||||||||||||
| 265 | case RightEdge: never executed: case RightEdge: | 0 | ||||||||||||||||||
| 266 | qDrawEdge(p, x2 - wby3, y1, x2, y2, dw1by3, dw2by3, RightEdge, BorderStyle_Solid, c); | - | ||||||||||||||||||
| 267 | qDrawEdge(p, x1, y1 + dw1 - dw1by3, x1 + wby3, y2 - dw2 + dw2by3, dw1by3, dw2by3, | - | ||||||||||||||||||
| 268 | RightEdge, BorderStyle_Solid, c); | - | ||||||||||||||||||
| 269 | break; never executed: break; | 0 | ||||||||||||||||||
| 270 | default: never executed: default: | 0 | ||||||||||||||||||
| 271 | break; never executed: break; | 0 | ||||||||||||||||||
| 272 | } | - | ||||||||||||||||||
| 273 | break; never executed: break; | 0 | ||||||||||||||||||
| 274 | } | - | ||||||||||||||||||
| 275 | case BorderStyle_Ridge: never executed: case BorderStyle_Ridge: | 0 | ||||||||||||||||||
| 276 | case BorderStyle_Groove: { never executed: case BorderStyle_Groove: | 0 | ||||||||||||||||||
| 277 | BorderStyle s1, s2; | - | ||||||||||||||||||
| 278 | if (style == BorderStyle_Groove) {
| 0 | ||||||||||||||||||
| 279 | s1 = BorderStyle_Inset; | - | ||||||||||||||||||
| 280 | s2 = BorderStyle_Outset; | - | ||||||||||||||||||
| 281 | } else { never executed: end of block | 0 | ||||||||||||||||||
| 282 | s1 = BorderStyle_Outset; | - | ||||||||||||||||||
| 283 | s2 = BorderStyle_Inset; | - | ||||||||||||||||||
| 284 | } never executed: end of block | 0 | ||||||||||||||||||
| 285 | int dw1by2 = qFloor(dw1/2), dw2by2 = qFloor(dw2/2); | - | ||||||||||||||||||
| 286 | int wby2 = qRound(width/2); | - | ||||||||||||||||||
| 287 | switch (edge) { | - | ||||||||||||||||||
| 288 | case TopEdge: never executed: case TopEdge: | 0 | ||||||||||||||||||
| 289 | qDrawEdge(p, x1, y1, x2, y1 + wby2, dw1by2, dw2by2, TopEdge, s1, c); | - | ||||||||||||||||||
| 290 | qDrawEdge(p, x1 + dw1by2, y1 + wby2, x2 - dw2by2, y2, dw1by2, dw2by2, TopEdge, s2, c); | - | ||||||||||||||||||
| 291 | break; never executed: break; | 0 | ||||||||||||||||||
| 292 | case BottomEdge: never executed: case BottomEdge: | 0 | ||||||||||||||||||
| 293 | qDrawEdge(p, x1, y1 + wby2, x2, y2, dw1by2, dw2by2, BottomEdge, s1, c); | - | ||||||||||||||||||
| 294 | qDrawEdge(p, x1 + dw1by2, y1, x2 - dw2by2, y1 + wby2, dw1by2, dw2by2, BottomEdge, s2, c); | - | ||||||||||||||||||
| 295 | break; never executed: break; | 0 | ||||||||||||||||||
| 296 | case LeftEdge: never executed: case LeftEdge: | 0 | ||||||||||||||||||
| 297 | qDrawEdge(p, x1, y1, x1 + wby2, y2, dw1by2, dw2by2, LeftEdge, s1, c); | - | ||||||||||||||||||
| 298 | qDrawEdge(p, x1 + wby2, y1 + dw1by2, x2, y2 - dw2by2, dw1by2, dw2by2, LeftEdge, s2, c); | - | ||||||||||||||||||
| 299 | break; never executed: break; | 0 | ||||||||||||||||||
| 300 | case RightEdge: never executed: case RightEdge: | 0 | ||||||||||||||||||
| 301 | qDrawEdge(p, x1 + wby2, y1, x2, y2, dw1by2, dw2by2, RightEdge, s1, c); | - | ||||||||||||||||||
| 302 | qDrawEdge(p, x1, y1 + dw1by2, x1 + wby2, y2 - dw2by2, dw1by2, dw2by2, RightEdge, s2, c); | - | ||||||||||||||||||
| 303 | break; never executed: break; | 0 | ||||||||||||||||||
| 304 | default: never executed: default: | 0 | ||||||||||||||||||
| 305 | break; never executed: break; | 0 | ||||||||||||||||||
| 306 | } | - | ||||||||||||||||||
| 307 | } | - | ||||||||||||||||||
| 308 | default: code before this statement never executed: default:never executed: default: | 0 | ||||||||||||||||||
| 309 | break; never executed: break; | 0 | ||||||||||||||||||
| 310 | } | - | ||||||||||||||||||
| 311 | p->restore(); | - | ||||||||||||||||||
| 312 | } never executed: end of block | 0 | ||||||||||||||||||
| 313 | - | |||||||||||||||||||
| 314 | void qNormalizeRadii(const QRect &br, const QSize *radii, | - | ||||||||||||||||||
| 315 | QSize *tlr, QSize *trr, QSize *blr, QSize *brr) | - | ||||||||||||||||||
| 316 | { | - | ||||||||||||||||||
| 317 | *tlr = radii[0].expandedTo(QSize(0, 0)); | - | ||||||||||||||||||
| 318 | *trr = radii[1].expandedTo(QSize(0, 0)); | - | ||||||||||||||||||
| 319 | *blr = radii[2].expandedTo(QSize(0, 0)); | - | ||||||||||||||||||
| 320 | *brr = radii[3].expandedTo(QSize(0, 0)); | - | ||||||||||||||||||
| 321 | if (tlr->width() + trr->width() > br.width())
| 0 | ||||||||||||||||||
| 322 | *tlr = *trr = QSize(0, 0); never executed: *tlr = *trr = QSize(0, 0); | 0 | ||||||||||||||||||
| 323 | if (blr->width() + brr->width() > br.width())
| 0 | ||||||||||||||||||
| 324 | *blr = *brr = QSize(0, 0); never executed: *blr = *brr = QSize(0, 0); | 0 | ||||||||||||||||||
| 325 | if (tlr->height() + blr->height() > br.height())
| 0 | ||||||||||||||||||
| 326 | *tlr = *blr = QSize(0, 0); never executed: *tlr = *blr = QSize(0, 0); | 0 | ||||||||||||||||||
| 327 | if (trr->height() + brr->height() > br.height())
| 0 | ||||||||||||||||||
| 328 | *trr = *brr = QSize(0, 0); never executed: *trr = *brr = QSize(0, 0); | 0 | ||||||||||||||||||
| 329 | } never executed: end of block | 0 | ||||||||||||||||||
| 330 | - | |||||||||||||||||||
| 331 | // Determines if Edge e1 draws over Edge e2. Depending on this trapezoids or rectanges are drawn | - | ||||||||||||||||||
| 332 | static bool paintsOver(const QCss::BorderStyle *styles, const QBrush *colors, QCss::Edge e1, QCss::Edge e2) | - | ||||||||||||||||||
| 333 | { | - | ||||||||||||||||||
| 334 | QCss::BorderStyle s1 = styles[e1]; | - | ||||||||||||||||||
| 335 | QCss::BorderStyle s2 = styles[e2]; | - | ||||||||||||||||||
| 336 | - | |||||||||||||||||||
| 337 | if (s2 == BorderStyle_None || colors[e2] == Qt::transparent)
| 0 | ||||||||||||||||||
| 338 | return true; never executed: return true; | 0 | ||||||||||||||||||
| 339 | - | |||||||||||||||||||
| 340 | if ((s1 == BorderStyle_Solid && s2 == BorderStyle_Solid) && (colors[e1] == colors[e2])
| 0 | ||||||||||||||||||
| 341 | && colors[e1].isOpaque()) {
| 0 | ||||||||||||||||||
| 342 | return true; never executed: return true; | 0 | ||||||||||||||||||
| 343 | } | - | ||||||||||||||||||
| 344 | - | |||||||||||||||||||
| 345 | return false; never executed: return false; | 0 | ||||||||||||||||||
| 346 | } | - | ||||||||||||||||||
| 347 | - | |||||||||||||||||||
| 348 | void qDrawBorder(QPainter *p, const QRect &rect, const QCss::BorderStyle *styles, | - | ||||||||||||||||||
| 349 | const int *borders, const QBrush *colors, const QSize *radii) | - | ||||||||||||||||||
| 350 | { | - | ||||||||||||||||||
| 351 | const QRectF br(rect); | - | ||||||||||||||||||
| 352 | QSize tlr, trr, blr, brr; | - | ||||||||||||||||||
| 353 | qNormalizeRadii(rect, radii, &tlr, &trr, &blr, &brr); | - | ||||||||||||||||||
| 354 | - | |||||||||||||||||||
| 355 | // Drawn in increasing order of precendence | - | ||||||||||||||||||
| 356 | if (styles[BottomEdge] != BorderStyle_None && borders[BottomEdge] > 0) {
| 0 | ||||||||||||||||||
| 357 | qreal dw1 = (blr.width() || paintsOver(styles, colors, BottomEdge, LeftEdge)) ? 0 : borders[LeftEdge];
| 0 | ||||||||||||||||||
| 358 | qreal dw2 = (brr.width() || paintsOver(styles, colors, BottomEdge, RightEdge)) ? 0 : borders[RightEdge];
| 0 | ||||||||||||||||||
| 359 | qreal x1 = br.x() + blr.width(); | - | ||||||||||||||||||
| 360 | qreal y1 = br.y() + br.height() - borders[BottomEdge]; | - | ||||||||||||||||||
| 361 | qreal x2 = br.x() + br.width() - brr.width(); | - | ||||||||||||||||||
| 362 | qreal y2 = br.y() + br.height() ; | - | ||||||||||||||||||
| 363 | - | |||||||||||||||||||
| 364 | qDrawEdge(p, x1, y1, x2, y2, dw1, dw2, BottomEdge, styles[BottomEdge], colors[BottomEdge]); | - | ||||||||||||||||||
| 365 | if (blr.width() || brr.width())
| 0 | ||||||||||||||||||
| 366 | qDrawRoundedCorners(p, x1, y1, x2, y2, blr, brr, BottomEdge, styles[BottomEdge], colors[BottomEdge]); never executed: qDrawRoundedCorners(p, x1, y1, x2, y2, blr, brr, BottomEdge, styles[BottomEdge], colors[BottomEdge]); | 0 | ||||||||||||||||||
| 367 | } never executed: end of block | 0 | ||||||||||||||||||
| 368 | if (styles[RightEdge] != BorderStyle_None && borders[RightEdge] > 0) {
| 0 | ||||||||||||||||||
| 369 | qreal dw1 = (trr.height() || paintsOver(styles, colors, RightEdge, TopEdge)) ? 0 : borders[TopEdge];
| 0 | ||||||||||||||||||
| 370 | qreal dw2 = (brr.height() || paintsOver(styles, colors, RightEdge, BottomEdge)) ? 0 : borders[BottomEdge];
| 0 | ||||||||||||||||||
| 371 | qreal x1 = br.x() + br.width() - borders[RightEdge]; | - | ||||||||||||||||||
| 372 | qreal y1 = br.y() + trr.height(); | - | ||||||||||||||||||
| 373 | qreal x2 = br.x() + br.width(); | - | ||||||||||||||||||
| 374 | qreal y2 = br.y() + br.height() - brr.height(); | - | ||||||||||||||||||
| 375 | - | |||||||||||||||||||
| 376 | qDrawEdge(p, x1, y1, x2, y2, dw1, dw2, RightEdge, styles[RightEdge], colors[RightEdge]); | - | ||||||||||||||||||
| 377 | if (trr.height() || brr.height())
| 0 | ||||||||||||||||||
| 378 | qDrawRoundedCorners(p, x1, y1, x2, y2, trr, brr, RightEdge, styles[RightEdge], colors[RightEdge]); never executed: qDrawRoundedCorners(p, x1, y1, x2, y2, trr, brr, RightEdge, styles[RightEdge], colors[RightEdge]); | 0 | ||||||||||||||||||
| 379 | } never executed: end of block | 0 | ||||||||||||||||||
| 380 | if (styles[LeftEdge] != BorderStyle_None && borders[LeftEdge] > 0) {
| 0 | ||||||||||||||||||
| 381 | qreal dw1 = (tlr.height() || paintsOver(styles, colors, LeftEdge, TopEdge)) ? 0 : borders[TopEdge];
| 0 | ||||||||||||||||||
| 382 | qreal dw2 = (blr.height() || paintsOver(styles, colors, LeftEdge, BottomEdge)) ? 0 : borders[BottomEdge];
| 0 | ||||||||||||||||||
| 383 | qreal x1 = br.x(); | - | ||||||||||||||||||
| 384 | qreal y1 = br.y() + tlr.height(); | - | ||||||||||||||||||
| 385 | qreal x2 = br.x() + borders[LeftEdge]; | - | ||||||||||||||||||
| 386 | qreal y2 = br.y() + br.height() - blr.height(); | - | ||||||||||||||||||
| 387 | - | |||||||||||||||||||
| 388 | qDrawEdge(p, x1, y1, x2, y2, dw1, dw2, LeftEdge, styles[LeftEdge], colors[LeftEdge]); | - | ||||||||||||||||||
| 389 | if (tlr.height() || blr.height())
| 0 | ||||||||||||||||||
| 390 | qDrawRoundedCorners(p, x1, y1, x2, y2, tlr, blr, LeftEdge, styles[LeftEdge], colors[LeftEdge]); never executed: qDrawRoundedCorners(p, x1, y1, x2, y2, tlr, blr, LeftEdge, styles[LeftEdge], colors[LeftEdge]); | 0 | ||||||||||||||||||
| 391 | } never executed: end of block | 0 | ||||||||||||||||||
| 392 | if (styles[TopEdge] != BorderStyle_None && borders[TopEdge] > 0) {
| 0 | ||||||||||||||||||
| 393 | qreal dw1 = (tlr.width() || paintsOver(styles, colors, TopEdge, LeftEdge)) ? 0 : borders[LeftEdge];
| 0 | ||||||||||||||||||
| 394 | qreal dw2 = (trr.width() || paintsOver(styles, colors, TopEdge, RightEdge)) ? 0 : borders[RightEdge];
| 0 | ||||||||||||||||||
| 395 | qreal x1 = br.x() + tlr.width(); | - | ||||||||||||||||||
| 396 | qreal y1 = br.y(); | - | ||||||||||||||||||
| 397 | qreal x2 = br.left() + br.width() - trr.width(); | - | ||||||||||||||||||
| 398 | qreal y2 = br.y() + borders[TopEdge]; | - | ||||||||||||||||||
| 399 | - | |||||||||||||||||||
| 400 | qDrawEdge(p, x1, y1, x2, y2, dw1, dw2, TopEdge, styles[TopEdge], colors[TopEdge]); | - | ||||||||||||||||||
| 401 | if (tlr.width() || trr.width())
| 0 | ||||||||||||||||||
| 402 | qDrawRoundedCorners(p, x1, y1, x2, y2, tlr, trr, TopEdge, styles[TopEdge], colors[TopEdge]); never executed: qDrawRoundedCorners(p, x1, y1, x2, y2, tlr, trr, TopEdge, styles[TopEdge], colors[TopEdge]); | 0 | ||||||||||||||||||
| 403 | } never executed: end of block | 0 | ||||||||||||||||||
| 404 | } never executed: end of block | 0 | ||||||||||||||||||
| 405 | - | |||||||||||||||||||
| 406 | #endif //QT_NO_CSSPARSER | - | ||||||||||||||||||
| 407 | - | |||||||||||||||||||
| 408 | QT_END_NAMESPACE | - | ||||||||||||||||||
| Source code | Switch to Preprocessed file |