qdrawutil.h

Go to the documentation of this file.
00001 /****************************************************************************
00002 **
00003 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
00004 ** All rights reserved.
00005 ** Contact: Nokia Corporation (qt-info@nokia.com)
00006 **
00007 ** This file is part of the QtGui module of the Qt Toolkit.
00008 **
00009 ** $QT_BEGIN_LICENSE:LGPL$
00010 ** Commercial Usage
00011 ** Licensees holding valid Qt Commercial licenses may use this file in
00012 ** accordance with the Qt Commercial License Agreement provided with the
00013 ** Software or, alternatively, in accordance with the terms contained in
00014 ** a written agreement between you and Nokia.
00015 **
00016 ** GNU Lesser General Public License Usage
00017 ** Alternatively, this file may be used under the terms of the GNU Lesser
00018 ** General Public License version 2.1 as published by the Free Software
00019 ** Foundation and appearing in the file LICENSE.LGPL included in the
00020 ** packaging of this file.  Please review the following information to
00021 ** ensure the GNU Lesser General Public License version 2.1 requirements
00022 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
00023 **
00024 ** In addition, as a special exception, Nokia gives you certain additional
00025 ** rights.  These rights are described in the Nokia Qt LGPL Exception
00026 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this module.
00027 **
00028 ** GNU General Public License Usage
00029 ** Alternatively, this file may be used under the terms of the GNU
00030 ** General Public License version 3.0 as published by the Free Software
00031 ** Foundation and appearing in the file LICENSE.GPL included in the
00032 ** packaging of this file.  Please review the following information to
00033 ** ensure the GNU General Public License version 3.0 requirements will be
00034 ** met: http://www.gnu.org/copyleft/gpl.html.
00035 **
00036 ** If you have questions regarding the use of this file, please contact
00037 ** Nokia at qt-info@nokia.com.
00038 ** $QT_END_LICENSE$
00039 **
00040 ****************************************************************************/
00041 
00042 #ifndef QDRAWUTIL_H
00043 #define QDRAWUTIL_H
00044 
00045 #include <QtCore/qnamespace.h>
00046 #include <QtCore/qstring.h> // char*->QString conversion
00047 #include <QtCore/qmargins.h>
00048 #include <QtGui/qpixmap.h>
00049 QT_BEGIN_HEADER
00050 
00051 QT_BEGIN_NAMESPACE
00052 
00053 QT_MODULE(Gui)
00054 
00055 class QPainter;
00056 #ifndef QT3_SUPPORT
00057 class QColorGroup;
00058 #endif
00059 class QPalette;
00060 class QPoint;
00061 class QColor;
00062 class QBrush;
00063 class QRect;
00064 
00065 //
00066 // Standard shade drawing
00067 //
00068 
00069 Q_GUI_EXPORT void qDrawShadeLine(QPainter *p, int x1, int y1, int x2, int y2,
00070                               const QPalette &pal, bool sunken = true,
00071                               int lineWidth = 1, int midLineWidth = 0);
00072 
00073 Q_GUI_EXPORT void qDrawShadeLine(QPainter *p, const QPoint &p1, const QPoint &p2,
00074                               const QPalette &pal, bool sunken = true,
00075                               int lineWidth = 1, int midLineWidth = 0);
00076 
00077 Q_GUI_EXPORT void qDrawShadeRect(QPainter *p, int x, int y, int w, int h,
00078                               const QPalette &pal, bool sunken = false,
00079                               int lineWidth = 1, int midLineWidth = 0,
00080                               const QBrush *fill = 0);
00081 
00082 Q_GUI_EXPORT void qDrawShadeRect(QPainter *p, const QRect &r,
00083                               const QPalette &pal, bool sunken = false,
00084                               int lineWidth = 1, int midLineWidth = 0,
00085                               const QBrush *fill = 0);
00086 
00087 Q_GUI_EXPORT void qDrawShadePanel(QPainter *p, int x, int y, int w, int h,
00088                                const QPalette &pal, bool sunken = false,
00089                                int lineWidth = 1, const QBrush *fill = 0);
00090 
00091 Q_GUI_EXPORT void qDrawShadePanel(QPainter *p, const QRect &r,
00092                                const QPalette &pal, bool sunken = false,
00093                                int lineWidth = 1, const QBrush *fill = 0);
00094 
00095 Q_GUI_EXPORT void qDrawWinButton(QPainter *p, int x, int y, int w, int h,
00096                               const QPalette &pal, bool sunken = false,
00097                               const QBrush *fill = 0);
00098 
00099 Q_GUI_EXPORT void qDrawWinButton(QPainter *p, const QRect &r,
00100                               const QPalette &pal, bool sunken = false,
00101                               const QBrush *fill = 0);
00102 
00103 Q_GUI_EXPORT void qDrawWinPanel(QPainter *p, int x, int y, int w, int h,
00104                               const QPalette &pal, bool sunken = false,
00105                              const QBrush *fill = 0);
00106 
00107 Q_GUI_EXPORT void qDrawWinPanel(QPainter *p, const QRect &r,
00108                               const QPalette &pal, bool sunken = false,
00109                              const QBrush *fill = 0);
00110 
00111 Q_GUI_EXPORT void qDrawPlainRect(QPainter *p, int x, int y, int w, int h, const QColor &,
00112                               int lineWidth = 1, const QBrush *fill = 0);
00113 
00114 Q_GUI_EXPORT void qDrawPlainRect(QPainter *p, const QRect &r, const QColor &,
00115                               int lineWidth = 1, const QBrush *fill = 0);
00116 
00117 
00118 #ifdef QT3_SUPPORT
00119 //
00120 // Use QStyle::itemRect(), QStyle::drawItem() and QStyle::drawArrow() instead.
00121 //
00122 Q_GUI_EXPORT QT3_SUPPORT QRect qItemRect(QPainter *p, Qt::GUIStyle gs, int x, int y, int w, int h,
00123                           int flags, bool enabled,
00124                           const QPixmap *pixmap, const QString& text, int len=-1);
00125 
00126 Q_GUI_EXPORT QT3_SUPPORT void qDrawItem(QPainter *p, Qt::GUIStyle gs, int x, int y, int w, int h,
00127                          int flags, const QPalette &pal, bool enabled,
00128                          const QPixmap *pixmap, const QString& text,
00129                          int len=-1, const QColor* penColor = 0);
00130 
00131 Q_GUI_EXPORT QT3_SUPPORT void qDrawArrow(QPainter *p, Qt::ArrowType type, Qt::GUIStyle style, bool down,
00132                           int x, int y, int w, int h,
00133                           const QPalette &pal, bool enabled);
00134 #endif
00135 
00136 struct QTileRules
00137 {
00138     inline QTileRules(Qt::TileRule horizontalRule, Qt::TileRule verticalRule)
00139             : horizontal(horizontalRule), vertical(verticalRule) {}
00140     inline QTileRules(Qt::TileRule rule = Qt::StretchTile)
00141             : horizontal(rule), vertical(rule) {}
00142     Qt::TileRule horizontal;
00143     Qt::TileRule vertical;
00144 };
00145 
00146 #ifndef Q_QDOC
00147 // For internal use only.
00148 namespace QDrawBorderPixmap
00149 {
00150     enum DrawingHint
00151     {
00152         OpaqueTopLeft = 0x0001,
00153         OpaqueTop = 0x0002,
00154         OpaqueTopRight = 0x0004,
00155         OpaqueLeft = 0x0008,
00156         OpaqueCenter = 0x0010,
00157         OpaqueRight = 0x0020,
00158         OpaqueBottomLeft = 0x0040,
00159         OpaqueBottom = 0x0080,
00160         OpaqueBottomRight = 0x0100,
00161         OpaqueCorners = OpaqueTopLeft | OpaqueTopRight | OpaqueBottomLeft | OpaqueBottomRight,
00162         OpaqueEdges = OpaqueTop | OpaqueLeft | OpaqueRight | OpaqueBottom,
00163         OpaqueFrame = OpaqueCorners | OpaqueEdges,
00164         OpaqueAll = OpaqueCenter | OpaqueFrame
00165     };
00166 
00167     Q_DECLARE_FLAGS(DrawingHints, DrawingHint)
00168 }
00169 #endif
00170 
00171 Q_GUI_EXPORT void qDrawBorderPixmap(QPainter *painter,
00172                                     const QRect &targetRect,
00173                                     const QMargins &targetMargins,
00174                                     const QPixmap &pixmap,
00175                                     const QRect &sourceRect,
00176                                     const QMargins &sourceMargins,
00177                                     const QTileRules &rules = QTileRules()
00178 #ifndef Q_QDOC
00179                                     , QDrawBorderPixmap::DrawingHints hints = 0
00180 #endif
00181                                     );
00182 
00183 inline void qDrawBorderPixmap(QPainter *painter,
00184                                            const QRect &target,
00185                                            const QMargins &margins,
00186                                            const QPixmap &pixmap)
00187 {
00188     qDrawBorderPixmap(painter, target, margins, pixmap, pixmap.rect(), margins);
00189 }
00190 
00191 QT_END_NAMESPACE
00192 
00193 QT_END_HEADER
00194 
00195 #endif // QDRAWUTIL_H