Qt 4.8
qdrawutil.h
Go to the documentation of this file.
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>
50 
52 
53 QT_MODULE(Gui)
54 
55 class QPainter;
56 #ifndef QT3_SUPPORT
57 class QColorGroup;
58 #endif
59 class QPalette;
60 class QPoint;
61 class QColor;
62 class QBrush;
63 class QRect;
64 
65 //
66 // Standard shade drawing
67 //
68 
69 Q_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 
73 Q_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 
77 Q_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 
82 Q_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 
87 Q_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 
91 Q_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 
95 Q_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 
99 Q_GUI_EXPORT void qDrawWinButton(QPainter *p, const QRect &r,
100  const QPalette &pal, bool sunken = false,
101  const QBrush *fill = 0);
102 
103 Q_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 
107 Q_GUI_EXPORT void qDrawWinPanel(QPainter *p, const QRect &r,
108  const QPalette &pal, bool sunken = false,
109  const QBrush *fill = 0);
110 
111 Q_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 
114 Q_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 //
122 Q_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 
126 Q_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 
131 Q_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 
137 {
138  inline QTileRules(Qt::TileRule horizontalRule, Qt::TileRule verticalRule)
139  : horizontal(horizontalRule), vertical(verticalRule) {}
141  : horizontal(rule), vertical(rule) {}
144 };
145 
146 #ifndef Q_QDOC
147 // For internal use only.
148 namespace 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 
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 
183 inline 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 
192 
194 
195 #endif // QDRAWUTIL_H
The QPainter class performs low-level painting on widgets and other paint devices.
Definition: qpainter.h:86
The QColor class provides colors based on RGB, HSV or CMYK values.
Definition: qcolor.h:67
int type
Definition: qmetatype.cpp:239
Q_GUI_EXPORT void qDrawBorderPixmap(QPainter *painter, const QRect &targetRect, const QMargins &targetMargins, const QPixmap &pixmap, const QRect &sourceRect, const QMargins &sourceMargins, const QTileRules &rules=QTileRules())
#define QT_END_NAMESPACE
This macro expands to.
Definition: qglobal.h:90
#define QT_MODULE(x)
Definition: qglobal.h:2783
int y1
Definition: qrect.h:177
#define QT_BEGIN_HEADER
Definition: qglobal.h:136
#define Q_DECLARE_FLAGS(Flags, Enum)
The Q_DECLARE_FLAGS() macro expands to.
Definition: qglobal.h:2348
TileRule
Definition: qnamespace.h:198
#define Q_GUI_EXPORT
Definition: qglobal.h:1450
int y2
Definition: qrect.h:179
QTileRules(Qt::TileRule horizontalRule, Qt::TileRule verticalRule)
Constructs a QTileRules with the given horizontalRule and verticalRule.
Definition: qdrawutil.h:138
QTileRules(Qt::TileRule rule=Qt::StretchTile)
Constructs a QTileRules with the given rule used for both the horizontal rule and the vertical rule...
Definition: qdrawutil.h:140
The QString class provides a Unicode character string.
Definition: qstring.h:83
Q_GUI_EXPORT void qDrawShadePanel(QPainter *p, int x, int y, int w, int h, const QPalette &pal, bool sunken=false, int lineWidth=1, const QBrush *fill=0)
Definition: qdrawutil.cpp:303
Q_GUI_EXPORT void qDrawShadeRect(QPainter *p, int x, int y, int w, int h, const QPalette &pal, bool sunken=false, int lineWidth=1, int midLineWidth=0, const QBrush *fill=0)
Definition: qdrawutil.cpp:204
Qt::TileRule vertical
Definition: qdrawutil.h:143
#define QT_BEGIN_NAMESPACE
This macro expands to.
Definition: qglobal.h:89
Q_GUI_EXPORT void qDrawWinPanel(QPainter *p, int x, int y, int w, int h, const QPalette &pal, bool sunken=false, const QBrush *fill=0)
Definition: qdrawutil.cpp:475
Q_GUI_EXPORT void qDrawPlainRect(QPainter *p, int x, int y, int w, int h, const QColor &, int lineWidth=1, const QBrush *fill=0)
Definition: qdrawutil.cpp:511
The QBrush class defines the fill pattern of shapes drawn by QPainter.
Definition: qbrush.h:76
Qt::TileRule horizontal
Definition: qdrawutil.h:142
int y() const
Returns the y-coordinate of the rectangle&#39;s top edge.
Definition: qrect.h:255
Holds the rules used to draw a pixmap or image split into nine segments, similar to [CSS3 border-imag...
Definition: qdrawutil.h:136
int x() const
Returns the x-coordinate of the rectangle&#39;s left edge.
Definition: qrect.h:252
The QPoint class defines a point in the plane using integer precision.
Definition: qpoint.h:53
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
The QColorGroup class contains color groups for each widget state.
QRect rect() const
Returns the pixmap&#39;s enclosing rectangle.
Definition: qpixmap.cpp:676
The QPixmap class is an off-screen image representation that can be used as a paint device...
Definition: qpixmap.h:71
int x2
Definition: qrect.h:180
The QMargins class defines the four margins of a rectangle.
Definition: qmargins.h:53
int x1
Definition: qrect.h:178
Q_GUI_EXPORT void qDrawWinButton(QPainter *p, int x, int y, int w, int h, const QPalette &pal, bool sunken=false, const QBrush *fill=0)
Definition: qdrawutil.cpp:435
#define QT_END_HEADER
Definition: qglobal.h:137
Q_GUI_EXPORT void qDrawShadeLine(QPainter *p, int x1, int y1, int x2, int y2, const QPalette &pal, bool sunken=true, int lineWidth=1, int midLineWidth=0)
Definition: qdrawutil.cpp:93
#define enabled
#define text
Definition: qobjectdefs.h:80
ArrowType
Definition: qnamespace.h:1126
The QPalette class contains color groups for each widget state.
Definition: qpalette.h:61