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#ifndef QDRAWUTIL_H
5#define QDRAWUTIL_H
6
7#include <QtCore/qnamespace.h>
8#include <QtCore/qstring.h> // char*->QString conversion
9#include <QtCore/qmargins.h>
10#include <QtGui/qpixmap.h>
11
12QT_BEGIN_NAMESPACE
13
14
15class QPainter;
16class QPalette;
17class QPoint;
18class QColor;
19class QBrush;
20class QRect;
21
22namespace QQC2 {
23
24//
25// Standard shade drawing
26//
27
28void qDrawShadeLine(QPainter *p, int x1, int y1, int x2, int y2,
29 const QPalette &pal, bool sunken = true,
30 int lineWidth = 1, int midLineWidth = 0);
31
32void qDrawShadeLine(QPainter *p, const QPoint &p1, const QPoint &p2,
33 const QPalette &pal, bool sunken = true,
34 int lineWidth = 1, int midLineWidth = 0);
35
36void qDrawShadeRect(QPainter *p, int x, int y, int w, int h,
37 const QPalette &pal, bool sunken = false,
38 int lineWidth = 1, int midLineWidth = 0,
39 const QBrush *fill = nullptr);
40
41void qDrawShadeRect(QPainter *p, const QRect &r,
42 const QPalette &pal, bool sunken = false,
43 int lineWidth = 1, int midLineWidth = 0,
44 const QBrush *fill = nullptr);
45
46void qDrawShadePanel(QPainter *p, int x, int y, int w, int h,
47 const QPalette &pal, bool sunken = false,
48 int lineWidth = 1, const QBrush *fill = nullptr);
49
50void qDrawShadePanel(QPainter *p, const QRect &r,
51 const QPalette &pal, bool sunken = false,
52 int lineWidth = 1, const QBrush *fill = nullptr);
53
54void qDrawWinButton(QPainter *p, int x, int y, int w, int h,
55 const QPalette &pal, bool sunken = false,
56 const QBrush *fill = nullptr);
57
58void qDrawWinButton(QPainter *p, const QRect &r,
59 const QPalette &pal, bool sunken = false,
60 const QBrush *fill = nullptr);
61
62void qDrawWinPanel(QPainter *p, int x, int y, int w, int h,
63 const QPalette &pal, bool sunken = false,
64 const QBrush *fill = nullptr);
65
66void qDrawWinPanel(QPainter *p, const QRect &r,
67 const QPalette &pal, bool sunken = false,
68 const QBrush *fill = nullptr);
69
70void qDrawPlainRect(QPainter *p, int x, int y, int w, int h, const QColor &,
71 int lineWidth = 1, const QBrush *fill = nullptr);
72
73void qDrawPlainRect(QPainter *p, const QRect &r, const QColor &,
74 int lineWidth = 1, const QBrush *fill = nullptr);
75
76
77
78struct QTileRules
79{
80 inline QTileRules(Qt::TileRule horizontalRule, Qt::TileRule verticalRule)
81 : horizontal(horizontalRule), vertical(verticalRule) {}
82 inline QTileRules(Qt::TileRule rule = Qt::StretchTile)
83 : horizontal(rule), vertical(rule) {}
84 Qt::TileRule horizontal;
85 Qt::TileRule vertical;
86};
87
88#ifndef Q_QDOC
89// For internal use only.
90namespace QDrawBorderPixmap
91{
92 enum DrawingHint
93 {
94 OpaqueTopLeft = 0x0001,
95 OpaqueTop = 0x0002,
96 OpaqueTopRight = 0x0004,
97 OpaqueLeft = 0x0008,
98 OpaqueCenter = 0x0010,
99 OpaqueRight = 0x0020,
100 OpaqueBottomLeft = 0x0040,
101 OpaqueBottom = 0x0080,
102 OpaqueBottomRight = 0x0100,
103 OpaqueCorners = OpaqueTopLeft | OpaqueTopRight | OpaqueBottomLeft | OpaqueBottomRight,
104 OpaqueEdges = OpaqueTop | OpaqueLeft | OpaqueRight | OpaqueBottom,
105 OpaqueFrame = OpaqueCorners | OpaqueEdges,
106 OpaqueAll = OpaqueCenter | OpaqueFrame
107 };
108
109 Q_DECLARE_FLAGS(DrawingHints, DrawingHint)
110}
111#endif
112
113void qDrawBorderPixmap(QPainter *painter,
114 const QRect &targetRect,
115 const QMargins &targetMargins,
116 const QPixmap &pixmap,
117 const QRect &sourceRect,
118 const QMargins &sourceMargins,
119 const QTileRules &rules = QTileRules()
120#ifndef Q_QDOC
121 , QDrawBorderPixmap::DrawingHints hints = QDrawBorderPixmap::DrawingHints()
122#endif
123 );
124
125inline void qDrawBorderPixmap(QPainter *painter,
126 const QRect &target,
127 const QMargins &margins,
128 const QPixmap &pixmap)
129{
130 qDrawBorderPixmap(painter, targetRect: target, targetMargins: margins, pixmap, sourceRect: pixmap.rect(), sourceMargins: margins);
131}
132
133} // namespace QQC2
134
135QT_END_NAMESPACE
136
137#endif // QDRAWUTIL_H
138

source code of qtdeclarative/src/quicknativestyle/qstyle/qquickdrawutil.h