477
485
paintPageBorders(painter, coordinate, paintBorder, cell);
481
// The following code was commented out in the above function. I'll
482
// leave it here in case this functionality is ever re-implemented and
483
// someone wants some code to start from.
488
* Modification for drawing the button
490
if (d->style == Cell::ST_Button)
492
QBrush fill(Qt::lightGray);
493
QApplication::style().drawControl(QStyle::CE_PushButton, &_painter, this,
494
QRect(_tx + 1, _ty + 1, w2 - 1, h2 - 1),
495
defaultColorGroup); //, selected, &fill );
499
* Modification for drawing the combo box
501
else if (d->style == Cell::ST_Select)
503
QApplication::style().drawComboButton(&_painter, _tx + 1, _ty + 1,
505
defaultColorGroup, selected);
511
void CellView::paintCellHighlight(QPainter& painter,
512
const QPointF& coordinate,
513
const QPoint& cellRef,
514
const int highlightBorder,
515
const QPen& rightPen,
516
const QPen& bottomPen,
521
//painter.drawLine(coordinate.x(),coordinate.y(),coordinate.x() + d->width,coordinate.y() + d->height);
522
//QPen pen(cell.d->extra()->highlight);
523
//painter.setPen(highlightPen);
526
painter.setBrush(nullBrush);
528
QRect zoomedCellRect = cell.doc()->zoomRect(cellRect);
530
//The highlight rect is just inside the main cell rect
531
//This saves the hassle of repainting nearby cells when the highlight is changed as the highlight areas
533
zoomedCellRect.setLeft(zoomedCellRect.left() + 1);
534
//zoomedCellRect.setRight(zoomedCellRect.right()-1);
535
zoomedCellRect.setTop(zoomedCellRect.top() + 1);
536
//zoomedCellRect.setBottom(zoomedCellRect.bottom()-1);
538
if (cellRef.x() != KS_colMax)
539
zoomedCellRect.setWidth(zoomedCellRect.width() - 1);
540
if (cellRef.y() != KS_rowMax)
541
zoomedCellRect.setHeight(zoomedCellRect.height() - 1);
543
if (highlightBorder & Top) {
544
painter.setPen(topPen);
545
painter.drawLine(zoomedCellRect.left(), zoomedCellRect.top(), zoomedCellRect.right(), zoomedCellRect.top());
547
if (highlightBorder & Left) {
548
painter.setPen(leftPen);
549
painter.drawLine(zoomedCellRect.left(), zoomedCellRect.top(), zoomedCellRect.left(), zoomedCellRect.bottom());
551
if (highlightBorder & RightBorder) {
552
painter.setPen(rightPen);
553
painter.drawLine(zoomedCellRect.right(), zoomedCellRect.top(), zoomedCellRect.right(), zoomedCellRect.bottom());
555
if (highlightBorder & Bottom) {
556
painter.setPen(bottomPen);
557
painter.drawLine(zoomedCellRect.left(), zoomedCellRect.bottom(), zoomedCellRect.right(), zoomedCellRect.bottom());
560
if (highlightBorder & SizeGrip) {
561
QBrush brush(rightPen.color());
562
painter.setBrush(brush);
563
painter.setPen(rightPen);
564
painter.drawRect(zoomedCellRect.right() - 3, zoomedCellRect.bottom() - 3, 4, 4);
567
//painter.drawRect(zoomedCellRect.left(),zoomedCellRect.top(),zoomedCellRect.width(),zoomedCellRect.height());
572
489
// Paint the background of this cell.
1431
1339
painter.drawLine(line);
1434
// FIXME: Look very closely at when the following code is really needed.
1435
// I can't really see any case, but I might be wrong.
1436
// Since the code below is buggy, and incredibly complex,
1437
// I am currently disabling it. If somebody wants to enable
1438
// it again, then please also solve bug 68977: "Embedded KSpread
1439
// document printing problem" at the same time.
1443
// Look at the cells on our corners. It may happen that we
1444
// just erased parts of their borders corner, so we might need
1445
// to repaint these corners.
1447
QPen vert_pen, horz_pen;
1448
int vert_penWidth, horz_penWidth;
1450
// Some useful referenses.
1451
Cell *cell_north = Cell(cell.sheet(), cellRef.x(), cellRef.y() - 1);
1452
Cell *cell_northwest = Cell(cell.sheet(), cellRef.x() - 1, cellRef.y() - 1);
1453
Cell *cell_west = Cell(cell.sheet(), cellRef.x() - 1, cellRef.y());
1454
Cell *cell_northeast = Cell(cell.sheet(), cellRef.x() + 1, cellRef.y() - 1);
1455
Cell *cell_east = Cell(cell.sheet(), cellRef.x() + 1, cellRef.y());
1456
Cell *cell_south = Cell(cell.sheet(), cellRef.x(), cellRef.y() + 1);
1457
Cell *cell_southwest = Cell(cell.sheet(), cellRef.x() - 1, cellRef.y() + 1);
1458
Cell *cell_southeast = Cell(cell.sheet(), cellRef.x() + 1, cellRef.y() + 1);
1460
// Fix the borders which meet at the top left corner
1461
if (cell_north->effLeftBorderValue(cellRef.x(), cellRef.y() - 1)
1462
>= cell_northwest->effRightBorderValue(cellRef.x() - 1, cellRef.y() - 1))
1463
vert_pen = cell_north->effLeftBorderPen(cellRef.x(), cellRef.y() - 1);
1465
vert_pen = cell_northwest->effRightBorderPen(cellRef.x() - 1, cellRef.y() - 1);
1467
vert_penWidth = qMax(1, doc->zoomItXOld(vert_pen.width()));
1468
vert_pen.setWidth(vert_penWidth);
1470
if (vert_pen.style() != Qt::NoPen) {
1471
if (cell_west->effTopBorderValue(cellRef.x() - 1, cellRef.y())
1472
>= cell_northwest->effBottomBorderValue(cellRef.x() - 1, cellRef.y() - 1))
1473
horz_pen = cell_west->effTopBorderPen(cellRef.x() - 1, cellRef.y());
1475
horz_pen = cell_northwest->effBottomBorderPen(cellRef.x() - 1, cellRef.y() - 1);
1477
horz_penWidth = qMax(1, doc->zoomItYOld(horz_pen.width()));
1478
int bottom = (qMax(0, -1 + horz_penWidth)) / 2 + 1;
1480
painter.setPen(vert_pen);
1481
// If we are on paper printout, we limit the length of the lines.
1482
// On paper, we always have full cells, on screen not.
1483
if (dynamic_cast<QPrinter*>(painter.device())) {
1484
if (cell.sheet()->layoutDirection() == Qt::RightToLeft)
1485
painter.drawLine(qMax(rect.left(), coordinate.x() + d->width),
1486
qMax(rect.top(), coordinate.y()),
1487
qMin(rect.right(), coordinate.x() + d->width),
1488
qMin(rect.bottom(), coordinate.y() + bottom));
1490
painter.drawLine(qMax(rect.left(), coordinate.x()),
1491
qMax(rect.top(), coordinate.y()),
1492
qMin(rect.right(), coordinate.x()),
1493
qMin(rect.bottom(), coordinate.y() + bottom));
1495
if (cell.sheet()->layoutDirection() == Qt::RightToLeft)
1496
painter.drawLine(coordinate.x() + d->width, coordinate.y(),
1497
coordinate.x() + d->width, coordinate.y() + bottom);
1499
painter.drawLine(coordinate.x(), coordinate.y(),
1500
coordinate.x(), coordinate.y() + bottom);
1504
// Fix the borders which meet at the top right corner
1505
if (cell_north->effRightBorderValue(cellRef.x(), cellRef.y() - 1)
1506
>= cell_northeast->effLeftBorderValue(cellRef.x() + 1,
1508
vert_pen = cell_north->effRightBorderPen(cellRef.x(), cellRef.y() - 1);
1510
vert_pen = cell_northeast->effLeftBorderPen(cellRef.x() + 1,
1513
// vert_pen = effRightBorderPen( cellRef.x(), cellRef.y() - 1 );
1514
vert_penWidth = qMax(1, doc->zoomItXOld(vert_pen.width()));
1515
vert_pen.setWidth(vert_penWidth);
1516
if ((vert_pen.style() != Qt::NoPen) && (cellRef.x() < KS_colMax)) {
1517
if (cell_east->effTopBorderValue(cellRef.x() + 1, cellRef.y())
1518
>= cell_northeast->effBottomBorderValue(cellRef.x() + 1,
1520
horz_pen = cell_east->effTopBorderPen(cellRef.x() + 1, cellRef.y());
1522
horz_pen = cell_northeast->effBottomBorderPen(cellRef.x() + 1,
1525
// horz_pen = cell.effTopBorderPen( cellRef.x() + 1, cellRef.y() );
1526
horz_penWidth = qMax(1, doc->zoomItYOld(horz_pen.width()));
1527
int bottom = (qMax(0, -1 + horz_penWidth)) / 2 + 1;
1529
painter.setPen(vert_pen);
1530
//If we are on paper printout, we limit the length of the lines
1531
//On paper, we always have full cells, on screen not
1532
if (dynamic_cast<QPrinter*>(painter.device())) {
1533
if (cell.sheet()->layoutDirection() == Qt::RightToLeft)
1534
painter.drawLine(qMax(rect.left(), coordinate.x()),
1535
qMax(rect.top(), coordinate.y()),
1536
qMin(rect.right(), coordinate.x()),
1537
qMin(rect.bottom(), coordinate.y() + bottom));
1539
painter.drawLine(qMax(rect.left(), coordinate.x() + d->width),
1540
qMax(rect.top(), coordinate.y()),
1541
qMin(rect.right(), coordinate.x() + d->width),
1542
qMin(rect.bottom(), coordinate.y() + bottom));
1544
if (cell.sheet()->layoutDirection() == Qt::RightToLeft)
1545
painter.drawLine(coordinate.x(), coordinate.y(),
1546
coordinate.x(), coordinate.y() + bottom);
1548
painter.drawLine(coordinate.x() + d->width, coordinate.y(),
1549
coordinate.x() + d->width, coordinate.y() + bottom);
1554
if (cellRef.y() < KS_rowMax) {
1555
// Fix the borders which meet at the bottom left corner
1556
if (cell_south->effLeftBorderValue(cellRef.x(), cellRef.y() + 1)
1557
>= cell_southwest->effRightBorderValue(cellRef.x() - 1,
1559
vert_pen = cell_south->effLeftBorderPen(cellRef.x(), cellRef.y() + 1);
1561
vert_pen = cell_southwest->effRightBorderPen(cellRef.x() - 1,
1564
// vert_pen = effLeftBorderPen( cellRef.x(), cellRef.y() + 1 );
1565
vert_penWidth = qMax(1, doc->zoomItYOld(vert_pen.width()));
1566
vert_pen.setWidth(vert_penWidth);
1567
if (vert_pen.style() != Qt::NoPen) {
1568
if (cell_west->effBottomBorderValue(cellRef.x() - 1, cellRef.y())
1569
>= cell_southwest->effTopBorderValue(cellRef.x() - 1,
1571
horz_pen = cell_west->effBottomBorderPen(cellRef.x() - 1,
1574
horz_pen = cell_southwest->effTopBorderPen(cellRef.x() - 1,
1577
// horz_pen = cell.effBottomBorderPen( cellRef.x() - 1, cellRef.y() );
1578
horz_penWidth = qMax(1, doc->zoomItXOld(horz_pen.width()));
1579
int bottom = (qMax(0, -1 + horz_penWidth)) / 2;
1581
painter.setPen(vert_pen);
1582
// If we are on paper printout, we limit the length of the lines.
1583
// On paper, we always have full cells, on screen not.
1584
if (dynamic_cast<QPrinter*>(painter.device())) {
1585
if (cell.sheet()->layoutDirection() == Qt::RightToLeft)
1586
painter.drawLine(qMax(rect.left(), coordinate.x() + d->width),
1587
qMax(rect.top(), coordinate.y() + d->height - bottom),
1588
qMin(rect.right(), coordinate.x() + d->width),
1589
qMin(rect.bottom(), coordinate.y() + d->height));
1591
painter.drawLine(qMax(rect.left(), coordinate.x()),
1592
qMax(rect.top(), coordinate.y() + d->height - bottom),
1593
qMin(rect.right(), coordinate.x()),
1594
qMin(rect.bottom(), coordinate.y() + d->height));
1596
if (cell.sheet()->layoutDirection() == Qt::RightToLeft)
1597
painter.drawLine(coordinate.x() + d->width, coordinate.y() + d->height - bottom,
1598
coordinate.x() + d->width, coordinate.y() + d->height);
1600
painter.drawLine(coordinate.x(), coordinate.y() + d->height - bottom,
1601
coordinate.x(), coordinate.y() + d->height);
1605
// Fix the borders which meet at the bottom right corner
1606
if (cell_south->effRightBorderValue(cellRef.x(), cellRef.y() + 1)
1607
>= cell_southeast->effLeftBorderValue(cellRef.x() + 1, cellRef.y() + 1))
1608
vert_pen = cell_south->effRightBorderPen(cellRef.x(), cellRef.y() + 1);
1610
vert_pen = cell_southeast->effLeftBorderPen(cellRef.x() + 1, cellRef.y() + 1);
1612
// vert_pen = effRightBorderPen( cellRef.x(), cellRef.y() + 1 );
1613
vert_penWidth = qMax(1, doc->zoomItYOld(vert_pen.width()));
1614
vert_pen.setWidth(vert_penWidth);
1615
if ((vert_pen.style() != Qt::NoPen) && (cellRef.x() < KS_colMax)) {
1616
if (cell_east ->effBottomBorderValue(cellRef.x() + 1, cellRef.y())
1617
>= cell_southeast->effTopBorderValue(cellRef.x() + 1,
1620
horz_pen = Cell(cell.sheet(), cellRef.x() + 1, cellRef.y())
1621
->effBottomBorderPen(cellRef.x() + 1, cellRef.y());
1623
horz_pen = Cell(cell.sheet(), cellRef.x() + 1, cellRef.y() + 1)
1624
->effTopBorderPen(cellRef.x() + 1, cellRef.y() + 1);
1626
// horz_pen = cell.effBottomBorderPen( cellRef.x() + 1, cellRef.y() );
1627
horz_penWidth = qMax(1, doc->zoomItXOld(horz_pen.width()));
1628
int bottom = (qMax(0, -1 + horz_penWidth)) / 2;
1630
painter.setPen(vert_pen);
1631
// If we are on paper printout, we limit the length of the lines.
1632
// On paper, we always have full cells, on screen not.
1633
if (dynamic_cast<QPrinter*>(painter.device())) {
1634
if (cell.sheet()->layoutDirection() == Qt::RightToLeft)
1635
painter.drawLine(qMax(rect.left(), coordinate.x()),
1636
qMax(rect.top(), coordinate.y() + d->height - bottom),
1637
qMin(rect.right(), coordinate.x()),
1638
qMin(rect.bottom(), coordinate.y() + d->height));
1640
painter.drawLine(qMax(rect.left(), coordinate.x() + d->width),
1641
qMax(rect.top(), coordinate.y() + d->height - bottom),
1642
qMin(rect.right(), coordinate.x() + d->width),
1643
qMin(rect.bottom(), coordinate.y() + d->height));
1645
if (cell.sheet()->layoutDirection() == Qt::RightToLeft)
1646
painter.drawLine(coordinate.x(), coordinate.y() + d->height - bottom,
1647
coordinate.x(), coordinate.y() + d->height);
1649
painter.drawLine(coordinate.x() + d->width, coordinate.y() + d->height - bottom,
1650
coordinate.x() + d->width, coordinate.y() + d->height);