1342
1356
QImage image2 = image1;
1344
const QRect outerRect = image1.rect();
1345
const QRect centerRect = outerRect.adjusted(horThickness / 2, vertThickness / 2,
1346
-(horThickness / 2), -(vertThickness / 2));
1347
const QRect innerRect = outerRect.adjusted(horThickness, vertThickness, -horThickness, -vertThickness);
1349
1358
const QColor c1 = style == RIDGE ? dark : light;
1350
1359
const QColor c2 = style == RIDGE ? light : dark;
1352
QPainterPath outer, inner;
1353
outer.arcMoveTo(outerRect, angleStart);
1354
outer.arcTo(outerRect, angleStart, angleSpan);
1355
if (centerRect.isValid())
1356
outer.arcTo(centerRect, angleStart + angleSpan, -angleSpan);
1358
outer.lineTo(radius.horizontal, radius.vertical);
1359
outer.closeSubpath();
1361
const qreal hw = horThickness / 2;
1362
const qreal vw = vertThickness / 2;
1363
int cx = radius.horizontal;
1364
int cy = radius.vertical;
1361
if (centerRect.isValid()) {
1362
inner.arcMoveTo(centerRect, angleStart);
1363
inner.arcTo(centerRect, angleStart, angleSpan);
1364
if (innerRect.isValid())
1365
inner.arcTo(innerRect, angleStart + angleSpan, -angleSpan);
1367
inner.lineTo(radius.horizontal, radius.vertical);
1368
inner.closeSubpath();
1366
BorderRadii innerRadius;
1367
innerRadius.horizontal = radius.horizontal - hw;
1368
innerRadius.vertical = radius.vertical - vw;
1372
1371
p2.begin(&image1);
1373
p2.setRenderHint(QPainter::Antialiasing);
1374
p2.fillPath(outer, c1);
1375
p2.fillPath(inner, c2);
1372
drawBorderArc(&p2, cx, cy, hw, vw, radius, angleStart, angleSpan, c1, textColor, SOLID);
1373
drawBorderArc(&p2, cx, cy, hw, vw, innerRadius, angleStart, angleSpan, c2, textColor, SOLID);
1378
1376
p2.begin(&image2);
1379
p2.setRenderHint(QPainter::Antialiasing);
1380
p2.fillPath(outer, c2);
1381
p2.fillPath(inner, c1);
1377
drawBorderArc(&p2, cx, cy, hw, vw, radius, angleStart, angleSpan, c2, textColor, SOLID);
1378
drawBorderArc(&p2, cx, cy, hw, vw, innerRadius, angleStart, angleSpan, c1, textColor, SOLID);
1384
1381
p->drawImage(x - radius.horizontal, y - radius.vertical, blendCornerImages(image1, image2));
1439
1431
bool lowerRightBorderStylesMatch = render_r && (bs == rs) && (bc == rc);
1442
bool ignore_left = (renderRadii && topLeft.horizontal > 0) ||
1434
bool ignore_left = (topLeft.horizontal > 0) ||
1443
1435
((tc == lc) && (tt == lt) &&
1444
1436
(ts >= OUTSET) &&
1445
1437
(ls == DOTTED || ls == DASHED || ls == SOLID || ls == OUTSET));
1447
bool ignore_right = (renderRadii && topRight.horizontal > 0) ||
1439
bool ignore_right = (topRight.horizontal > 0) ||
1448
1440
((tc == rc) && (tt == rt) &&
1449
1441
(ts >= OUTSET) &&
1450
1442
(rs == DOTTED || rs == DASHED || rs == SOLID || rs == INSET));
1455
x += topLeft.horizontal;
1456
x2 -= topRight.horizontal;
1444
int x = _tx + topLeft.horizontal;
1445
int x2 = _tx + w - topRight.horizontal;
1459
1447
drawBorder(p, x, _ty, x2, _ty + style->borderTopWidth(), BSTop, tc, style->color(), ts,
1460
1448
ignore_left?0:style->borderLeftWidth(),
1461
1449
ignore_right?0:style->borderRightWidth());
1464
if (topLeft.hasBorderRadius()) {
1465
int x = _tx + topLeft.horizontal;
1466
int y = _ty + topLeft.vertical;
1467
int startAngle = 90;
1468
int span = upperLeftBorderStylesMatch ? 90 : 45;
1470
// Draw the upper left arc
1471
drawBorderArc(p, x, y, style->borderLeftWidth(), style->borderTopWidth(),
1472
topLeft, startAngle, span, tc, style->color(), ts);
1475
if (topRight.hasBorderRadius()) {
1476
int x = _tx + w - topRight.horizontal;
1477
int y = _ty + topRight.vertical;
1478
int startAngle = 90;
1479
int span = upperRightBorderStylesMatch ? -90 : -45;
1481
// Draw the upper right arc
1482
drawBorderArc(p, x, y, style->borderRightWidth(), style->borderTopWidth(),
1483
topRight, startAngle, span, tc, style->color(), ts);
1451
if (topLeft.hasBorderRadius()) {
1452
int x = _tx + topLeft.horizontal;
1453
int y = _ty + topLeft.vertical;
1454
int startAngle = 90;
1455
int span = upperLeftBorderStylesMatch ? 90 : 45;
1457
// Draw the upper left arc
1458
drawBorderArc(p, x, y, style->borderLeftWidth(), style->borderTopWidth(),
1459
topLeft, startAngle, span, tc, style->color(), ts);
1462
if (topRight.hasBorderRadius()) {
1463
int x = _tx + w - topRight.horizontal;
1464
int y = _ty + topRight.vertical;
1465
int startAngle = 90;
1466
int span = upperRightBorderStylesMatch ? -90 : -45;
1468
// Draw the upper right arc
1469
drawBorderArc(p, x, y, style->borderRightWidth(), style->borderTopWidth(),
1470
topRight, startAngle, span, tc, style->color(), ts);
1489
bool ignore_left = (renderRadii && bottomLeft.horizontal > 0) ||
1475
bool ignore_left = (bottomLeft.horizontal > 0) ||
1490
1476
((bc == lc) && (bt == lt) &&
1491
1477
(bs >= OUTSET) &&
1492
1478
(ls == DOTTED || ls == DASHED || ls == SOLID || ls == OUTSET));
1494
bool ignore_right = (renderRadii && bottomRight.horizontal > 0) ||
1480
bool ignore_right = (bottomRight.horizontal > 0) ||
1495
1481
((bc == rc) && (bt == rt) &&
1496
1482
(bs >= OUTSET) &&
1497
1483
(rs == DOTTED || rs == DASHED || rs == SOLID || rs == INSET));
1502
x += bottomLeft.horizontal;
1503
x2 -= bottomRight.horizontal;
1485
int x = _tx + bottomLeft.horizontal;
1486
int x2 = _tx + w - bottomRight.horizontal;
1506
1488
drawBorder(p, x, _ty + h - style->borderBottomWidth(), x2, _ty + h, BSBottom, bc, style->color(), bs,
1507
1489
ignore_left?0:style->borderLeftWidth(),
1508
1490
ignore_right?0:style->borderRightWidth());
1511
if (bottomLeft.hasBorderRadius()) {
1512
int x = _tx + bottomLeft.horizontal;
1513
int y = _ty + h - bottomLeft.vertical;
1514
int startAngle = 270;
1515
int span = lowerLeftBorderStylesMatch ? -90 : -45;
1517
// Draw the bottom left arc
1518
drawBorderArc(p, x, y, style->borderLeftWidth(), style->borderBottomWidth(),
1519
bottomLeft, startAngle, span, bc, style->color(), bs);
1522
if (bottomRight.hasBorderRadius()) {
1523
int x = _tx + w - bottomRight.horizontal;
1524
int y = _ty + h - bottomRight.vertical;
1525
int startAngle = 270;
1526
int span = lowerRightBorderStylesMatch ? 90 : 45;
1528
// Draw the bottom right arc
1529
drawBorderArc(p, x, y, style->borderRightWidth(), style->borderBottomWidth(),
1530
bottomRight, startAngle, span, bc, style->color(), bs);
1492
if (bottomLeft.hasBorderRadius()) {
1493
int x = _tx + bottomLeft.horizontal;
1494
int y = _ty + h - bottomLeft.vertical;
1495
int startAngle = 270;
1496
int span = lowerLeftBorderStylesMatch ? -90 : -45;
1498
// Draw the bottom left arc
1499
drawBorderArc(p, x, y, style->borderLeftWidth(), style->borderBottomWidth(),
1500
bottomLeft, startAngle, span, bc, style->color(), bs);
1503
if (bottomRight.hasBorderRadius()) {
1504
int x = _tx + w - bottomRight.horizontal;
1505
int y = _ty + h - bottomRight.vertical;
1506
int startAngle = 270;
1507
int span = lowerRightBorderStylesMatch ? 90 : 45;
1509
// Draw the bottom right arc
1510
drawBorderArc(p, x, y, style->borderRightWidth(), style->borderBottomWidth(),
1511
bottomRight, startAngle, span, bc, style->color(), bs);
1537
bool ignore_top = (renderRadii && topLeft.vertical > 0) ||
1517
bool ignore_top = (topLeft.vertical > 0) ||
1538
1518
((tc == lc) && (tt == lt) &&
1539
1519
(ls >= OUTSET) &&
1540
1520
(ts == DOTTED || ts == DASHED || ts == SOLID || ts == OUTSET));
1542
bool ignore_bottom = (renderRadii && bottomLeft.vertical > 0) ||
1522
bool ignore_bottom = (bottomLeft.vertical > 0) ||
1543
1523
((bc == lc) && (bt == lt) &&
1544
1524
(ls >= OUTSET) &&
1545
1525
(bs == DOTTED || bs == DASHED || bs == SOLID || bs == INSET));
1550
y += topLeft.vertical;
1551
y2 -= bottomLeft.vertical;
1527
int y = _ty + topLeft.vertical;
1528
int y2 = _ty + h - bottomLeft.vertical;
1554
1530
drawBorder(p, _tx, y, _tx + style->borderLeftWidth(), y2, BSLeft, lc, style->color(), ls,
1555
1531
ignore_top?0:style->borderTopWidth(),
1556
1532
ignore_bottom?0:style->borderBottomWidth());
1558
if (renderRadii && (!upperLeftBorderStylesMatch || !lowerLeftBorderStylesMatch)) {
1559
if (!upperLeftBorderStylesMatch && topLeft.hasBorderRadius()) {
1560
int x = _tx + topLeft.horizontal;
1561
int y = _ty + topLeft.vertical;
1562
int startAngle = 135;
1565
// Draw the upper left arc
1566
drawBorderArc(p, x, y, style->borderLeftWidth(), style->borderTopWidth(),
1567
topLeft, startAngle, span, lc, style->color(), ls);
1569
if (!lowerLeftBorderStylesMatch && bottomLeft.hasBorderRadius()) {
1570
int x = _tx + bottomLeft.horizontal;
1571
int y = _ty + h - bottomLeft.vertical;
1572
int startAngle = 180;
1575
// Draw the bottom left arc
1576
drawBorderArc(p, x, y, style->borderLeftWidth(), style->borderBottomWidth(),
1577
bottomLeft, startAngle, span, lc, style->color(), ls);
1534
if (!upperLeftBorderStylesMatch && topLeft.hasBorderRadius()) {
1535
int x = _tx + topLeft.horizontal;
1536
int y = _ty + topLeft.vertical;
1537
int startAngle = 135;
1540
// Draw the upper left arc
1541
drawBorderArc(p, x, y, style->borderLeftWidth(), style->borderTopWidth(),
1542
topLeft, startAngle, span, lc, style->color(), ls);
1544
if (!lowerLeftBorderStylesMatch && bottomLeft.hasBorderRadius()) {
1545
int x = _tx + bottomLeft.horizontal;
1546
int y = _ty + h - bottomLeft.vertical;
1547
int startAngle = 180;
1550
// Draw the bottom left arc
1551
drawBorderArc(p, x, y, style->borderLeftWidth(), style->borderBottomWidth(),
1552
bottomLeft, startAngle, span, lc, style->color(), ls);
1584
bool ignore_top = (renderRadii && topRight.vertical > 0) ||
1558
bool ignore_top = (topRight.vertical > 0) ||
1585
1559
((tc == rc) && (tt == rt) &&
1586
1560
(rs >= DOTTED || rs == INSET) &&
1587
1561
(ts == DOTTED || ts == DASHED || ts == SOLID || ts == OUTSET));
1589
bool ignore_bottom = (renderRadii && bottomRight.vertical > 0) ||
1563
bool ignore_bottom = (bottomRight.vertical > 0) ||
1590
1564
((bc == rc) && (bt == rt) &&
1591
1565
(rs >= DOTTED || rs == INSET) &&
1592
1566
(bs == DOTTED || bs == DASHED || bs == SOLID || bs == INSET));
1597
y += topRight.vertical;
1598
y2 -= bottomRight.vertical;
1568
int y = _ty + topRight.vertical;
1569
int y2 = _ty + h - bottomRight.vertical;
1601
1571
drawBorder(p, _tx + w - style->borderRightWidth(), y, _tx + w, y2, BSRight, rc, style->color(), rs,
1602
1572
ignore_top?0:style->borderTopWidth(),
1603
1573
ignore_bottom?0:style->borderBottomWidth());
1605
if (renderRadii && (!upperRightBorderStylesMatch || !lowerRightBorderStylesMatch)) {
1606
if (!upperRightBorderStylesMatch && topRight.hasBorderRadius()) {
1607
int x = _tx + w - topRight.horizontal;
1608
int y = _ty + topRight.vertical;
1612
// Draw the upper right arc
1613
drawBorderArc(p, x, y, style->borderRightWidth(), style->borderTopWidth(),
1614
topRight, startAngle, span, rc, style->color(), rs);
1616
if (!lowerRightBorderStylesMatch && bottomRight.hasBorderRadius()) {
1617
int x = _tx + w - bottomRight.horizontal;
1618
int y = _ty + h - bottomRight.vertical;
1619
int startAngle = 315;
1622
// Draw the bottom right arc
1623
drawBorderArc(p, x, y, style->borderRightWidth(), style->borderBottomWidth(),
1624
bottomRight, startAngle, span, rc, style->color(), rs);
1575
if (!upperRightBorderStylesMatch && topRight.hasBorderRadius()) {
1576
int x = _tx + w - topRight.horizontal;
1577
int y = _ty + topRight.vertical;
1581
// Draw the upper right arc
1582
drawBorderArc(p, x, y, style->borderRightWidth(), style->borderTopWidth(),
1583
topRight, startAngle, span, rc, style->color(), rs);
1585
if (!lowerRightBorderStylesMatch && bottomRight.hasBorderRadius()) {
1586
int x = _tx + w - bottomRight.horizontal;
1587
int y = _ty + h - bottomRight.vertical;
1588
int startAngle = 315;
1591
// Draw the bottom right arc
1592
drawBorderArc(p, x, y, style->borderRightWidth(), style->borderBottomWidth(),
1593
bottomRight, startAngle, span, rc, style->color(), rs);