1/****************************************************************************
2**
3** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
4** Contact: http://www.qt-project.org/legal
5**
6** This file is part of the QtGui 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 Digia. For licensing terms and
14** conditions see http://qt.digia.com/licensing. For further information
15** use the contact form at http://qt.digia.com/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 2.1 as published by the Free Software
20** Foundation and appearing in the file LICENSE.LGPL included in the
21** packaging of this file. Please review the following information to
22** ensure the GNU Lesser General Public License version 2.1 requirements
23** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24**
25** In addition, as a special exception, Digia gives you certain additional
26** rights. These rights are described in the Digia Qt LGPL Exception
27** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
28**
29** GNU General Public License Usage
30** Alternatively, this file may be used under the terms of the GNU
31** General Public License version 3.0 as published by the Free Software
32** Foundation and appearing in the file LICENSE.GPL included in the
33** packaging of this file. Please review the following information to
34** ensure the GNU General Public License version 3.0 requirements will be
35** met: http://www.gnu.org/copyleft/gpl.html.
36**
37**
38** $QT_END_LICENSE$
39**
40****************************************************************************/
41
42#ifndef QDRAWUTIL_H
43#define QDRAWUTIL_H
44
45#include <QtCore/qnamespace.h>
46#include <QtCore/qstring.h> // char*->QString conversion
47#include <QtCore/qmargins.h>
48#include <QtGui/qpixmap.h>
49QT_BEGIN_HEADER
50
51QT_BEGIN_NAMESPACE
52
53QT_MODULE(Gui)
54
55class QPainter;
56#ifndef QT3_SUPPORT
57class QColorGroup;
58#endif
59class QPalette;
60class QPoint;
61class QColor;
62class QBrush;
63class QRect;
64
65//
66// Standard shade drawing
67//
68
69Q_GUI_EXPORT void qDrawShadeLine(QPainter *p, int x1, int y1, int x2, int y2,
70 const QPalette &pal, bool sunken = true,
71 int lineWidth = 1, int midLineWidth = 0);
72
73Q_GUI_EXPORT void qDrawShadeLine(QPainter *p, const QPoint &p1, const QPoint &p2,
74 const QPalette &pal, bool sunken = true,
75 int lineWidth = 1, int midLineWidth = 0);
76
77Q_GUI_EXPORT void qDrawShadeRect(QPainter *p, int x, int y, int w, int h,
78 const QPalette &pal, bool sunken = false,
79 int lineWidth = 1, int midLineWidth = 0,
80 const QBrush *fill = 0);
81
82Q_GUI_EXPORT void qDrawShadeRect(QPainter *p, const QRect &r,
83 const QPalette &pal, bool sunken = false,
84 int lineWidth = 1, int midLineWidth = 0,
85 const QBrush *fill = 0);
86
87Q_GUI_EXPORT void qDrawShadePanel(QPainter *p, int x, int y, int w, int h,
88 const QPalette &pal, bool sunken = false,
89 int lineWidth = 1, const QBrush *fill = 0);
90
91Q_GUI_EXPORT void qDrawShadePanel(QPainter *p, const QRect &r,
92 const QPalette &pal, bool sunken = false,
93 int lineWidth = 1, const QBrush *fill = 0);
94
95Q_GUI_EXPORT void qDrawWinButton(QPainter *p, int x, int y, int w, int h,
96 const QPalette &pal, bool sunken = false,
97 const QBrush *fill = 0);
98
99Q_GUI_EXPORT void qDrawWinButton(QPainter *p, const QRect &r,
100 const QPalette &pal, bool sunken = false,
101 const QBrush *fill = 0);
102
103Q_GUI_EXPORT void qDrawWinPanel(QPainter *p, int x, int y, int w, int h,
104 const QPalette &pal, bool sunken = false,
105 const QBrush *fill = 0);
106
107Q_GUI_EXPORT void qDrawWinPanel(QPainter *p, const QRect &r,
108 const QPalette &pal, bool sunken = false,
109 const QBrush *fill = 0);
110
111Q_GUI_EXPORT void qDrawPlainRect(QPainter *p, int x, int y, int w, int h, const QColor &,
112 int lineWidth = 1, const QBrush *fill = 0);
113
114Q_GUI_EXPORT void qDrawPlainRect(QPainter *p, const QRect &r, const QColor &,
115 int lineWidth = 1, const QBrush *fill = 0);
116
117
118#ifdef QT3_SUPPORT
119//
120// Use QStyle::itemRect(), QStyle::drawItem() and QStyle::drawArrow() instead.
121//
122Q_GUI_EXPORT QT3_SUPPORT QRect qItemRect(QPainter *p, Qt::GUIStyle gs, int x, int y, int w, int h,
123 int flags, bool enabled,
124 const QPixmap *pixmap, const QString& text, int len=-1);
125
126Q_GUI_EXPORT QT3_SUPPORT void qDrawItem(QPainter *p, Qt::GUIStyle gs, int x, int y, int w, int h,
127 int flags, const QPalette &pal, bool enabled,
128 const QPixmap *pixmap, const QString& text,
129 int len=-1, const QColor* penColor = 0);
130
131Q_GUI_EXPORT QT3_SUPPORT void qDrawArrow(QPainter *p, Qt::ArrowType type, Qt::GUIStyle style, bool down,
132 int x, int y, int w, int h,
133 const QPalette &pal, bool enabled);
134#endif
135
136struct QTileRules
137{
138 inline QTileRules(Qt::TileRule horizontalRule, Qt::TileRule verticalRule)
139 : horizontal(horizontalRule), vertical(verticalRule) {}
140 inline QTileRules(Qt::TileRule rule = Qt::StretchTile)
141 : horizontal(rule), vertical(rule) {}
142 Qt::TileRule horizontal;
143 Qt::TileRule vertical;
144};
145
146#ifndef Q_QDOC
147// For internal use only.
148namespace QDrawBorderPixmap
149{
150 enum DrawingHint
151 {
152 OpaqueTopLeft = 0x0001,
153 OpaqueTop = 0x0002,
154 OpaqueTopRight = 0x0004,
155 OpaqueLeft = 0x0008,
156 OpaqueCenter = 0x0010,
157 OpaqueRight = 0x0020,
158 OpaqueBottomLeft = 0x0040,
159 OpaqueBottom = 0x0080,
160 OpaqueBottomRight = 0x0100,
161 OpaqueCorners = OpaqueTopLeft | OpaqueTopRight | OpaqueBottomLeft | OpaqueBottomRight,
162 OpaqueEdges = OpaqueTop | OpaqueLeft | OpaqueRight | OpaqueBottom,
163 OpaqueFrame = OpaqueCorners | OpaqueEdges,
164 OpaqueAll = OpaqueCenter | OpaqueFrame
165 };
166
167 Q_DECLARE_FLAGS(DrawingHints, DrawingHint)
168}
169#endif
170
171Q_GUI_EXPORT void qDrawBorderPixmap(QPainter *painter,
172 const QRect &targetRect,
173 const QMargins &targetMargins,
174 const QPixmap &pixmap,
175 const QRect &sourceRect,
176 const QMargins &sourceMargins,
177 const QTileRules &rules = QTileRules()
178#ifndef Q_QDOC
179 , QDrawBorderPixmap::DrawingHints hints = 0
180#endif
181 );
182
183inline void qDrawBorderPixmap(QPainter *painter,
184 const QRect &target,
185 const QMargins &margins,
186 const QPixmap &pixmap)
187{
188 qDrawBorderPixmap(painter, target, margins, pixmap, pixmap.rect(), margins);
189}
190
191QT_END_NAMESPACE
192
193QT_END_HEADER
194
195#endif // QDRAWUTIL_H
196