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

source code of qtbase/src/widgets/styles/qdrawutil.h