summaryrefslogtreecommitdiffstats
path: root/doc/html/chart-element-cpp.html
diff options
context:
space:
mode:
authorTimothy Pearson <kb9vqf@pearsoncomputing.net>2011-11-08 12:31:36 -0600
committerTimothy Pearson <kb9vqf@pearsoncomputing.net>2011-11-08 12:31:36 -0600
commitd796c9dd933ab96ec83b9a634feedd5d32e1ba3f (patch)
tree6e3dcca4f77e20ec8966c666aac7c35bd4704053 /doc/html/chart-element-cpp.html
downloadtqt3-d796c9dd933ab96ec83b9a634feedd5d32e1ba3f.tar.gz
tqt3-d796c9dd933ab96ec83b9a634feedd5d32e1ba3f.zip
Test conversion to TQt3 from Qt3 8c6fc1f8e35fd264dd01c582ca5e7549b32ab731
Diffstat (limited to 'doc/html/chart-element-cpp.html')
-rw-r--r--doc/html/chart-element-cpp.html169
1 files changed, 169 insertions, 0 deletions
diff --git a/doc/html/chart-element-cpp.html b/doc/html/chart-element-cpp.html
new file mode 100644
index 000000000..cc517fbc5
--- /dev/null
+++ b/doc/html/chart-element-cpp.html
@@ -0,0 +1,169 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<!-- /home/espenr/tmp/qt-3.3.8-espenr-2499/qt-x11-free-3.3.8/doc/tutorial2.doc:3 -->
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
+<title>chart/element.cpp Example File</title>
+<style type="text/css"><!--
+fn { margin-left: 1cm; text-indent: -1cm; }
+a:link { color: #004faf; text-decoration: none }
+a:visited { color: #672967; text-decoration: none }
+body { background: #ffffff; color: black; }
+--></style>
+</head>
+<body>
+
+<table border="0" cellpadding="0" cellspacing="0" width="100%">
+<tr bgcolor="#E5E5E5">
+<td valign=center>
+ <a href="index.html">
+<font color="#004faf">Home</font></a>
+ | <a href="classes.html">
+<font color="#004faf">All&nbsp;Classes</font></a>
+ | <a href="mainclasses.html">
+<font color="#004faf">Main&nbsp;Classes</font></a>
+ | <a href="annotated.html">
+<font color="#004faf">Annotated</font></a>
+ | <a href="groups.html">
+<font color="#004faf">Grouped&nbsp;Classes</font></a>
+ | <a href="functions.html">
+<font color="#004faf">Functions</font></a>
+</td>
+<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.cpp Example File</h1>
+
+
+<pre>#include "element.h"
+
+#include &lt;<a href="qstringlist-h.html">qstringlist.h</a>&gt;
+#include &lt;<a href="qtextstream-h.html">qtextstream.h</a>&gt;
+
+const char FIELD_SEP = ':';
+const char PROPOINT_SEP = ';';
+const char XY_SEP = ',';
+
+
+void Element::init( double value, TQColor valueColor, int valuePattern,
+ const <a href="qstring.html">TQString</a>&amp; label, TQColor labelColor )
+{
+ m_value = value;
+ m_valueColor = valueColor;
+ if ( valuePattern &lt; TQt::SolidPattern || valuePattern &gt; TQt::DiagCrossPattern )
+ valuePattern = TQt::SolidPattern;
+ m_valuePattern = valuePattern;
+ m_label = label;
+ m_labelColor = labelColor;
+}
+
+
+void Element::setValuePattern( int valuePattern )
+{
+ if ( valuePattern &lt; TQt::SolidPattern || valuePattern &gt; TQt::DiagCrossPattern )
+ valuePattern = TQt::SolidPattern;
+ m_valuePattern = valuePattern;
+}
+
+
+double Element::proX( int index ) const
+{
+ <a href="qapplication.html#Q_ASSERT">Q_ASSERT</a>(index &gt;= 0 &amp;&amp; index &lt; MAX_PROPOINTS);
+ return m_propoints[2 * index];
+}
+
+
+double Element::proY( int index ) const
+{
+ <a href="qapplication.html#Q_ASSERT">Q_ASSERT</a>(index &gt;= 0 &amp;&amp; index &lt; MAX_PROPOINTS);
+ return m_propoints[(2 * index) + 1];
+}
+
+
+void Element::setProX( int index, double value )
+{
+ <a href="qapplication.html#Q_ASSERT">Q_ASSERT</a>(index &gt;= 0 &amp;&amp; index &lt; MAX_PROPOINTS);
+ m_propoints[2 * index] = value;
+}
+
+
+void Element::setProY( int index, double value )
+{
+ <a href="qapplication.html#Q_ASSERT">Q_ASSERT</a>(index &gt;= 0 &amp;&amp; index &lt; MAX_PROPOINTS);
+ m_propoints[(2 * index) + 1] = value;
+}
+
+
+TQTextStream &amp;operator&lt;&lt;( <a href="qtextstream.html">TQTextStream</a> &amp;s, const Element &amp;element )
+{
+ s &lt;&lt; element.value() &lt;&lt; FIELD_SEP
+ &lt;&lt; element.valueColor().name() &lt;&lt; FIELD_SEP
+ &lt;&lt; element.valuePattern() &lt;&lt; FIELD_SEP
+ &lt;&lt; element.labelColor().name() &lt;&lt; FIELD_SEP;
+
+ for ( int i = 0; i &lt; Element::MAX_PROPOINTS; ++i ) {
+ s &lt;&lt; element.proX( i ) &lt;&lt; XY_SEP &lt;&lt; element.proY( i );
+ s &lt;&lt; ( i == Element::MAX_PROPOINTS - 1 ? FIELD_SEP : PROPOINT_SEP );
+ }
+
+ s &lt;&lt; element.label() &lt;&lt; '\n';
+
+ return s;
+}
+
+
+TQTextStream &amp;operator&gt;&gt;( <a href="qtextstream.html">TQTextStream</a> &amp;s, Element &amp;element )
+{
+ <a href="qstring.html">TQString</a> data = s.<a href="qtextstream.html#readLine">readLine</a>();
+ element.setValue( Element::INVALID );
+
+ int errors = 0;
+ bool ok;
+
+ <a href="qstringlist.html">TQStringList</a> fields = TQStringList::<a href="qstringlist.html#split">split</a>( FIELD_SEP, data );
+ if ( fields.<a href="qvaluelist.html#count">count</a>() &gt;= 4 ) {
+ double value = fields[0].toDouble( &amp;ok );
+ if ( !ok )
+ errors++;
+ <a href="qcolor.html">TQColor</a> valueColor = TQColor( fields[1] );
+ if ( !valueColor.<a href="qcolor.html#isValid">isValid</a>() )
+ errors++;
+ int valuePattern = fields[2].toInt( &amp;ok );
+ if ( !ok )
+ errors++;
+ <a href="qcolor.html">TQColor</a> labelColor = TQColor( fields[3] );
+ if ( !labelColor.<a href="qcolor.html#isValid">isValid</a>() )
+ errors++;
+ <a href="qstringlist.html">TQStringList</a> propoints = TQStringList::<a href="qstringlist.html#split">split</a>( PROPOINT_SEP, fields[4] );
+ <a href="qstring.html">TQString</a> label = data.<a href="qstring.html#section">section</a>( FIELD_SEP, 5 );
+
+ if ( !errors ) {
+ element.set( value, valueColor, valuePattern, label, labelColor );
+ int i = 0;
+ for ( TQStringList::iterator point = propoints.<a href="qvaluelist.html#begin">begin</a>();
+ i &lt; Element::MAX_PROPOINTS &amp;&amp; point != propoints.<a href="qvaluelist.html#end">end</a>();
+ ++i, ++point ) {
+ errors = 0;
+ <a href="qstringlist.html">TQStringList</a> xy = TQStringList::<a href="qstringlist.html#split">split</a>( XY_SEP, *point );
+ double x = xy[0].toDouble( &amp;ok );
+ if ( !ok || x &lt;= 0.0 || x &gt;= 1.0 )
+ errors++;
+ double y = xy[1].toDouble( &amp;ok );
+ if ( !ok || y &lt;= 0.0 || y &gt;= 1.0 )
+ errors++;
+ if ( errors )
+ x = y = Element::NO_PROPORTION;
+ element.setProX( i, x );
+ element.setProY( i, y );
+ }
+ }
+ }
+
+ return s;
+}
+
+</pre><!-- eof -->
+<p><address><hr><div align=center>
+<table width=100% cellspacing=0 border=0><tr>
+<td>Copyright &copy; 2007
+<a href="troll.html">Trolltech</a><td align=center><a href="trademarks.html">Trademarks</a>
+<td align=right><div align=right>TQt 3.3.8</div>
+</table></div></address></body>
+</html>