1 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
---|
2 | <!-- /home/espenr/tmp/qt-3.3.8-espenr-2499/qt-x11-free-3.3.8/doc/tutorial2.doc:2 -->
|
---|
3 | <html>
|
---|
4 | <head>
|
---|
5 | <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
|
---|
6 | <title>chart/element.h Example File</title>
|
---|
7 | <style type="text/css"><!--
|
---|
8 | fn { margin-left: 1cm; text-indent: -1cm; }
|
---|
9 | a:link { color: #004faf; text-decoration: none }
|
---|
10 | a:visited { color: #672967; text-decoration: none }
|
---|
11 | body { background: #ffffff; color: black; }
|
---|
12 | --></style>
|
---|
13 | </head>
|
---|
14 | <body>
|
---|
15 |
|
---|
16 | <table border="0" cellpadding="0" cellspacing="0" width="100%">
|
---|
17 | <tr bgcolor="#E5E5E5">
|
---|
18 | <td valign=center>
|
---|
19 | <a href="index.html">
|
---|
20 | <font color="#004faf">Home</font></a>
|
---|
21 | | <a href="classes.html">
|
---|
22 | <font color="#004faf">All Classes</font></a>
|
---|
23 | | <a href="mainclasses.html">
|
---|
24 | <font color="#004faf">Main Classes</font></a>
|
---|
25 | | <a href="annotated.html">
|
---|
26 | <font color="#004faf">Annotated</font></a>
|
---|
27 | | <a href="groups.html">
|
---|
28 | <font color="#004faf">Grouped Classes</font></a>
|
---|
29 | | <a href="functions.html">
|
---|
30 | <font color="#004faf">Functions</font></a>
|
---|
31 | </td>
|
---|
32 | <td align="right" valign="center"><img src="logo32.png" align="right" width="64" height="32" border="0"></td></tr></table><h1 align=center>chart/element.h Example File</h1>
|
---|
33 |
|
---|
34 |
|
---|
35 | <pre>#ifndef ELEMENT_H
|
---|
36 | #define ELEMENT_H
|
---|
37 |
|
---|
38 | #include <<a href="qcolor-h.html">qcolor.h</a>>
|
---|
39 | #include <<a href="qnamespace-h.html">qnamespace.h</a>>
|
---|
40 | #include <<a href="qstring-h.html">qstring.h</a>>
|
---|
41 | #include <<a href="qvaluevector-h.html">qvaluevector.h</a>>
|
---|
42 |
|
---|
43 | class Element;
|
---|
44 |
|
---|
45 | typedef QValueVector<Element> ElementVector;
|
---|
46 |
|
---|
47 | /*
|
---|
48 | Elements are valid if they have a value which is > EPSILON.
|
---|
49 | */
|
---|
50 | const double EPSILON = 0.0000001; // Must be > INVALID.
|
---|
51 |
|
---|
52 |
|
---|
53 | class Element
|
---|
54 | {
|
---|
55 | public:
|
---|
56 | enum { INVALID = -1 };
|
---|
57 | enum { NO_PROPORTION = -1 };
|
---|
58 | enum { MAX_PROPOINTS = 3 }; // One proportional point per chart type
|
---|
59 |
|
---|
60 | Element( double value = INVALID, QColor valueColor = Qt::gray,
|
---|
61 | int valuePattern = Qt::SolidPattern,
|
---|
62 | const <a href="qstring.html">QString</a>& label = QString::null,
|
---|
63 | <a href="qcolor.html">QColor</a> labelColor = Qt::black ) {
|
---|
64 | init( value, valueColor, valuePattern, label, labelColor );
|
---|
65 | for ( int i = 0; i < MAX_PROPOINTS * 2; ++i )
|
---|
66 | m_propoints[i] = NO_PROPORTION;
|
---|
67 | }
|
---|
68 | ~Element() {}
|
---|
69 |
|
---|
70 | bool isValid() const { return m_value > EPSILON; }
|
---|
71 |
|
---|
72 | double value() const { return m_value; }
|
---|
73 | <a href="qcolor.html">QColor</a> valueColor() const { return m_valueColor; }
|
---|
74 | int valuePattern() const { return m_valuePattern; }
|
---|
75 | <a href="qstring.html">QString</a> label() const { return m_label; }
|
---|
76 | <a href="qcolor.html">QColor</a> labelColor() const { return m_labelColor; }
|
---|
77 | double proX( int index ) const;
|
---|
78 | double proY( int index ) const;
|
---|
79 |
|
---|
80 | void set( double value = INVALID, QColor valueColor = Qt::gray,
|
---|
81 | int valuePattern = Qt::SolidPattern,
|
---|
82 | const <a href="qstring.html">QString</a>& label = QString::null,
|
---|
83 | <a href="qcolor.html">QColor</a> labelColor = Qt::black ) {
|
---|
84 | init( value, valueColor, valuePattern, label, labelColor );
|
---|
85 | }
|
---|
86 | void setValue( double value ) { m_value = value; }
|
---|
87 | void setValueColor( <a href="qcolor.html">QColor</a> valueColor ) { m_valueColor = valueColor; }
|
---|
88 | void setValuePattern( int valuePattern );
|
---|
89 | void setLabel( const <a href="qstring.html">QString</a>& label ) { m_label = label; }
|
---|
90 | void setLabelColor( <a href="qcolor.html">QColor</a> labelColor ) { m_labelColor = labelColor; }
|
---|
91 | void setProX( int index, double value );
|
---|
92 | void setProY( int index, double value );
|
---|
93 |
|
---|
94 | #ifdef Q_FULL_TEMPLATE_INSTANTIATION
|
---|
95 | // xlC 3.x workaround
|
---|
96 | Q_DUMMY_COMPARISON_OPERATOR(Element)
|
---|
97 | bool operator!=( const Element& e) const {
|
---|
98 | return ( !(e == *this) );
|
---|
99 | }
|
---|
100 | #endif
|
---|
101 |
|
---|
102 | private:
|
---|
103 | void init( double value, QColor valueColor, int valuePattern,
|
---|
104 | const <a href="qstring.html">QString</a>& label, QColor labelColor );
|
---|
105 |
|
---|
106 | double m_value;
|
---|
107 | <a href="qcolor.html">QColor</a> m_valueColor;
|
---|
108 | int m_valuePattern;
|
---|
109 | <a href="qstring.html">QString</a> m_label;
|
---|
110 | <a href="qcolor.html">QColor</a> m_labelColor;
|
---|
111 | double m_propoints[2 * MAX_PROPOINTS];
|
---|
112 | };
|
---|
113 |
|
---|
114 |
|
---|
115 | QTextStream &operator<<( <a href="qtextstream.html">QTextStream</a>&, const Element& );
|
---|
116 | QTextStream &operator>>( <a href="qtextstream.html">QTextStream</a>&, Element& );
|
---|
117 |
|
---|
118 | #endif
|
---|
119 | </pre><!-- eof -->
|
---|
120 | <p><address><hr><div align=center>
|
---|
121 | <table width=100% cellspacing=0 border=0><tr>
|
---|
122 | <td>Copyright © 2007
|
---|
123 | <a href="troll.html">Trolltech</a><td align=center><a href="trademarks.html">Trademarks</a>
|
---|
124 | <td align=right><div align=right>Qt 3.3.8</div>
|
---|
125 | </table></div></address></body>
|
---|
126 | </html>
|
---|