1 /****************************************************************************
2 **
3 ** Copyright (C) 2015 The Qt Company Ltd.
4 ** Contact: http://www.qt.io/licensing/
5 **
6 ** This file is part of the QtWidgets module of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:LGPL21$
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 http://www.qt.io/terms-conditions. For further
15 ** information use the contact form at http://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 2.1 or version 3 as published by the Free
20 ** Software Foundation and appearing in the file LICENSE.LGPLv21 and
21 ** LICENSE.LGPLv3 included in the packaging of this file. Please review the
22 ** following information to ensure the GNU Lesser General Public License
23 ** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
24 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
25 **
26 ** As a special exception, The Qt Company gives you certain additional
27 ** rights. These rights are described in The Qt Company LGPL Exception
28 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
29 **
30 ** $QT_END_LICENSE$
31 **
32 ****************************************************************************/
33 
34 #ifndef QGTKPAINTER_H
35 #define QGTKPAINTER_H
36 
37 //
38 //  W A R N I N G
39 //  -------------
40 //
41 // This file is not part of the Qt API.  It exists purely as an
42 // implementation detail.  This header file may change from version to
43 // version without notice, or even be removed.
44 //
45 // We mean it.
46 //
47 
48 #include <QtCore/qglobal.h>
49 
50 #include "qgtkglobal_p.h"
51 #include <QtCore/qsize.h>
52 #include <QtCore/qrect.h>
53 #include <QtCore/qpoint.h>
54 #include <QtGui/qpixmap.h>
55 #include <QtGui/qpainter.h>
56 
57 QT_BEGIN_NAMESPACE
58 
59 class QGtkPainter
60 {
61 public:
62     QGtkPainter();
63     virtual ~QGtkPainter();
64 
65     void reset(QPainter *painter = 0);
66 
setAlphaSupport(bool value)67     void setAlphaSupport(bool value) { m_alpha = value; }
setClipRect(const QRect & rect)68     void setClipRect(const QRect &rect) { m_cliprect = rect; }
setFlipHorizontal(bool value)69     void setFlipHorizontal(bool value) { m_hflipped = value; }
setFlipVertical(bool value)70     void setFlipVertical(bool value) { m_vflipped = value; }
setUsePixmapCache(bool value)71     void setUsePixmapCache(bool value) { m_usePixmapCache = value; }
72 
73     virtual void paintBoxGap(GtkWidget *gtkWidget, const gchar* part, const QRect &rect,
74                              GtkStateType state, GtkShadowType shadow, GtkPositionType gap_side, gint x,
75                              gint width, GtkStyle *style) = 0;
76     virtual void paintBox(GtkWidget *gtkWidget, const gchar* part,
77                           const QRect &rect, GtkStateType state, GtkShadowType shadow, GtkStyle *style,
78                           const QString &pmKey = QString()) = 0;
79     virtual void paintHline(GtkWidget *gtkWidget, const gchar* part, const QRect &rect, GtkStateType state, GtkStyle *style,
80                             int x1, int x2, int y, const QString &pmKey = QString()) = 0;
81     virtual void paintVline(GtkWidget *gtkWidget, const gchar* part, const QRect &rect, GtkStateType state, GtkStyle *style,
82                             int y1, int y2, int x, const QString &pmKey = QString()) = 0;
83     virtual void paintExpander(GtkWidget *gtkWidget, const gchar* part, const QRect &rect, GtkStateType state,
84                                GtkExpanderStyle expander_state, GtkStyle *style, const QString &pmKey = QString()) = 0;
85     virtual void paintFocus(GtkWidget *gtkWidget, const gchar* part, const QRect &rect, GtkStateType state, GtkStyle *style,
86                             const QString &pmKey = QString()) = 0;
87     virtual void paintResizeGrip(GtkWidget *gtkWidget, const gchar* part, const QRect &rect, GtkStateType state, GtkShadowType shadow,
88                                  GdkWindowEdge edge, GtkStyle *style, const QString &pmKey = QString()) = 0;
89     virtual void paintArrow(GtkWidget *gtkWidget, const gchar* part, const QRect &arrowrect, GtkArrowType arrow_type, GtkStateType state, GtkShadowType shadow,
90                             gboolean fill, GtkStyle *style, const QString &pmKey = QString()) = 0;
91     virtual void paintHandle(GtkWidget *gtkWidget, const gchar* part, const QRect &rect,
92                              GtkStateType state, GtkShadowType shadow, GtkOrientation orientation, GtkStyle *style) = 0;
93     virtual void paintSlider(GtkWidget *gtkWidget, const gchar* part, const QRect &rect, GtkStateType state, GtkShadowType shadow,
94                              GtkStyle *style, GtkOrientation orientation, const QString &pmKey = QString()) = 0;
95     virtual void paintShadow(GtkWidget *gtkWidget, const gchar* part, const QRect &rect, GtkStateType state, GtkShadowType shadow,
96                              GtkStyle *style, const QString &pmKey = QString()) = 0;
97     virtual void paintFlatBox(GtkWidget *gtkWidget, const gchar* part, const QRect &rect, GtkStateType state, GtkShadowType shadow, GtkStyle *style, const QString & = QString()) = 0;
98     virtual void paintExtention(GtkWidget *gtkWidget, const gchar *part, const QRect &rect, GtkStateType state, GtkShadowType shadow,
99                                 GtkPositionType gap_pos, GtkStyle *style) = 0;
100     virtual void paintOption(GtkWidget *gtkWidget, const QRect &rect, GtkStateType state, GtkShadowType shadow, GtkStyle *style, const QString &detail) = 0;
101     virtual void paintCheckbox(GtkWidget *gtkWidget, const QRect &rect, GtkStateType state, GtkShadowType shadow, GtkStyle *style, const QString &detail) = 0;
102 
103 protected:
104     static QString uniqueName(const QString &key, GtkStateType state, GtkShadowType shadow, const QSize &size, GtkWidget *widget = 0);
105 
106     QPainter *m_painter;
107     bool m_alpha;
108     bool m_hflipped;
109     bool m_vflipped;
110     bool m_usePixmapCache;
111     QRect m_cliprect;
112 };
113 
114 QT_END_NAMESPACE
115 
116 #endif // QGTKPAINTER_H
117