~oif-team/ubuntu/natty/qt4-x11/xi2.1

« back to all changes in this revision

Viewing changes to doc/html/demos-gradients-gradients-h.html

  • Committer: Bazaar Package Importer
  • Author(s): Adam Conrad
  • Date: 2005-08-24 04:09:09 UTC
  • Revision ID: james.westby@ubuntu.com-20050824040909-xmxe9jfr4a0w5671
Tags: upstream-4.0.0
ImportĀ upstreamĀ versionĀ 4.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<?xml version="1.0" encoding="iso-8859-1"?>
 
2
<!DOCTYPE html
 
3
    PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd">
 
4
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
 
5
<head>
 
6
    <title>Qt 4.0: gradients.h Example File (demos/gradients/gradients.h)</title>
 
7
    <style>h3.fn,span.fn { margin-left: 1cm; text-indent: -1cm; }
 
8
a:link { color: #004faf; text-decoration: none }
 
9
a:visited { color: #672967; text-decoration: none }
 
10
td.postheader { font-family: sans-serif }
 
11
tr.address { font-family: sans-serif }
 
12
body { background: #ffffff; color: black; }</style>
 
13
</head>
 
14
<body>
 
15
<table border="0" cellpadding="0" cellspacing="0" width="100%">
 
16
<tr>
 
17
<td align="left" valign="top" width="32"><img src="images/qt-logo.png" align="left" width="32" height="32" border="0" /></td>
 
18
<td width="1">&nbsp;&nbsp;</td><td class="postheader" valign="center"><a href="index.html"><font color="#004faf">Home</font></a>&nbsp;&middot; <a href="classes.html"><font color="#004faf">All&nbsp;Classes</font></a>&nbsp;&middot; <a href="mainclasses.html"><font color="#004faf">Main&nbsp;Classes</font></a>&nbsp;&middot; <a href="annotated.html"><font color="#004faf">Annotated</font></a>&nbsp;&middot; <a href="groups.html"><font color="#004faf">Grouped&nbsp;Classes</font></a>&nbsp;&middot; <a href="functions.html"><font color="#004faf">Functions</font></a></td>
 
19
<td align="right" valign="top" width="230"><img src="images/trolltech-logo.png" align="right" width="203" height="32" border="0" /></td></tr></table><h1 align="center">gradients.h Example File<br /><small><small>demos/gradients/gradients.h</small></small></h1>
 
20
<pre>&nbsp;   #ifndef GRADIENTS_H
 
21
    #define GRADIENTS_H
 
22
 
 
23
    #include &lt;QtGui&gt;
 
24
 
 
25
    #include &quot;arthurwidgets.h&quot;
 
26
 
 
27
    class HoverPoints;
 
28
 
 
29
    class ShadeWidget : public QWidget
 
30
    {
 
31
        Q_OBJECT
 
32
    public:
 
33
        enum ShadeType {
 
34
            RedShade,
 
35
            GreenShade,
 
36
            BlueShade,
 
37
            ARGBShade
 
38
        };
 
39
 
 
40
        ShadeWidget(ShadeType type, QWidget *parent);
 
41
 
 
42
        void setGradientStops(const QGradientStops &amp;stops);
 
43
 
 
44
        void paintEvent(QPaintEvent *e);
 
45
 
 
46
        QSize sizeHint() const { return QSize(150, 40); }
 
47
        QPolygonF points() const;
 
48
 
 
49
        HoverPoints *hoverPoints() const { return m_hoverPoints; }
 
50
 
 
51
        uint colorAt(int x);
 
52
 
 
53
    signals:
 
54
        void colorsChanged();
 
55
 
 
56
    private:
 
57
        void generateShade();
 
58
 
 
59
        ShadeType m_shade_type;
 
60
        QImage m_shade;
 
61
        HoverPoints *m_hoverPoints;
 
62
        QLinearGradient m_alpha_gradient;
 
63
    };
 
64
 
 
65
    class GradientEditor : public QWidget
 
66
    {
 
67
        Q_OBJECT
 
68
    public:
 
69
        GradientEditor(QWidget *parent);
 
70
 
 
71
        void setGradientStops(const QGradientStops &amp;stops);
 
72
 
 
73
    public slots:
 
74
        void pointsUpdated();
 
75
 
 
76
    signals:
 
77
        void gradientStopsChanged(const QGradientStops &amp;stops);
 
78
 
 
79
    private:
 
80
        ShadeWidget *m_red_shade;
 
81
        ShadeWidget *m_green_shade;
 
82
        ShadeWidget *m_blue_shade;
 
83
        ShadeWidget *m_alpha_shade;
 
84
    };
 
85
 
 
86
    class GradientRenderer : public ArthurFrame
 
87
    {
 
88
        Q_OBJECT
 
89
    public:
 
90
        GradientRenderer(QWidget *parent);
 
91
        void paint(QPainter *p);
 
92
 
 
93
        QSize sizeHint() const { return QSize(400, 400); }
 
94
 
 
95
        HoverPoints *hoverPoints() const { return m_hoverPoints; }
 
96
        void mousePressEvent(QMouseEvent *e);
 
97
 
 
98
    public slots:
 
99
        void setGradientStops(const QGradientStops &amp;stops);
 
100
 
 
101
        void setPadSpread() { m_spread = QGradient::PadSpread; update(); }
 
102
        void setRepeatSpread() { m_spread = QGradient::RepeatSpread; update(); }
 
103
        void setReflectSpread() { m_spread = QGradient::ReflectSpread; update(); }
 
104
 
 
105
        void setLinearGradient() { m_gradientType = Qt::LinearGradientPattern; update(); }
 
106
        void setRadialGradient() { m_gradientType = Qt::RadialGradientPattern; update(); }
 
107
        void setConicalGradient() { m_gradientType = Qt::ConicalGradientPattern; update(); }
 
108
 
 
109
    private:
 
110
        QGradientStops m_stops;
 
111
        HoverPoints *m_hoverPoints;
 
112
 
 
113
        QGradient::Spread m_spread;
 
114
        Qt::BrushStyle m_gradientType;
 
115
    };
 
116
 
 
117
    class GradientWidget : public QWidget
 
118
    {
 
119
        Q_OBJECT
 
120
    public:
 
121
        GradientWidget(QWidget *parent);
 
122
 
 
123
    public slots:
 
124
        void setDefault1() { setDefault(1); }
 
125
        void setDefault2() { setDefault(2); }
 
126
        void setDefault3() { setDefault(3); }
 
127
        void setDefault4() { setDefault(4); }
 
128
 
 
129
    private:
 
130
        void setDefault(int i);
 
131
 
 
132
        GradientRenderer *m_renderer;
 
133
        GradientEditor *m_editor;
 
134
 
 
135
        QRadioButton *m_linearButton;
 
136
        QRadioButton *m_radialButton;
 
137
        QRadioButton *m_conicalButton;
 
138
        QRadioButton *m_padSpreadButton;
 
139
        QRadioButton *m_reflectSpreadButton;
 
140
        QRadioButton *m_repeatSpreadButton;
 
141
 
 
142
    };
 
143
 
 
144
    #endif // GRADIENTS_H</pre>
 
145
<p /><address><hr /><div align="center">
 
146
<table width="100%" cellspacing="0" border="0"><tr class="address">
 
147
<td width="30%">Copyright &copy; 2005 <a href="trolltech.html">Trolltech</a></td>
 
148
<td width="40%" align="center"><a href="trademarks.html">Trademarks</a></td>
 
149
<td width="30%" align="right"><div align="right">Qt 4.0.0</div></td>
 
150
</tr></table></div></address></body>
 
151
</html>