File: classCategoryExample.html

package info (click to toggle)
witty 3.2.1-2%2Bdeb7u1
  • links: PTS
  • area: main
  • in suites: wheezy
  • size: 70,436 kB
  • sloc: cpp: 117,095; ansic: 77,999; xml: 7,564; sh: 1,037; perl: 208; makefile: 144; java: 86; sql: 14
file content (199 lines) | stat: -rw-r--r-- 16,886 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<title>Wt examples: CategoryExample Class Reference</title>

<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="doxygen.css" rel="stylesheet" type="text/css" />



</head>
<body>
<div id="top"><!-- do not remove this div! -->


<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  
  
  <td style="padding-left: 0.5em;">
   <div id="projectname">Wt examples
   &#160;<span id="projectnumber">3.2.1</span>
   </div>
   
  </td>
  
  
  
 </tr>
 </tbody>
</table>
</div>

<!-- Generated by Doxygen 1.7.5.1 -->
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li><a href="modules.html"><span>Modules</span></a></li>
      <li><a href="namespaces.html"><span>Namespaces</span></a></li>
      <li class="current"><a href="annotated.html"><span>Classes</span></a></li>
      <li><a href="files.html"><span>Files</span></a></li>
    </ul>
  </div>
  <div id="navrow2" class="tabs2">
    <ul class="tablist">
      <li><a href="annotated.html"><span>Class&#160;List</span></a></li>
      <li><a href="inherits.html"><span>Class&#160;Hierarchy</span></a></li>
      <li><a href="functions.html"><span>Class&#160;Members</span></a></li>
    </ul>
  </div>
</div>
<div class="header">
  <div class="summary">
<a href="#pub-methods">Public Member Functions</a>  </div>
  <div class="headertitle">
<div class="title">CategoryExample Class Reference<div class="ingroups"><a class="el" href="group__chartsexample.html">Charts example</a></div></div>  </div>
</div>
<div class="contents">
<!-- doxytag: class="CategoryExample" --><!-- doxytag: inherits="Wt::WContainerWidget" -->
<p>A Widget that demonstrates a category chart.  
 <a href="classCategoryExample.html#details">More...</a></p>

<p><code>#include &lt;<a class="el" href="ChartsExample_8h_source.html">ChartsExample.h</a>&gt;</code></p>
<div class="dynheader">
Inheritance diagram for CategoryExample:</div>
<div class="dyncontent">
<div class="center"><img src="classCategoryExample__inherit__graph.png" border="0" usemap="#CategoryExample_inherit__map" alt="Inheritance graph"/></div>
<map name="CategoryExample_inherit__map" id="CategoryExample_inherit__map">
<area shape="rect" doxygen="wt.tags:../../reference/html" href="../../reference/html/classWt_1_1WContainerWidget.html" title="Wt::WContainerWidget" alt="" coords="5,304,160,331"/><area shape="rect" doxygen="wt.tags:../../reference/html" href="../../reference/html/classWt_1_1WInteractWidget.html" title="Wt::WInteractWidget" alt="" coords="11,229,155,256"/><area shape="rect" doxygen="wt.tags:../../reference/html" href="../../reference/html/classWt_1_1WWebWidget.html" title="Wt::WWebWidget" alt="" coords="19,155,147,181"/><area shape="rect" doxygen="wt.tags:../../reference/html" href="../../reference/html/classWt_1_1WWidget.html" title="Wt::WWidget" alt="" coords="33,80,132,107"/><area shape="rect" doxygen="wt.tags:../../reference/html" href="../../reference/html/classWt_1_1WObject.html" title="Wt::WObject" alt="" coords="35,5,131,32"/></map>
<center><span class="legend">[<a href="graph_legend.html">legend</a>]</span></center></div>

<p><a href="classCategoryExample-members.html">List of all members.</a></p>
<table class="memberdecls">
<tr><td colspan="2"><h2><a name="pub-methods"></a>
Public Member Functions</h2></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classCategoryExample.html#ad1918a1ab288d28676e215be15919769">CategoryExample</a> (<a class="elRef" doxygen="wt.tags:../../reference/html" href="../../reference/html/classWt_1_1WContainerWidget.html">Wt::WContainerWidget</a> *<a class="elRef" doxygen="wt.tags:../../reference/html" href="../../reference/html/classWt_1_1WWidget.html#a3461e31818c4d2f516641bdaf508312a">parent</a>)</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Creates the category chart example.  <a href="#ad1918a1ab288d28676e215be15919769"></a><br/></td></tr>
</table>
<hr/><a name="details" id="details"></a><h2>Detailed Description</h2>
<div class="textblock"><p>A Widget that demonstrates a category chart. </p>

