| 672 | } |
| 673 | |
| 674 | void DocumentContainerPrivate::draw_background(litehtml::uint_ptr hdc, |
| 675 | const litehtml::background_paint &bg) |
| 676 | { |
| 677 | auto painter = toQPainter(hdc); |
| 678 | if (bg.is_root) { |
| 679 | // TODO ? |
| 680 | return; |
| 681 | } |
| 682 | painter->save(); |
| 683 | painter->setClipRect(toQRect(bg.clip_box)); |
| 684 | const QRegion horizontalMiddle( |
| 685 | QRect(bg.border_box.x, |
| 686 | bg.border_box.y + bg.border_radius.top_left_y, |
| 687 | bg.border_box.width, |
| 688 | bg.border_box.height - bg.border_radius.top_left_y - bg.border_radius.bottom_left_y)); |
| 689 | const QRegion horizontalTop( |
| 690 | QRect(bg.border_box.x + bg.border_radius.top_left_x, |
| 691 | bg.border_box.y, |
| 692 | bg.border_box.width - bg.border_radius.top_left_x - bg.border_radius.top_right_x, |
| 693 | bg.border_radius.top_left_y)); |
| 694 | const QRegion horizontalBottom(QRect(bg.border_box.x + bg.border_radius.bottom_left_x, |
| 695 | bg.border_box.bottom() - bg.border_radius.bottom_left_y, |
| 696 | bg.border_box.width - bg.border_radius.bottom_left_x |
| 697 | - bg.border_radius.bottom_right_x, |
| 698 | bg.border_radius.bottom_left_y)); |
| 699 | const QRegion topLeft(QRect(bg.border_box.left(), |
| 700 | bg.border_box.top(), |
| 701 | 2 * bg.border_radius.top_left_x, |
| 702 | 2 * bg.border_radius.top_left_y), |
| 703 | QRegion::Ellipse); |
| 704 | const QRegion topRight(QRect(bg.border_box.right() - 2 * bg.border_radius.top_right_x, |
| 705 | bg.border_box.top(), |
| 706 | 2 * bg.border_radius.top_right_x, |
| 707 | 2 * bg.border_radius.top_right_y), |
| 708 | QRegion::Ellipse); |
| 709 | const QRegion bottomLeft(QRect(bg.border_box.left(), |
| 710 | bg.border_box.bottom() - 2 * bg.border_radius.bottom_left_y, |
| 711 | 2 * bg.border_radius.bottom_left_x, |
| 712 | 2 * bg.border_radius.bottom_left_y), |
| 713 | QRegion::Ellipse); |
| 714 | const QRegion bottomRight(QRect(bg.border_box.right() - 2 * bg.border_radius.bottom_right_x, |
| 715 | bg.border_box.bottom() - 2 * bg.border_radius.bottom_right_y, |
| 716 | 2 * bg.border_radius.bottom_right_x, |
| 717 | 2 * bg.border_radius.bottom_right_y), |
| 718 | QRegion::Ellipse); |
| 719 | const QRegion clipRegion = horizontalMiddle.united(horizontalTop) |
| 720 | .united(horizontalBottom) |
| 721 | .united(topLeft) |
| 722 | .united(topRight) |
| 723 | .united(bottomLeft) |
| 724 | .united(bottomRight); |
| 725 | painter->setClipRegion(clipRegion, Qt::IntersectClip); |
| 726 | painter->setPen(Qt::NoPen); |
| 727 | painter->setBrush(toQColor(bg.color)); |
| 728 | painter->drawRect(bg.border_box.x, bg.border_box.y, bg.border_box.width, bg.border_box.height); |
| 729 | drawSelection(painter, toQRect(bg.border_box)); |
| 730 | if (!bg.image.empty()) { |
| 731 | const QPixmap pixmap = getPixmap(QString::fromStdString(bg.image), |