1 | // Copyright (C) 2020 The Qt Company Ltd. |
2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only |
3 | |
4 | #include "qquickstyleitemframe.h" |
5 | |
6 | QT_BEGIN_NAMESPACE |
7 | |
8 | StyleItemGeometry QQuickStyleItemFrame::calculateGeometry() |
9 | { |
10 | QStyleOptionFrame styleOption; |
11 | initStyleOption(styleOption); |
12 | StyleItemGeometry geometry; |
13 | |
14 | geometry.minimumSize = style()->sizeFromContents(ct: QStyle::CT_Frame, opt: &styleOption, contentsSize: QSize(0, 0)); |
15 | geometry.implicitSize = contentSize(); |
16 | styleOption.rect = QRect(QPoint(0, 0), geometry.implicitSize); |
17 | geometry.contentRect = style()->subElementRect(subElement: QStyle::SE_FrameContents, option: &styleOption); |
18 | geometry.ninePatchMargins = style()->ninePatchMargins(ce: QStyle::CE_ShapedFrame, opt: &styleOption, imageSize: geometry.minimumSize); |
19 | |
20 | return geometry; |
21 | } |
22 | |
23 | void QQuickStyleItemFrame::paintEvent(QPainter *painter) const |
24 | { |
25 | QStyleOptionFrame styleOption; |
26 | initStyleOption(styleOption); |
27 | style()->drawControl(element: QStyle::CE_ShapedFrame, opt: &styleOption, p: painter); |
28 | } |
29 | |
30 | void QQuickStyleItemFrame::initStyleOption(QStyleOptionFrame &styleOption) const |
31 | { |
32 | initStyleOptionBase(styleOption); |
33 | styleOption.lineWidth = 1; |
34 | styleOption.frameShape = QStyleOptionFrame::StyledPanel; |
35 | styleOption.features = QStyleOptionFrame::Flat; |
36 | } |
37 | |
38 | QT_END_NAMESPACE |
39 | |
40 | #include "moc_qquickstyleitemframe.cpp" |
41 | |