1/****************************************************************************
2**
3** Copyright (C) 2016 The Qt Company Ltd.
4** Contact: https://www.qt.io/licensing/
5**
6** This file is part of the QtWidgets module of the Qt Toolkit.
7**
8** $QT_BEGIN_LICENSE:LGPL$
9** Commercial License Usage
10** Licensees holding valid commercial Qt licenses may use this file in
11** accordance with the commercial license agreement provided with the
12** Software or, alternatively, in accordance with the terms contained in
13** a written agreement between you and The Qt Company. For licensing terms
14** and conditions see https://www.qt.io/terms-conditions. For further
15** information use the contact form at https://www.qt.io/contact-us.
16**
17** GNU Lesser General Public License Usage
18** Alternatively, this file may be used under the terms of the GNU Lesser
19** General Public License version 3 as published by the Free Software
20** Foundation and appearing in the file LICENSE.LGPL3 included in the
21** packaging of this file. Please review the following information to
22** ensure the GNU Lesser General Public License version 3 requirements
23** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
24**
25** GNU General Public License Usage
26** Alternatively, this file may be used under the terms of the GNU
27** General Public License version 2.0 or (at your option) the GNU General
28** Public license version 3 or any later version approved by the KDE Free
29** Qt Foundation. The licenses are as published by the Free Software
30** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
31** included in the packaging of this file. Please review the following
32** information to ensure the GNU General Public License requirements will
33** be met: https://www.gnu.org/licenses/gpl-2.0.html and
34** https://www.gnu.org/licenses/gpl-3.0.html.
35**
36** $QT_END_LICENSE$
37**
38****************************************************************************/
39
40#ifndef QDRAWUTIL_H
41#define QDRAWUTIL_H
42
43#include <QtWidgets/qtwidgetsglobal.h>
44#include <QtCore/qnamespace.h>
45#include <QtCore/qstring.h> // char*->QString conversion
46#include <QtCore/qmargins.h>
47#include <QtGui/qpixmap.h>
48QT_BEGIN_NAMESPACE
49
50
51class QPainter;
52class QPalette;
53class QPoint;
54class QColor;
55class QBrush;
56class QRect;
57
58//
59// Standard shade drawing
60//
61
62Q_WIDGETS_EXPORT void qDrawShadeLine(QPainter *p, int x1, int y1, int x2, int y2,
63 const QPalette &pal, bool sunken = true,
64 int lineWidth = 1, int midLineWidth = 0);
65
66Q_WIDGETS_EXPORT void qDrawShadeLine(QPainter *p, const QPoint &p1, const QPoint &p2,
67 const QPalette &pal, bool sunken = true,
68 int lineWidth = 1, int midLineWidth = 0);
69
70Q_WIDGETS_EXPORT void qDrawShadeRect(QPainter *p, int x, int y, int w, int h,
71 const QPalette &pal, bool sunken = false,
72 int lineWidth = 1, int midLineWidth = 0,
73 const QBrush *fill = nullptr);
74
75Q_WIDGETS_EXPORT void qDrawShadeRect(QPainter *p, const QRect &r,
76 const QPalette &pal, bool sunken = false,
77 int lineWidth = 1, int midLineWidth = 0,
78 const QBrush *fill = nullptr);
79
80Q_WIDGETS_EXPORT void qDrawShadePanel(QPainter *p, int x, int y, int w, int h,
81 const QPalette &pal, bool sunken = false,
82 int lineWidth = 1, const QBrush *fill = nullptr);
83
84Q_WIDGETS_EXPORT void qDrawShadePanel(QPainter *p, const QRect &r,
85 const QPalette &pal, bool sunken = false,
86 int lineWidth = 1, const QBrush *fill = nullptr);
87
88Q_WIDGETS_EXPORT void qDrawWinButton(QPainter *p, int x, int y, int w, int h,
89 const QPalette &pal, bool sunken = false,
90 const QBrush *fill = nullptr);
91
92Q_WIDGETS_EXPORT void qDrawWinButton(QPainter *p, const QRect &r,
93 const QPalette &pal, bool sunken = false,
94 const QBrush *fill = nullptr);
95
96Q_WIDGETS_EXPORT void qDrawWinPanel(QPainter *p, int x, int y, int w, int h,
97 const QPalette &pal, bool sunken = false,
98 const QBrush *fill = nullptr);
99
100Q_WIDGETS_EXPORT void qDrawWinPanel(QPainter *p, const QRect &r,
101 const QPalette &pal, bool sunken = false,
102 const QBrush *fill = nullptr);
103
104Q_WIDGETS_EXPORT void qDrawPlainRect(QPainter *p, int x, int y, int w, int h, const QColor &,
105 int lineWidth = 1, const QBrush *fill = nullptr);
106
107Q_WIDGETS_EXPORT void qDrawPlainRect(QPainter *p, const QRect &r, const QColor &,
108 int lineWidth = 1, const QBrush *fill = nullptr);
109
110
111
112struct QTileRules
113{
114 inline QTileRules(Qt::TileRule horizontalRule, Qt::TileRule verticalRule)
115 : horizontal(horizontalRule), vertical(verticalRule) {}
116 inline QTileRules(Qt::TileRule rule = Qt::StretchTile)
117 : horizontal(rule), vertical(rule) {}
118 Qt::TileRule horizontal;
119 Qt::TileRule vertical;
120};
121
122#ifndef Q_CLANG_QDOC
123// For internal use only.
124namespace QDrawBorderPixmap
125{
126 enum DrawingHint
127 {
128 OpaqueTopLeft = 0x0001,
129 OpaqueTop = 0x0002,
130 OpaqueTopRight = 0x0004,
131 OpaqueLeft = 0x0008,
132 OpaqueCenter = 0x0010,
133 OpaqueRight = 0x0020,
134 OpaqueBottomLeft = 0x0040,
135 OpaqueBottom = 0x0080,
136 OpaqueBottomRight = 0x0100,
137 OpaqueCorners = OpaqueTopLeft | OpaqueTopRight | OpaqueBottomLeft | OpaqueBottomRight,
138 OpaqueEdges = OpaqueTop | OpaqueLeft | OpaqueRight | OpaqueBottom,
139 OpaqueFrame = OpaqueCorners | OpaqueEdges,
140 OpaqueAll = OpaqueCenter | OpaqueFrame
141 };
142
143 Q_DECLARE_FLAGS(DrawingHints, DrawingHint)
144}
145#endif
146
147Q_WIDGETS_EXPORT void qDrawBorderPixmap(QPainter *painter,
148 const QRect &targetRect,
149 const QMargins &targetMargins,
150 const QPixmap &pixmap,
151 const QRect &sourceRect,
152 const QMargins &sourceMargins,
153 const QTileRules &rules = QTileRules()
154#ifndef Q_CLANG_QDOC
155 , QDrawBorderPixmap::DrawingHints hints = QDrawBorderPixmap::DrawingHints()
156#endif
157 );
158
159inline void qDrawBorderPixmap(QPainter *painter,
160 const QRect &target,
161 const QMargins &margins,
162 const QPixmap &pixmap)
163{
164 qDrawBorderPixmap(painter, targetRect: target, targetMargins: margins, pixmap, sourceRect: pixmap.rect(), sourceMargins: margins);
165}
166
167QT_END_NAMESPACE
168
169#endif // QDRAWUTIL_H
170

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