<p>Definition at line <a class="el" href="ChartsExample_8h_source.html#l00039">39</a> of file <a class="el" href="ChartsExample_8h_source.html">ChartsExample.h</a>.</p>
</div><hr/><h2>Constructor &amp; Destructor Documentation</h2>
<a class="anchor" id="ad1918a1ab288d28676e215be15919769"></a><!-- doxytag: member="CategoryExample::CategoryExample" ref="ad1918a1ab288d28676e215be15919769" args="(Wt::WContainerWidget *parent)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">CategoryExample::CategoryExample </td>
          <td>(</td>
          <td class="paramtype"><a class="elRef" doxygen="wt.tags:../../reference/html" href="../../reference/html/classWt_1_1WContainerWidget.html">Wt::WContainerWidget</a> *&#160;</td>
          <td class="paramname"><em>parent</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>Creates the category chart example. </p>

<p>Definition at line <a class="el" href="ChartsExample_8C_source.html#l00083">83</a> of file <a class="el" href="ChartsExample_8C_source.html">ChartsExample.C</a>.</p>
<div class="fragment"><pre class="fragment">                                                          :
  <a class="codeRef" doxygen="wt.tags:../../reference/html" href="../../reference/html/classWt_1_1WContainerWidget.html#a520ba6e52a36a7f2efbef1a31a69e898">WContainerWidget</a>(parent)
{
  <span class="keyword">new</span> <a class="codeRef" doxygen="wt.tags:../../reference/html" href="../../reference/html/classWt_1_1WText.html">WText</a>(WString::tr(<span class="stringliteral">&quot;category chart&quot;</span>), <span class="keyword">this</span>);

  <a class="codeRef" doxygen="wt.tags:../../reference/html" href="../../reference/html/classWt_1_1WAbstractItemModel.html">WAbstractItemModel</a> *model
    = readCsvFile(WApplication::appRoot() + <span class="stringliteral">&quot;category.csv&quot;</span>, <span class="keyword">this</span>);

  <span class="keywordflow">if</span> (!model)
    <span class="keywordflow">return</span>;

  <span class="comment">// Show a view that allows editing of the model.</span>
  <a class="codeRef" doxygen="wt.tags:../../reference/html" href="../../reference/html/classWt_1_1WContainerWidget.html">WContainerWidget</a> *w = <span class="keyword">new</span> <a class="codeRef" doxygen="wt.tags:../../reference/html" href="../../reference/html/classWt_1_1WContainerWidget.html#a520ba6e52a36a7f2efbef1a31a69e898">WContainerWidget</a>(<span class="keyword">this</span>);
  <a class="codeRef" doxygen="wt.tags:../../reference/html" href="../../reference/html/classWt_1_1WTableView.html">WTableView</a> *table = <span class="keyword">new</span> <a class="codeRef" doxygen="wt.tags:../../reference/html" href="../../reference/html/classWt_1_1WTableView.html">WTableView</a>(w);

  table-&gt;<a class="codeRef" doxygen="wt.tags:../../reference/html" href="../../reference/html/classWt_1_1WCompositeWidget.html#addf49ace29b76331067c86bc4ae6ac38">setMargin</a>(10, Top | Bottom);
  table-&gt;<a class="codeRef" doxygen="wt.tags:../../reference/html" href="../../reference/html/classWt_1_1WCompositeWidget.html#addf49ace29b76331067c86bc4ae6ac38">setMargin</a>(WLength::Auto, Left | Right);

  table-&gt;<a class="codeRef" doxygen="wt.tags:../../reference/html" href="../../reference/html/classWt_1_1WTableView.html#a2e3629fbaee86da21c77c4583efb79ed">setModel</a>(model);
  table-&gt;<a class="codeRef" doxygen="wt.tags:../../reference/html" href="../../reference/html/classWt_1_1WAbstractItemView.html#ae1c86a0f37f97f63aed3b00fd8ffad7c">setSortingEnabled</a>(<span class="keyword">true</span>);
  table-&gt;<a class="codeRef" doxygen="wt.tags:../../reference/html" href="../../reference/html/classWt_1_1WAbstractItemView.html#a4fe24c3ed80cc59f6bed2ed7795bc127">setColumnResizeEnabled</a>(<span class="keyword">true</span>);
  <span class="comment">// table-&gt;setSelectionMode(ExtendedSelection);</span>
  table-&gt;<a class="codeRef" doxygen="wt.tags:../../reference/html" href="../../reference/html/classWt_1_1WTableView.html#afbc128d312f1d5aa75c65352cb43e4ca">setAlternatingRowColors</a>(<span class="keyword">true</span>);
  table-&gt;<a class="codeRef" doxygen="wt.tags:../../reference/html" href="../../reference/html/classWt_1_1WAbstractItemView.html#aafd2a6edd366b620c71d9b3a89ed6590">setColumnAlignment</a>(0, AlignCenter);
  table-&gt;<a class="codeRef" doxygen="wt.tags:../../reference/html" href="../../reference/html/classWt_1_1WAbstractItemView.html#a036e6a392c5e38470326d71157140d1a">setHeaderAlignment</a>(0, AlignCenter);
  table-&gt;<a class="codeRef" doxygen="wt.tags:../../reference/html" href="../../reference/html/classWt_1_1WTableView.html#ab17c45b65e38c22c0230062696c36e61">setRowHeight</a>(22);

  <span class="comment">// Editing does not really work without Ajax, it would require an</span>
  <span class="comment">// additional button somewhere to confirm the edited value.</span>
  <span class="keywordflow">if</span> (WApplication::instance()-&gt;environment().ajax()) {
    table-&gt;<a class="codeRef" doxygen="wt.tags:../../reference/html" href="../../reference/html/classWt_1_1WTableView.html#a921a3a6c489b584b261c6b7c7bf720d8">resize</a>(600, 20 + 5*22);
    table-&gt;<a class="codeRef" doxygen="wt.tags:../../reference/html" href="../../reference/html/classWt_1_1WAbstractItemView.html#a93d2efc8642a6b9c55b35b7665a13da5">setEditTriggers</a>(WAbstractItemView::SingleClicked);
  } <span class="keywordflow">else</span> {
    table-&gt;<a class="codeRef" doxygen="wt.tags:../../reference/html" href="../../reference/html/classWt_1_1WTableView.html#a921a3a6c489b584b261c6b7c7bf720d8">resize</a>(600, WLength::Auto);
    table-&gt;<a class="codeRef" doxygen="wt.tags:../../reference/html" href="../../reference/html/classWt_1_1WAbstractItemView.html#a93d2efc8642a6b9c55b35b7665a13da5">setEditTriggers</a>(WAbstractItemView::NoEditTrigger);
  }

  <span class="comment">// We use a single delegate for all items which rounds values to</span>
  <span class="comment">// the closest integer value.</span>
  <a class="codeRef" doxygen="wt.tags:../../reference/html" href="../../reference/html/classWt_1_1WItemDelegate.html">WItemDelegate</a> *delegate = <span class="keyword">new</span> <a class="codeRef" doxygen="wt.tags:../../reference/html" href="../../reference/html/classWt_1_1WItemDelegate.html">WItemDelegate</a>(<span class="keyword">this</span>);
  delegate-&gt;<a class="codeRef" doxygen="wt.tags:../../reference/html" href="../../reference/html/classWt_1_1WItemDelegate.html#ad886d265dc00b95d9fb90c022a6322f9">setTextFormat</a>(<span class="stringliteral">&quot;%.f&quot;</span>);
  table-&gt;<a class="codeRef" doxygen="wt.tags:../../reference/html" href="../../reference/html/classWt_1_1WAbstractItemView.html#a2954ce5999e6ca683fef576777973496">setItemDelegate</a>(delegate);

  table-&gt;<a class="codeRef" doxygen="wt.tags:../../reference/html" href="../../reference/html/classWt_1_1WTableView.html#af37d27044e96919e2fa6af4e25f3ef67">setColumnWidth</a>(0, 80);
  <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 1; i &lt; model-&gt;<a class="codeRef" doxygen="wt.tags:../../reference/html" href="../../reference/html/classWt_1_1WAbstractItemModel.html#abcf7912a95a0a60f8e9b1c37d30b8383">columnCount</a>(); ++i)
    table-&gt;<a class="codeRef" doxygen="wt.tags:../../reference/html" href="../../reference/html/classWt_1_1WTableView.html#af37d27044e96919e2fa6af4e25f3ef67">setColumnWidth</a>(i, 120);

  <span class="comment">/*</span>
<span class="comment">   * Create the category chart.</span>
<span class="comment">   */</span>
  <a class="codeRef" doxygen="wt.tags:../../reference/html" href="../../reference/html/classWt_1_1Chart_1_1WCartesianChart.html">WCartesianChart</a> *chart = <span class="keyword">new</span> <a class="codeRef" doxygen="wt.tags:../../reference/html" href="../../reference/html/classWt_1_1Chart_1_1WCartesianChart.html">WCartesianChart</a>(<span class="keyword">this</span>);
  <span class="comment">// chart-&gt;setPreferredMethod(WPaintedWidget::PngImage);</span>
  chart-&gt;<a class="codeRef" doxygen="wt.tags:../../reference/html" href="../../reference/html/classWt_1_1Chart_1_1WAbstractChart.html#aa23d116689e939301470398df8ad5c8b">setModel</a>(model);        <span class="comment">// set the model</span>
  chart-&gt;<a class="codeRef" doxygen="wt.tags:../../reference/html" href="../../reference/html/classWt_1_1Chart_1_1WCartesianChart.html#a6c954fa4ed6d73f00ee973bfe3af5ed0">setXSeriesColumn</a>(0);    <span class="comment">// set the column that holds the categories</span>
  chart-&gt;<a class="codeRef" doxygen="wt.tags:../../reference/html" href="../../reference/html/classWt_1_1Chart_1_1WCartesianChart.html#a26c3d97f4884da079e01e7b50447a915">setLegendEnabled</a>(<span class="keyword">true</span>); <span class="comment">// enable the legend</span>

  <span class="comment">// Provide space for the X and Y axis and title. </span>
  chart-&gt;<a class="codeRef" doxygen="wt.tags:../../reference/html" href="../../reference/html/classWt_1_1Chart_1_1WAbstractChart.html#ace6ea85014f731c7034e4215710a8a48">setPlotAreaPadding</a>(80, Left);
  chart-&gt;<a class="codeRef" doxygen="wt.tags:../../reference/html" href="../../reference/html/classWt_1_1Chart_1_1WAbstractChart.html#ace6ea85014f731c7034e4215710a8a48">setPlotAreaPadding</a>(40, Top | Bottom);

  <span class="comment">/*</span>
<span class="comment">   * Add all (but first) column as bar series</span>
<span class="comment">   */</span>
  <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 1; i &lt; model-&gt;<a class="codeRef" doxygen="wt.tags:../../reference/html" href="../../reference/html/classWt_1_1WAbstractItemModel.html#abcf7912a95a0a60f8e9b1c37d30b8383">columnCount</a>(); ++i) {
    <a class="codeRef" doxygen="wt.tags:../../reference/html" href="../../reference/html/classWt_1_1Chart_1_1WDataSeries.html">WDataSeries</a> s(i, <a class="codeRef" doxygen="wt.tags:../../reference/html" href="../../reference/html/group__charts.html#gga44d64e4a9d08c7ef69648f4a9c3e4053a6751dbd7ed4600a4befa967107a6dde8">BarSeries</a>);
    s.setShadow(<a class="codeRef" doxygen="wt.tags:../../reference/html" href="../../reference/html/classWt_1_1WShadow.html">WShadow</a>(3, 3, <a class="codeRef" doxygen="wt.tags:../../reference/html" href="../../reference/html/classWt_1_1WColor.html">WColor</a>(0, 0, 0, 127), 3));
    chart-&gt;<a class="codeRef" doxygen="wt.tags:../../reference/html" href="../../reference/html/classWt_1_1Chart_1_1WCartesianChart.html#afa4ac6588e6e2e0dd93320c3a0541d46">addSeries</a>(s);
  }

  chart-&gt;<a class="codeRef" doxygen="wt.tags:../../reference/html" href="../../reference/html/classWt_1_1WPaintedWidget.html#aa57b940110d240951d0e3a6d03390319">resize</a>(800, 400);

  chart-&gt;<a class="codeRef" doxygen="wt.tags:../../reference/html" href="../../reference/html/classWt_1_1WWebWidget.html#a9795c18e926b26b97fcbabc62a1dd4e3">setMargin</a>(10, Top | Bottom);
  chart-&gt;<a class="codeRef" doxygen="wt.tags:../../reference/html" href="../../reference/html/classWt_1_1WWebWidget.html#a9795c18e926b26b97fcbabc62a1dd4e3">setMargin</a>(WLength::Auto, Left | Right);

  <span class="comment">/*</span>
<span class="comment">   * Provide a widget to manipulate chart properties</span>
<span class="comment">   */</span>
  <span class="keyword">new</span> <a class="code" href="classChartConfig.html" title="A class that allows configuration of a cartesian chart.">ChartConfig</a>(chart, <span class="keyword">this</span>);
}
</pre></div>
</div>
</div>
<hr/>The documentation for this class was generated from the following files:<ul>
<li>/home/koen/project/wt/public-git/wt/examples/charts/<a class="el" href="ChartsExample_8h_source.html">ChartsExample.h</a></li>
<li>/home/koen/project/wt/public-git/wt/examples/charts/<a class="el" href="ChartsExample_8C_source.html">ChartsExample.C</a></li>
</ul>
</div>
<hr size="1"><address style="text-align: right; margin: 3px"><small>
Generated on Fri Mar 30 2012 for <a href="http://www.webtoolkit.eu/wt">the
C++ Web Toolkit (Wt)</a> by&nbsp;<a
href="http://www.doxygen.org/index.html"><img src="doxygen.png"
alt="doxygen" border="0" style="vertical-align: middle; display:
inline-block; height: 2em"></a> 1.7.5.1</small></address>
</body>
</html>