aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/libraries/irrlicht-1.8/doc/html/example024.html
diff options
context:
space:
mode:
Diffstat (limited to 'libraries/irrlicht-1.8/doc/html/example024.html')
-rw-r--r--libraries/irrlicht-1.8/doc/html/example024.html630
1 files changed, 0 insertions, 630 deletions
diff --git a/libraries/irrlicht-1.8/doc/html/example024.html b/libraries/irrlicht-1.8/doc/html/example024.html
deleted file mode 100644
index 862bba2..0000000
--- a/libraries/irrlicht-1.8/doc/html/example024.html
+++ /dev/null
@@ -1,630 +0,0 @@
1<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
2<html xmlns="http://www.w3.org/1999/xhtml">
3<head>
4<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
5<title>Irrlicht 3D Engine: Tutorial 24: CursorControl</title>
6
7<link href="tabs.css" rel="stylesheet" type="text/css"/>
8<link href="doxygen.css" rel="stylesheet" type="text/css" />
9<link href="navtree.css" rel="stylesheet" type="text/css"/>
10<script type="text/javascript" src="jquery.js"></script>
11<script type="text/javascript" src="resize.js"></script>
12<script type="text/javascript" src="navtree.js"></script>
13<script type="text/javascript">
14 $(document).ready(initResizable);
15</script>
16<link href="search/search.css" rel="stylesheet" type="text/css"/>
17<script type="text/javascript" src="search/search.js"></script>
18<script type="text/javascript">
19 $(document).ready(function() { searchBox.OnSelectItem(0); });
20</script>
21
22</head>
23<body>
24<div id="top"><!-- do not remove this div! -->
25
26
27<div id="titlearea">
28<table cellspacing="0" cellpadding="0">
29 <tbody>
30 <tr style="height: 56px;">
31
32 <td id="projectlogo"><img alt="Logo" src="irrlichtlogo.png"/></td>
33
34
35 <td style="padding-left: 0.5em;">
36 <div id="projectname">Irrlicht 3D Engine
37
38 </div>
39
40 </td>
41
42
43
44
45 <td> <div id="MSearchBox" class="MSearchBoxInactive">
46 <span class="left">
47 <img id="MSearchSelect" src="search/mag_sel.png"
48 onmouseover="return searchBox.OnSearchSelectShow()"
49 onmouseout="return searchBox.OnSearchSelectHide()"
50 alt=""/>
51 <input type="text" id="MSearchField" value="Search" accesskey="S"
52 onfocus="searchBox.OnSearchFieldFocus(true)"
53 onblur="searchBox.OnSearchFieldFocus(false)"
54 onkeyup="searchBox.OnSearchFieldChange(event)"/>
55 </span><span class="right">
56 <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
57 </span>
58 </div>
59</td>
60
61
62 </tr>
63 </tbody>
64</table>
65</div>
66
67<!-- Generated by Doxygen 1.7.5.1 -->
68<script type="text/javascript">
69var searchBox = new SearchBox("searchBox", "search",false,'Search');
70</script>
71<script type="text/javascript" src="dynsections.js"></script>
72</div>
73<div id="side-nav" class="ui-resizable side-nav-resizable">
74 <div id="nav-tree">
75 <div id="nav-tree-contents">
76 </div>
77 </div>
78 <div id="splitbar" style="-moz-user-select:none;"
79 class="ui-resizable-handle">
80 </div>
81</div>
82<script type="text/javascript">
83 initNavTree('example024.html','');
84</script>
85<div id="doc-content">
86<div class="header">
87 <div class="headertitle">
88<div class="title">Tutorial 24: CursorControl </div> </div>
89</div>
90<div class="contents">
91<div class="textblock"><div class="image">
92<img src="024shot.jpg" alt="024shot.jpg"/>
93</div>
94 <p>Show how to modify cursors and offer some useful tool-functions for creating cursors. It can also be used for experiments with the mouse in general. </p>
95<div class="fragment"><pre class="fragment"><span class="preprocessor">#include &lt;<a class="code" href="irrlicht_8h.html" title="Main header file of the irrlicht, the only file needed to include.">irrlicht.h</a>&gt;</span>
96<span class="preprocessor">#include &quot;<a class="code" href="driver_choice_8h.html">driverChoice.h</a>&quot;</span>
97
98<span class="keyword">using namespace </span>irr;
99<span class="keyword">using namespace </span>core;
100<span class="keyword">using namespace </span>scene;
101<span class="keyword">using namespace </span>video;
102<span class="keyword">using namespace </span>io;
103<span class="keyword">using namespace </span>gui;
104
105<span class="preprocessor">#ifdef _IRR_WINDOWS_</span>
106<span class="preprocessor"></span><span class="preprocessor">#pragma comment(lib, &quot;Irrlicht.lib&quot;)</span>
107<span class="preprocessor"></span><span class="preprocessor">#endif</span>
108<span class="preprocessor"></span>
109<span class="keyword">const</span> <span class="keywordtype">int</span> DELAY_TIME = 3000;
110
111<span class="keyword">enum</span> ETimerAction
112{
113 ETA_MOUSE_VISIBLE,
114 ETA_MOUSE_INVISIBLE,
115};
116</pre></div><p>Structure to allow delayed execution of some actions. </p>
117<div class="fragment"><pre class="fragment"><span class="keyword">struct </span>TimerAction
118{
119 <a class="code" href="namespaceirr.html#a0416a53257075833e7002efd0a18e804" title="32 bit unsigned variable.">u32</a> TargetTime;
120 ETimerAction Action;
121};
122</pre></div><div class="fragment"><pre class="fragment"><span class="keyword">struct </span>SAppContext
123{
124 SAppContext()
125 : Device(0), InfoStatic(0), EventBox(0), CursorBox(0), SpriteBox(0)
126 , ButtonSetVisible(0), ButtonSetInvisible(0), ButtonSimulateBadFps(0)
127 , ButtonChangeIcon(0)
128 , SimulateBadFps(false)
129 {
130 }
131
132 <span class="keywordtype">void</span> update()
133 {
134 <span class="keywordflow">if</span> (!Device)
135 <span class="keywordflow">return</span>;
136 <a class="code" href="namespaceirr.html#a0416a53257075833e7002efd0a18e804" title="32 bit unsigned variable.">u32</a> timeNow = Device-&gt;getTimer()-&gt;getTime();
137 <span class="keywordflow">for</span> ( <a class="code" href="namespaceirr.html#a0416a53257075833e7002efd0a18e804" title="32 bit unsigned variable.">u32</a> i=0; i &lt; TimerActions.size(); ++i )
138 {
139 <span class="keywordflow">if</span> ( timeNow &gt;= TimerActions[i].TargetTime )
140 {
141 runTimerAction(TimerActions[i]);
142 TimerActions.erase(i);
143 }
144 <span class="keywordflow">else</span>
145 {
146 ++i;
147 }
148 }
149 }
150
151 <span class="keywordtype">void</span> runTimerAction(<span class="keyword">const</span> TimerAction&amp; action)
152 {
153 <span class="keywordflow">if</span> (ETA_MOUSE_VISIBLE == action.Action)
154 {
155 Device-&gt;getCursorControl()-&gt;setVisible(<span class="keyword">true</span>);
156 ButtonSetVisible-&gt;setEnabled(<span class="keyword">true</span>);
157 }
158 <span class="keywordflow">else</span> <span class="keywordflow">if</span> ( ETA_MOUSE_INVISIBLE == action.Action)
159 {
160 Device-&gt;getCursorControl()-&gt;setVisible(<span class="keyword">false</span>);
161 ButtonSetInvisible-&gt;setEnabled(<span class="keyword">true</span>);
162 }
163 }
164</pre></div><p>Add another icon which the user can click and select as cursor later on. </p>
165<div class="fragment"><pre class="fragment"> <span class="keywordtype">void</span> addIcon(<span class="keyword">const</span> <a class="code" href="namespaceirr_1_1core.html#aef83fafbb1b36fcce44c07c9be23a7f2" title="Typedef for wide character strings.">stringw</a>&amp; name, <span class="keyword">const</span> SCursorSprite &amp;sprite, <span class="keywordtype">bool</span> addCursor=<span class="keyword">true</span>)
166 {
167 <span class="comment">// Sprites are just icons - not yet cursors. They can be displayed by Irrlicht sprite functions and be used to create cursors.</span>
168 SpriteBox-&gt;addItem(name.c_str(), sprite.SpriteId);
169 Sprites.push_back(sprite);
170
171 <span class="comment">// create the cursor together with the icon?</span>
172 <span class="keywordflow">if</span> ( addCursor )
173 {
174</pre></div><p> Here we create a hardware cursor from a sprite </p>
175<div class="fragment"><pre class="fragment"> Device-&gt;getCursorControl()-&gt;addIcon(sprite);
176
177 <span class="comment">// ... and add it to the cursors selection listbox to the other system cursors.</span>
178 CursorBox-&gt;addItem(name.c_str());
179 }
180 }
181
182 IrrlichtDevice * Device;
183 gui::IGUIStaticText * InfoStatic;
184 gui::IGUIListBox * EventBox;
185 gui::IGUIListBox * CursorBox;
186 gui::IGUIListBox * SpriteBox;
187 gui::IGUIButton * ButtonSetVisible;
188 gui::IGUIButton * ButtonSetInvisible;
189 gui::IGUIButton * ButtonSimulateBadFps;
190 gui::IGUIButton * ButtonChangeIcon;
191 array&lt;TimerAction&gt; TimerActions;
192 <span class="keywordtype">bool</span> SimulateBadFps;
193 array&lt;SCursorSprite&gt; Sprites;
194};
195</pre></div><p>Helper function to print mouse event names into a stringw </p>
196<div class="fragment"><pre class="fragment"><span class="keywordtype">void</span> PrintMouseEventName(<span class="keyword">const</span> SEvent&amp; event, <a class="code" href="namespaceirr_1_1core.html#aef83fafbb1b36fcce44c07c9be23a7f2" title="Typedef for wide character strings.">stringw</a> &amp;result)
197{
198 <span class="keywordflow">switch</span> ( event.MouseInput.Event )
199 {
200 <span class="keywordflow">case</span> <a class="code" href="namespaceirr.html#a2dbf2a247aa17a9eeefbbf36ebd5739fa3f551814f5f38596ea1f3ed7c6c7bad7" title="Left mouse button was pressed down.">EMIE_LMOUSE_PRESSED_DOWN</a>: result += <a class="code" href="namespaceirr_1_1core.html#aef83fafbb1b36fcce44c07c9be23a7f2" title="Typedef for wide character strings.">stringw</a>(L<span class="stringliteral">&quot;EMIE_LMOUSE_PRESSED_DOWN&quot;</span>); <span class="keywordflow">break</span>;
201 <span class="keywordflow">case</span> <a class="code" href="namespaceirr.html#a2dbf2a247aa17a9eeefbbf36ebd5739fab54734344dc9cc7c00b33afcc6443575" title="Right mouse button was pressed down.">EMIE_RMOUSE_PRESSED_DOWN</a>: result += <a class="code" href="namespaceirr_1_1core.html#aef83fafbb1b36fcce44c07c9be23a7f2" title="Typedef for wide character strings.">stringw</a>(L<span class="stringliteral">&quot;EMIE_RMOUSE_PRESSED_DOWN&quot;</span>); <span class="keywordflow">break</span>;
202 <span class="keywordflow">case</span> <a class="code" href="namespaceirr.html#a2dbf2a247aa17a9eeefbbf36ebd5739fa3daff77552ab92abc317afe09b41bc76" title="Middle mouse button was pressed down.">EMIE_MMOUSE_PRESSED_DOWN</a>: result += <a class="code" href="namespaceirr_1_1core.html#aef83fafbb1b36fcce44c07c9be23a7f2" title="Typedef for wide character strings.">stringw</a>(L<span class="stringliteral">&quot;EMIE_MMOUSE_PRESSED_DOWN&quot;</span>); <span class="keywordflow">break</span>;
203 <span class="keywordflow">case</span> <a class="code" href="namespaceirr.html#a2dbf2a247aa17a9eeefbbf36ebd5739fa26d91b99a8912ff622133f02c60f306a" title="Left mouse button was left up.">EMIE_LMOUSE_LEFT_UP</a>: result += <a class="code" href="namespaceirr_1_1core.html#aef83fafbb1b36fcce44c07c9be23a7f2" title="Typedef for wide character strings.">stringw</a>(L<span class="stringliteral">&quot;EMIE_LMOUSE_LEFT_UP&quot;</span>); <span class="keywordflow">break</span>;
204 <span class="keywordflow">case</span> <a class="code" href="namespaceirr.html#a2dbf2a247aa17a9eeefbbf36ebd5739fadb92d5c1011534b2b18065573182d9f4" title="Right mouse button was left up.">EMIE_RMOUSE_LEFT_UP</a>: result += <a class="code" href="namespaceirr_1_1core.html#aef83fafbb1b36fcce44c07c9be23a7f2" title="Typedef for wide character strings.">stringw</a>(L<span class="stringliteral">&quot;EMIE_RMOUSE_LEFT_UP&quot;</span>); <span class="keywordflow">break</span>;
205 <span class="keywordflow">case</span> <a class="code" href="namespaceirr.html#a2dbf2a247aa17a9eeefbbf36ebd5739fa13e6b5b0964334f1dbefae9848dc26df" title="Middle mouse button was left up.">EMIE_MMOUSE_LEFT_UP</a>: result += <a class="code" href="namespaceirr_1_1core.html#aef83fafbb1b36fcce44c07c9be23a7f2" title="Typedef for wide character strings.">stringw</a>(L<span class="stringliteral">&quot;EMIE_MMOUSE_LEFT_UP&quot;</span>); <span class="keywordflow">break</span>;
206 <span class="keywordflow">case</span> <a class="code" href="namespaceirr.html#a2dbf2a247aa17a9eeefbbf36ebd5739fae3288f42ed4b8372853c1822bbc0a7a1" title="The mouse cursor changed its position.">EMIE_MOUSE_MOVED</a>: result += <a class="code" href="namespaceirr_1_1core.html#aef83fafbb1b36fcce44c07c9be23a7f2" title="Typedef for wide character strings.">stringw</a>(L<span class="stringliteral">&quot;EMIE_MOUSE_MOVED&quot;</span>); <span class="keywordflow">break</span>;
207 <span class="keywordflow">case</span> <a class="code" href="namespaceirr.html#a2dbf2a247aa17a9eeefbbf36ebd5739fad091f4f4144d57e46be11b029c3c6720">EMIE_MOUSE_WHEEL</a>: result += <a class="code" href="namespaceirr_1_1core.html#aef83fafbb1b36fcce44c07c9be23a7f2" title="Typedef for wide character strings.">stringw</a>(L<span class="stringliteral">&quot;EMIE_MOUSE_WHEEL&quot;</span>); <span class="keywordflow">break</span>;
208 <span class="keywordflow">case</span> <a class="code" href="namespaceirr.html#a2dbf2a247aa17a9eeefbbf36ebd5739fa689d3c959226829a85d5dc005400c7ce">EMIE_LMOUSE_DOUBLE_CLICK</a>: result += <a class="code" href="namespaceirr_1_1core.html#aef83fafbb1b36fcce44c07c9be23a7f2" title="Typedef for wide character strings.">stringw</a>(L<span class="stringliteral">&quot;EMIE_LMOUSE_DOUBLE_CLICK&quot;</span>); <span class="keywordflow">break</span>;
209 <span class="keywordflow">case</span> <a class="code" href="namespaceirr.html#a2dbf2a247aa17a9eeefbbf36ebd5739fa90865e216488a0a92c030f220a5a69d6">EMIE_RMOUSE_DOUBLE_CLICK</a>: result += <a class="code" href="namespaceirr_1_1core.html#aef83fafbb1b36fcce44c07c9be23a7f2" title="Typedef for wide character strings.">stringw</a>(L<span class="stringliteral">&quot;EMIE_RMOUSE_DOUBLE_CLICK&quot;</span>); <span class="keywordflow">break</span>;
210 <span class="keywordflow">case</span> <a class="code" href="namespaceirr.html#a2dbf2a247aa17a9eeefbbf36ebd5739fa89b46e2e0e79ee26d9c2478ebe1dd9ee">EMIE_MMOUSE_DOUBLE_CLICK</a>: result += <a class="code" href="namespaceirr_1_1core.html#aef83fafbb1b36fcce44c07c9be23a7f2" title="Typedef for wide character strings.">stringw</a>(L<span class="stringliteral">&quot;EMIE_MMOUSE_DOUBLE_CLICK&quot;</span>); <span class="keywordflow">break</span>;
211 <span class="keywordflow">case</span> <a class="code" href="namespaceirr.html#a2dbf2a247aa17a9eeefbbf36ebd5739fa1145828528f7999720df3dd10a3a7de3">EMIE_LMOUSE_TRIPLE_CLICK</a>: result += <a class="code" href="namespaceirr_1_1core.html#aef83fafbb1b36fcce44c07c9be23a7f2" title="Typedef for wide character strings.">stringw</a>(L<span class="stringliteral">&quot;EMIE_LMOUSE_TRIPLE_CLICK&quot;</span>); <span class="keywordflow">break</span>;
212 <span class="keywordflow">case</span> <a class="code" href="namespaceirr.html#a2dbf2a247aa17a9eeefbbf36ebd5739fab24cbd2197b888022531799561c12b49">EMIE_RMOUSE_TRIPLE_CLICK</a>: result += <a class="code" href="namespaceirr_1_1core.html#aef83fafbb1b36fcce44c07c9be23a7f2" title="Typedef for wide character strings.">stringw</a>(L<span class="stringliteral">&quot;EMIE_RMOUSE_TRIPLE_CLICK&quot;</span>); <span class="keywordflow">break</span>;
213 <span class="keywordflow">case</span> <a class="code" href="namespaceirr.html#a2dbf2a247aa17a9eeefbbf36ebd5739fa72b90a632c6063a6f8e2fbf26187c9c6">EMIE_MMOUSE_TRIPLE_CLICK</a>: result += <a class="code" href="namespaceirr_1_1core.html#aef83fafbb1b36fcce44c07c9be23a7f2" title="Typedef for wide character strings.">stringw</a>(L<span class="stringliteral">&quot;EMIE_MMOUSE_TRIPLE_CLICK&quot;</span>); <span class="keywordflow">break</span>;
214 <span class="keywordflow">default</span>:
215 <span class="keywordflow">break</span>;
216 }
217}
218</pre></div><p>Helper function to print all the state information which get from a mouse-event into a stringw </p>
219<div class="fragment"><pre class="fragment"><span class="keywordtype">void</span> PrintMouseState(<span class="keyword">const</span> SEvent&amp; event, <a class="code" href="namespaceirr_1_1core.html#aef83fafbb1b36fcce44c07c9be23a7f2" title="Typedef for wide character strings.">stringw</a> &amp;result)
220{
221 result += <a class="code" href="namespaceirr_1_1core.html#aef83fafbb1b36fcce44c07c9be23a7f2" title="Typedef for wide character strings.">stringw</a>(L<span class="stringliteral">&quot;X: &quot;</span>);
222 result += <a class="code" href="namespaceirr_1_1core.html#aef83fafbb1b36fcce44c07c9be23a7f2" title="Typedef for wide character strings.">stringw</a>(event.MouseInput.X);
223 result += <a class="code" href="namespaceirr_1_1core.html#aef83fafbb1b36fcce44c07c9be23a7f2" title="Typedef for wide character strings.">stringw</a>(L<span class="stringliteral">&quot;\n&quot;</span>);
224
225 result += <a class="code" href="namespaceirr_1_1core.html#aef83fafbb1b36fcce44c07c9be23a7f2" title="Typedef for wide character strings.">stringw</a>(L<span class="stringliteral">&quot;Y: &quot;</span>);
226 result += <a class="code" href="namespaceirr_1_1core.html#aef83fafbb1b36fcce44c07c9be23a7f2" title="Typedef for wide character strings.">stringw</a>(event.MouseInput.Y);
227 result += <a class="code" href="namespaceirr_1_1core.html#aef83fafbb1b36fcce44c07c9be23a7f2" title="Typedef for wide character strings.">stringw</a>(L<span class="stringliteral">&quot;\n&quot;</span>);
228
229
230 result += <a class="code" href="namespaceirr_1_1core.html#aef83fafbb1b36fcce44c07c9be23a7f2" title="Typedef for wide character strings.">stringw</a>(L<span class="stringliteral">&quot;Wheel: &quot;</span>);
231 result += <a class="code" href="namespaceirr_1_1core.html#aef83fafbb1b36fcce44c07c9be23a7f2" title="Typedef for wide character strings.">stringw</a>(event.MouseInput.Wheel);
232 result += <a class="code" href="namespaceirr_1_1core.html#aef83fafbb1b36fcce44c07c9be23a7f2" title="Typedef for wide character strings.">stringw</a>(L<span class="stringliteral">&quot;\n&quot;</span>);
233
234 result += <a class="code" href="namespaceirr_1_1core.html#aef83fafbb1b36fcce44c07c9be23a7f2" title="Typedef for wide character strings.">stringw</a>(L<span class="stringliteral">&quot;Shift: &quot;</span>);
235 <span class="keywordflow">if</span> ( event.MouseInput.Shift )
236 result += <a class="code" href="namespaceirr_1_1core.html#aef83fafbb1b36fcce44c07c9be23a7f2" title="Typedef for wide character strings.">stringw</a>(L<span class="stringliteral">&quot;true\n&quot;</span>);
237 <span class="keywordflow">else</span>
238 result += <a class="code" href="namespaceirr_1_1core.html#aef83fafbb1b36fcce44c07c9be23a7f2" title="Typedef for wide character strings.">stringw</a>(L<span class="stringliteral">&quot;false\n&quot;</span>);
239
240 result += <a class="code" href="namespaceirr_1_1core.html#aef83fafbb1b36fcce44c07c9be23a7f2" title="Typedef for wide character strings.">stringw</a>(L<span class="stringliteral">&quot;Control: &quot;</span>);
241 <span class="keywordflow">if</span> ( event.MouseInput.Control )
242 result += <a class="code" href="namespaceirr_1_1core.html#aef83fafbb1b36fcce44c07c9be23a7f2" title="Typedef for wide character strings.">stringw</a>(L<span class="stringliteral">&quot;true\n&quot;</span>);
243 <span class="keywordflow">else</span>
244 result += <a class="code" href="namespaceirr_1_1core.html#aef83fafbb1b36fcce44c07c9be23a7f2" title="Typedef for wide character strings.">stringw</a>(L<span class="stringliteral">&quot;false\n&quot;</span>);
245
246 result += <a class="code" href="namespaceirr_1_1core.html#aef83fafbb1b36fcce44c07c9be23a7f2" title="Typedef for wide character strings.">stringw</a>(L<span class="stringliteral">&quot;ButtonStates: &quot;</span>);
247 result += <a class="code" href="namespaceirr_1_1core.html#aef83fafbb1b36fcce44c07c9be23a7f2" title="Typedef for wide character strings.">stringw</a>(event.MouseInput.ButtonStates);
248 result += <a class="code" href="namespaceirr_1_1core.html#aef83fafbb1b36fcce44c07c9be23a7f2" title="Typedef for wide character strings.">stringw</a>(L<span class="stringliteral">&quot;\n&quot;</span>);
249
250 result += <a class="code" href="namespaceirr_1_1core.html#aef83fafbb1b36fcce44c07c9be23a7f2" title="Typedef for wide character strings.">stringw</a>(L<span class="stringliteral">&quot;isLeftPressed: &quot;</span>);
251 <span class="keywordflow">if</span> ( event.MouseInput.isLeftPressed() )
252 result += <a class="code" href="namespaceirr_1_1core.html#aef83fafbb1b36fcce44c07c9be23a7f2" title="Typedef for wide character strings.">stringw</a>(L<span class="stringliteral">&quot;true\n&quot;</span>);
253 <span class="keywordflow">else</span>
254 result += <a class="code" href="namespaceirr_1_1core.html#aef83fafbb1b36fcce44c07c9be23a7f2" title="Typedef for wide character strings.">stringw</a>(L<span class="stringliteral">&quot;false\n&quot;</span>);
255
256 result += <a class="code" href="namespaceirr_1_1core.html#aef83fafbb1b36fcce44c07c9be23a7f2" title="Typedef for wide character strings.">stringw</a>(L<span class="stringliteral">&quot;isRightPressed: &quot;</span>);
257 <span class="keywordflow">if</span> ( event.MouseInput.isRightPressed() )
258 result += <a class="code" href="namespaceirr_1_1core.html#aef83fafbb1b36fcce44c07c9be23a7f2" title="Typedef for wide character strings.">stringw</a>(L<span class="stringliteral">&quot;true\n&quot;</span>);
259 <span class="keywordflow">else</span>
260 result += <a class="code" href="namespaceirr_1_1core.html#aef83fafbb1b36fcce44c07c9be23a7f2" title="Typedef for wide character strings.">stringw</a>(L<span class="stringliteral">&quot;false\n&quot;</span>);
261
262 result += <a class="code" href="namespaceirr_1_1core.html#aef83fafbb1b36fcce44c07c9be23a7f2" title="Typedef for wide character strings.">stringw</a>(L<span class="stringliteral">&quot;isMiddlePressed: &quot;</span>);
263 <span class="keywordflow">if</span> ( event.MouseInput.isMiddlePressed() )
264 result += <a class="code" href="namespaceirr_1_1core.html#aef83fafbb1b36fcce44c07c9be23a7f2" title="Typedef for wide character strings.">stringw</a>(L<span class="stringliteral">&quot;true\n&quot;</span>);
265 <span class="keywordflow">else</span>
266 result += <a class="code" href="namespaceirr_1_1core.html#aef83fafbb1b36fcce44c07c9be23a7f2" title="Typedef for wide character strings.">stringw</a>(L<span class="stringliteral">&quot;false\n&quot;</span>);
267
268 result += <a class="code" href="namespaceirr_1_1core.html#aef83fafbb1b36fcce44c07c9be23a7f2" title="Typedef for wide character strings.">stringw</a>(L<span class="stringliteral">&quot;Event: &quot;</span>);
269
270 PrintMouseEventName(event, result);
271
272 result += <a class="code" href="namespaceirr_1_1core.html#aef83fafbb1b36fcce44c07c9be23a7f2" title="Typedef for wide character strings.">stringw</a>(L<span class="stringliteral">&quot;\n&quot;</span>);
273}
274</pre></div><p>A typical event receiver. </p>
275<div class="fragment"><pre class="fragment"><span class="keyword">class </span>MyEventReceiver : <span class="keyword">public</span> IEventReceiver
276{
277<span class="keyword">public</span>:
278 MyEventReceiver(SAppContext &amp; context) : Context(context) { }
279
280 <span class="keyword">virtual</span> <span class="keywordtype">bool</span> OnEvent(<span class="keyword">const</span> SEvent&amp; event)
281 {
282 <span class="keywordflow">if</span> (event.EventType == <a class="code" href="namespaceirr.html#ac9eed96e06e85ce3c86fcbbbe9e48a0cae85bb44dd09a29c879d64a05047fc1d2" title="An event of the graphical user interface.">EET_GUI_EVENT</a> )
283 {
284 <span class="keywordflow">switch</span> ( event.GUIEvent.EventType )
285 {
286 <span class="keywordflow">case</span> <a class="code" href="namespaceirr_1_1gui.html#aeac71ad17341a4b6e9026ae11d576808a308ee345c92444931f83e48354072d98" title="A button was clicked.">EGET_BUTTON_CLICKED</a>:
287 {
288 <a class="code" href="namespaceirr.html#a0416a53257075833e7002efd0a18e804" title="32 bit unsigned variable.">u32</a> timeNow = Context.Device-&gt;getTimer()-&gt;getTime();
289 TimerAction action;
290 action.TargetTime = timeNow + DELAY_TIME;
291 <span class="keywordflow">if</span> ( event.GUIEvent.Caller == Context.ButtonSetVisible )
292 {
293 action.Action = ETA_MOUSE_VISIBLE;
294 Context.TimerActions.push_back(action);
295 Context.ButtonSetVisible-&gt;setEnabled(<span class="keyword">false</span>);
296 }
297 <span class="keywordflow">else</span> <span class="keywordflow">if</span> ( event.GUIEvent.Caller == Context.ButtonSetInvisible )
298 {
299 action.Action = ETA_MOUSE_INVISIBLE;
300 Context.TimerActions.push_back(action);
301 Context.ButtonSetInvisible-&gt;setEnabled(<span class="keyword">false</span>);
302 }
303 <span class="keywordflow">else</span> <span class="keywordflow">if</span> ( event.GUIEvent.Caller == Context.ButtonSimulateBadFps )
304 {
305 Context.SimulateBadFps = Context.ButtonSimulateBadFps-&gt;isPressed();
306 }
307 <span class="keywordflow">else</span> <span class="keywordflow">if</span> ( event.GUIEvent.Caller == Context.ButtonChangeIcon )
308 {
309</pre></div><p>Replace an existing cursor icon by another icon. The user has to select both - the icon which should be replaced and the icon which will replace it. </p>
310<div class="fragment"><pre class="fragment"> <a class="code" href="namespaceirr.html#ac66849b7a6ed16e30ebede579f9b47c6" title="32 bit signed variable.">s32</a> selectedCursor = Context.CursorBox-&gt;getSelected();
311 <a class="code" href="namespaceirr.html#ac66849b7a6ed16e30ebede579f9b47c6" title="32 bit signed variable.">s32</a> selectedSprite = Context.SpriteBox-&gt;getSelected();
312 <span class="keywordflow">if</span> ( selectedCursor &gt;= 0 &amp;&amp; selectedSprite &gt;= 0 )
313 {
314</pre></div><p>This does replace the icon. </p>
315<div class="fragment"><pre class="fragment"> Context.Device-&gt;getCursorControl()-&gt;changeIcon((<a class="code" href="namespaceirr_1_1gui.html#aefee802dd632c5735703e40ef40f879b" title="Default icons for cursors.">ECURSOR_ICON</a>)selectedCursor, Context.Sprites[selectedSprite] );
316</pre></div><p>Do also show the new icon. </p>
317<div class="fragment"><pre class="fragment"> Context.Device-&gt;getCursorControl()-&gt;setActiveIcon( <a class="code" href="namespaceirr_1_1gui.html#aefee802dd632c5735703e40ef40f879b" title="Default icons for cursors.">ECURSOR_ICON</a>(selectedCursor) );
318 }
319 }
320 }
321 <span class="keywordflow">break</span>;
322 <span class="keywordflow">case</span> <a class="code" href="namespaceirr_1_1gui.html#aeac71ad17341a4b6e9026ae11d576808ac4834bd158653766be139a322de519aa" title="A new item in a listbox was selected.">EGET_LISTBOX_CHANGED</a>:
323 <span class="keywordflow">case</span> <a class="code" href="namespaceirr_1_1gui.html#aeac71ad17341a4b6e9026ae11d576808a3f3c374a3c74405ee3eac6973e78345f" title="An item in the listbox was selected, which was already selected.">EGET_LISTBOX_SELECTED_AGAIN</a>:
324 {
325 <span class="keywordflow">if</span> ( event.GUIEvent.Caller == Context.CursorBox )
326 {
327</pre></div><p>Find out which cursor the user selected </p>
328<div class="fragment"><pre class="fragment"> <a class="code" href="namespaceirr.html#ac66849b7a6ed16e30ebede579f9b47c6" title="32 bit signed variable.">s32</a> selected = Context.CursorBox-&gt;getSelected();
329 <span class="keywordflow">if</span> ( selected &gt;= 0 )
330 {
331</pre></div><p>Here we set the new cursor icon which will now be used within our window. </p>
332<div class="fragment"><pre class="fragment"> Context.Device-&gt;getCursorControl()-&gt;setActiveIcon( <a class="code" href="namespaceirr_1_1gui.html#aefee802dd632c5735703e40ef40f879b" title="Default icons for cursors.">ECURSOR_ICON</a>(selected) );
333 }
334 }
335 }
336 <span class="keywordflow">break</span>;
337 <span class="keywordflow">default</span>:
338 <span class="keywordflow">break</span>;
339 }
340 }
341
342 <span class="keywordflow">if</span> (event.EventType == <a class="code" href="namespaceirr.html#ac9eed96e06e85ce3c86fcbbbe9e48a0caa230b748674e074aa67f661819ad5891" title="A mouse input event.">EET_MOUSE_INPUT_EVENT</a>)
343 {
344 <a class="code" href="namespaceirr_1_1core.html#aef83fafbb1b36fcce44c07c9be23a7f2" title="Typedef for wide character strings.">stringw</a> infoText;
345 PrintMouseState(event, infoText);
346 Context.InfoStatic-&gt;setText(infoText.c_str());
347 <span class="keywordflow">if</span> ( event.MouseInput.Event != <a class="code" href="namespaceirr.html#a2dbf2a247aa17a9eeefbbf36ebd5739fae3288f42ed4b8372853c1822bbc0a7a1" title="The mouse cursor changed its position.">EMIE_MOUSE_MOVED</a> &amp;&amp; event.MouseInput.Event != <a class="code" href="namespaceirr.html#a2dbf2a247aa17a9eeefbbf36ebd5739fad091f4f4144d57e46be11b029c3c6720">EMIE_MOUSE_WHEEL</a> ) <span class="comment">// no spam</span>
348 {
349 infoText = L<span class="stringliteral">&quot;&quot;</span>;
350 PrintMouseEventName(event, infoText);
351 Context.EventBox-&gt;insertItem(0, infoText.c_str(), -1);
352 }
353 }
354
355 <span class="keywordflow">return</span> <span class="keyword">false</span>;
356 }
357
358<span class="keyword">private</span>:
359 SAppContext &amp; Context;
360};
361</pre></div><p>Use several imagefiles as animation frames for a sprite which can be used as cursor icon. The images in those files all need to have the same size. Return sprite index on success or -1 on failure </p>
362<div class="fragment"><pre class="fragment"><a class="code" href="namespaceirr.html#ac66849b7a6ed16e30ebede579f9b47c6" title="32 bit signed variable.">s32</a> AddAnimatedIconToSpriteBank( gui::IGUISpriteBank * spriteBank, video::IVideoDriver* driver, <span class="keyword">const</span> array&lt; io::path &gt;&amp; files, <a class="code" href="namespaceirr.html#a0416a53257075833e7002efd0a18e804" title="32 bit unsigned variable.">u32</a> frameTime )
363{
364 <span class="keywordflow">if</span> ( !spriteBank || !driver || !files.size() )
365 <span class="keywordflow">return</span> -1;
366
367 video::ITexture * tex = driver-&gt;getTexture( files[0] );
368 <span class="keywordflow">if</span> ( tex )
369 {
370 array&lt; rect&lt;s32&gt; &gt;&amp; spritePositions = spriteBank-&gt;getPositions();
371 <a class="code" href="namespaceirr.html#a0416a53257075833e7002efd0a18e804" title="32 bit unsigned variable.">u32</a> idxRect = spritePositions.size();
372 spritePositions.push_back( rect&lt;s32&gt;(0,0, tex-&gt;getSize().Width, tex-&gt;getSize().Height) );
373
374 SGUISprite sprite;
375 sprite.frameTime = frameTime;
376
377 array&lt; SGUISprite &gt;&amp; sprites = spriteBank-&gt;getSprites();
378 <a class="code" href="namespaceirr.html#a0416a53257075833e7002efd0a18e804" title="32 bit unsigned variable.">u32</a> startIdx = spriteBank-&gt;getTextureCount();
379 <span class="keywordflow">for</span> ( <a class="code" href="namespaceirr.html#a0416a53257075833e7002efd0a18e804" title="32 bit unsigned variable.">u32</a> f=0; f &lt; files.size(); ++f )
380 {
381 tex = driver-&gt;getTexture( files[f] );
382 <span class="keywordflow">if</span> ( tex )
383 {
384 spriteBank-&gt;addTexture( driver-&gt;getTexture(files[f]) );
385 gui::SGUISpriteFrame frame;
386 frame.rectNumber = idxRect;
387 frame.textureNumber = startIdx+f;
388 sprite.Frames.push_back( frame );
389 }
390 }
391
392 sprites.push_back( sprite );
393 <span class="keywordflow">return</span> sprites.size()-1;
394 }
395
396 <span class="keywordflow">return</span> -1;
397}
398</pre></div><p>Use several images within one imagefile as animation frames for a sprite which can be used as cursor icon The sizes of the icons within that file all need to have the same size Return sprite index on success or -1 on failure </p>
399<div class="fragment"><pre class="fragment"><a class="code" href="namespaceirr.html#ac66849b7a6ed16e30ebede579f9b47c6" title="32 bit signed variable.">s32</a> AddAnimatedIconToSpriteBank( gui::IGUISpriteBank * spriteBank, video::IVideoDriver* driver, <span class="keyword">const</span> <a class="code" href="namespaceirr_1_1io.html#ab1bdc45edb3f94d8319c02bc0f840ee1" title="Type used for all file system related strings.">io::path</a>&amp; file, <span class="keyword">const</span> array&lt; rect&lt;s32&gt; &gt;&amp; rects, <a class="code" href="namespaceirr.html#a0416a53257075833e7002efd0a18e804" title="32 bit unsigned variable.">u32</a> frameTime )
400{
401 <span class="keywordflow">if</span> ( !spriteBank || !driver || !rects.size() )
402 <span class="keywordflow">return</span> -1;
403
404 video::ITexture * tex = driver-&gt;getTexture( file );
405 <span class="keywordflow">if</span> ( tex )
406 {
407 array&lt; rect&lt;s32&gt; &gt;&amp; spritePositions = spriteBank-&gt;getPositions();
408 <a class="code" href="namespaceirr.html#a0416a53257075833e7002efd0a18e804" title="32 bit unsigned variable.">u32</a> idxRect = spritePositions.size();
409 <a class="code" href="namespaceirr.html#a0416a53257075833e7002efd0a18e804" title="32 bit unsigned variable.">u32</a> idxTex = spriteBank-&gt;getTextureCount();
410 spriteBank-&gt;addTexture( tex );
411
412 SGUISprite sprite;
413 sprite.frameTime = frameTime;
414
415 array&lt; SGUISprite &gt;&amp; sprites = spriteBank-&gt;getSprites();
416 <span class="keywordflow">for</span> ( <a class="code" href="namespaceirr.html#a0416a53257075833e7002efd0a18e804" title="32 bit unsigned variable.">u32</a> i=0; i &lt; rects.size(); ++i )
417 {
418 spritePositions.push_back( rects[i] );
419
420 gui::SGUISpriteFrame frame;
421 frame.rectNumber = idxRect+i;
422 frame.textureNumber = idxTex;
423 sprite.Frames.push_back( frame );
424 }
425
426 sprites.push_back( sprite );
427 <span class="keywordflow">return</span> sprites.size()-1;
428 }
429
430 <span class="keywordflow">return</span> -1;
431}
432</pre></div><p>Create a non-animated icon from the given file and position and put it into the spritebank. We can use this icon later on in a cursor. </p>
433<div class="fragment"><pre class="fragment"><a class="code" href="namespaceirr.html#ac66849b7a6ed16e30ebede579f9b47c6" title="32 bit signed variable.">s32</a> AddIconToSpriteBank( gui::IGUISpriteBank * spriteBank, video::IVideoDriver* driver, <span class="keyword">const</span> <a class="code" href="namespaceirr_1_1io.html#ab1bdc45edb3f94d8319c02bc0f840ee1" title="Type used for all file system related strings.">io::path</a>&amp; file, <span class="keyword">const</span> core::rect&lt;s32&gt;&amp; rect )
434{
435 <span class="keywordflow">if</span> ( !spriteBank || !driver )
436 <span class="keywordflow">return</span> -1;
437
438 video::ITexture * tex = driver-&gt;getTexture( file );
439 <span class="keywordflow">if</span> ( tex )
440 {
441 core::array&lt; core::rect&lt;irr::s32&gt; &gt;&amp; spritePositions = spriteBank-&gt;getPositions();
442 spritePositions.push_back( rect );
443 array&lt; SGUISprite &gt;&amp; sprites = spriteBank-&gt;getSprites();
444 spriteBank-&gt;addTexture( tex );
445
446 gui::SGUISpriteFrame frame;
447 frame.rectNumber = spritePositions.size()-1;
448 frame.textureNumber = spriteBank-&gt;getTextureCount()-1;
449
450 SGUISprite sprite;
451 sprite.frameTime = 0;
452 sprite.Frames.push_back( frame );
453
454 sprites.push_back( sprite );
455
456 <span class="keywordflow">return</span> sprites.size()-1;
457 }
458
459 <span class="keywordflow">return</span> -1;
460}
461
462<span class="keywordtype">int</span> main()
463{
464 <a class="code" href="namespaceirr_1_1video.html#ae35a6de6d436c76107ad157fe42356d0" title="An enum for all types of drivers the Irrlicht Engine supports.">video::E_DRIVER_TYPE</a> driverType = driverChoiceConsole();
465 <span class="keywordflow">if</span> (driverType==<a class="code" href="namespaceirr_1_1video.html#ae35a6de6d436c76107ad157fe42356d0ae685cada50f8c100403134d932d0414c" title="No driver, just for counting the elements.">video::EDT_COUNT</a>)
466 <span class="keywordflow">return</span> 1;
467
468 IrrlichtDevice * device = <a class="code" href="namespaceirr.html#abaf4d8719cc26b0d30813abf85e47c76" title="Creates an Irrlicht device. The Irrlicht device is the root object for using the engine.">createDevice</a>(driverType, dimension2d&lt;u32&gt;(640, 480));
469 <span class="keywordflow">if</span> (device == 0)
470 <span class="keywordflow">return</span> 1; <span class="comment">// could not create selected driver.</span>
471
472 <span class="comment">// It&#39;s sometimes of interest to know how the mouse behaves after a resize</span>
473 device-&gt;setResizable(<span class="keyword">true</span>);
474
475 device-&gt;setWindowCaption(L<span class="stringliteral">&quot;Cursor control - Irrlicht engine tutorial&quot;</span>);
476 video::IVideoDriver* driver = device-&gt;getVideoDriver();
477 IGUIEnvironment* env = device-&gt;getGUIEnvironment();
478
479 gui::IGUISpriteBank * SpriteBankIcons;
480
481 SAppContext context;
482 context.Device = device;
483
484 rect&lt; s32 &gt; rectInfoStatic(10,10, 200, 200);
485 env-&gt;addStaticText (L<span class="stringliteral">&quot;Cursor state information&quot;</span>, rectInfoStatic, <span class="keyword">true</span>, <span class="keyword">true</span>);
486 rectInfoStatic.UpperLeftCorner += <a class="code" href="namespaceirr_1_1core.html#ac79bc3704cf28bc1ab72d7cd1cae78d1" title="Typedef for an integer dimension.">dimension2di</a>(0, 15);
487 context.InfoStatic = env-&gt;addStaticText (L<span class="stringliteral">&quot;&quot;</span>, rectInfoStatic, <span class="keyword">true</span>, <span class="keyword">true</span>);
488 rect&lt; s32 &gt; rectEventBox(10,210, 200, 400);
489 env-&gt;addStaticText (L<span class="stringliteral">&quot;click events (new on top)&quot;</span>, rectEventBox, <span class="keyword">true</span>, <span class="keyword">true</span>);
490 rectEventBox.UpperLeftCorner += <a class="code" href="namespaceirr_1_1core.html#ac79bc3704cf28bc1ab72d7cd1cae78d1" title="Typedef for an integer dimension.">dimension2di</a>(0, 15);
491 context.EventBox = env-&gt;addListBox(rectEventBox);
492 rect&lt; s32 &gt; rectCursorBox(210,10, 400, 250);
493 env-&gt;addStaticText (L<span class="stringliteral">&quot;cursors, click to set the active one&quot;</span>, rectCursorBox, <span class="keyword">true</span>, <span class="keyword">true</span>);
494 rectCursorBox.UpperLeftCorner += <a class="code" href="namespaceirr_1_1core.html#ac79bc3704cf28bc1ab72d7cd1cae78d1" title="Typedef for an integer dimension.">dimension2di</a>(0, 15);
495 context.CursorBox = env-&gt;addListBox(rectCursorBox);
496 rect&lt; s32 &gt; rectSpriteBox(210,260, 400, 400);
497 env-&gt;addStaticText (L<span class="stringliteral">&quot;sprites&quot;</span>, rectSpriteBox, <span class="keyword">true</span>, <span class="keyword">true</span>);
498 rectSpriteBox.UpperLeftCorner += <a class="code" href="namespaceirr_1_1core.html#ac79bc3704cf28bc1ab72d7cd1cae78d1" title="Typedef for an integer dimension.">dimension2di</a>(0, 15);
499 context.SpriteBox = env-&gt;addListBox(rectSpriteBox);
500
501 context.ButtonSetVisible = env-&gt;addButton( rect&lt;s32&gt;( 410, 20, 560, 40 ), 0, -1, L<span class="stringliteral">&quot;set visible (delayed)&quot;</span> );
502 context.ButtonSetInvisible = env-&gt;addButton( rect&lt;s32&gt;( 410, 50, 560, 70 ), 0, -1, L<span class="stringliteral">&quot;set invisible (delayed)&quot;</span> );
503 context.ButtonSimulateBadFps = env-&gt;addButton( rect&lt;s32&gt;( 410, 80, 560, 100 ), 0, -1, L<span class="stringliteral">&quot;simulate bad FPS&quot;</span> );
504 context.ButtonSimulateBadFps-&gt;setIsPushButton(<span class="keyword">true</span>);
505 context.ButtonChangeIcon = env-&gt;addButton( rect&lt;s32&gt;( 410, 140, 560, 160 ), 0, -1, L<span class="stringliteral">&quot;replace cursor icon\n(cursor+sprite must be selected)&quot;</span> );
506
507 <span class="comment">// set the names for all the system cursors</span>
508 <span class="keywordflow">for</span> ( <span class="keywordtype">int</span> i=0; i &lt; (int)<a class="code" href="namespaceirr_1_1gui.html#aefee802dd632c5735703e40ef40f879ba4960196a815443cf827e58ca48232583">gui::ECI_COUNT</a>; ++i )
509 {
510 context.CursorBox-&gt;addItem(<a class="code" href="namespaceirr_1_1core.html#aef83fafbb1b36fcce44c07c9be23a7f2" title="Typedef for wide character strings.">stringw</a>( <a class="code" href="namespaceirr_1_1gui.html#a33bd57d04dbf92750f64a244df85cd51" title="Names for ECURSOR_ICON.">GUICursorIconNames</a>[i] ).c_str());
511 }
512</pre></div><p>Create sprites which then can be used as cursor icons. </p>
513<div class="fragment"><pre class="fragment"> SpriteBankIcons = env-&gt;addEmptySpriteBank(<a class="code" href="namespaceirr_1_1io.html#ab1bdc45edb3f94d8319c02bc0f840ee1" title="Type used for all file system related strings.">io::path</a>(<span class="stringliteral">&quot;cursor_icons&quot;</span>));
514 context.SpriteBox-&gt;setSpriteBank(SpriteBankIcons);
515
516 <span class="comment">// create one animated icon from several files</span>
517 array&lt; io::path &gt; files;
518 files.push_back( <a class="code" href="namespaceirr_1_1io.html#ab1bdc45edb3f94d8319c02bc0f840ee1" title="Type used for all file system related strings.">io::path</a>(<span class="stringliteral">&quot;../../media/icon_crosshairs16x16bw1.png&quot;</span>) );
519 files.push_back( <a class="code" href="namespaceirr_1_1io.html#ab1bdc45edb3f94d8319c02bc0f840ee1" title="Type used for all file system related strings.">io::path</a>(<span class="stringliteral">&quot;../../media/icon_crosshairs16x16bw2.png&quot;</span>) );
520 files.push_back( <a class="code" href="namespaceirr_1_1io.html#ab1bdc45edb3f94d8319c02bc0f840ee1" title="Type used for all file system related strings.">io::path</a>(<span class="stringliteral">&quot;../../media/icon_crosshairs16x16bw3.png&quot;</span>) );
521 files.push_back( <a class="code" href="namespaceirr_1_1io.html#ab1bdc45edb3f94d8319c02bc0f840ee1" title="Type used for all file system related strings.">io::path</a>(<span class="stringliteral">&quot;../../media/icon_crosshairs16x16bw3.png&quot;</span>) );
522 files.push_back( <a class="code" href="namespaceirr_1_1io.html#ab1bdc45edb3f94d8319c02bc0f840ee1" title="Type used for all file system related strings.">io::path</a>(<span class="stringliteral">&quot;../../media/icon_crosshairs16x16bw2.png&quot;</span>) );
523 SCursorSprite spriteBw; <span class="comment">// the sprite + some additional information needed for cursors</span>
524 spriteBw.SpriteId = AddAnimatedIconToSpriteBank( SpriteBankIcons, driver, files, 200 );
525 spriteBw.SpriteBank = SpriteBankIcons;
526 spriteBw.HotSpot = position2d&lt;s32&gt;(7,7);
527 context.addIcon(L<span class="stringliteral">&quot;crosshair_bw&quot;</span>, spriteBw);
528
529 <span class="comment">// create one animated icon from one file</span>
530 array&lt; rect&lt;s32&gt; &gt; iconRects;
531 iconRects.push_back( rect&lt;s32&gt;(0,0, 16, 16) );
532 iconRects.push_back( rect&lt;s32&gt;(16,0, 32, 16) );
533 iconRects.push_back( rect&lt;s32&gt;(0,16, 16, 32) );
534 iconRects.push_back( rect&lt;s32&gt;(0,16, 16, 32) );
535 iconRects.push_back( rect&lt;s32&gt;(16,0, 32, 16) );
536 SCursorSprite spriteCol; <span class="comment">// the sprite + some additional information needed for cursors</span>
537 spriteCol.SpriteId = AddAnimatedIconToSpriteBank( SpriteBankIcons, driver, <a class="code" href="namespaceirr_1_1io.html#ab1bdc45edb3f94d8319c02bc0f840ee1" title="Type used for all file system related strings.">io::path</a>(<span class="stringliteral">&quot;../../media/icon_crosshairs16x16col.png&quot;</span>), iconRects, 200 );
538 spriteCol.HotSpot = position2d&lt;s32&gt;(7,7);
539 spriteCol.SpriteBank = SpriteBankIcons;
540 context.addIcon(L<span class="stringliteral">&quot;crosshair_colored&quot;</span>, spriteCol);
541
542 <span class="comment">// Create some non-animated icons</span>
543 rect&lt;s32&gt; rectIcon;
544 SCursorSprite spriteNonAnimated(SpriteBankIcons, 0, position2d&lt;s32&gt;(7,7));
545
546 rectIcon = rect&lt;s32&gt;(0,0, 16, 16);
547 spriteNonAnimated.SpriteId = AddIconToSpriteBank( SpriteBankIcons, driver, <a class="code" href="namespaceirr_1_1io.html#ab1bdc45edb3f94d8319c02bc0f840ee1" title="Type used for all file system related strings.">io::path</a>(<span class="stringliteral">&quot;../../media/icon_crosshairs16x16col.png&quot;</span>), rectIcon );
548 context.addIcon(L<span class="stringliteral">&quot;crosshair_col1&quot;</span>, spriteNonAnimated, <span class="keyword">false</span>);
549
550 rectIcon = rect&lt;s32&gt;(16,0, 32, 16);
551 spriteNonAnimated.SpriteId = AddIconToSpriteBank( SpriteBankIcons, driver, <a class="code" href="namespaceirr_1_1io.html#ab1bdc45edb3f94d8319c02bc0f840ee1" title="Type used for all file system related strings.">io::path</a>(<span class="stringliteral">&quot;../../media/icon_crosshairs16x16col.png&quot;</span>), rectIcon );
552 context.addIcon(L<span class="stringliteral">&quot;crosshair_col2&quot;</span>, spriteNonAnimated, <span class="keyword">false</span>);
553
554 rectIcon = rect&lt;s32&gt;(0,16, 16, 32);
555 spriteNonAnimated.SpriteId = AddIconToSpriteBank( SpriteBankIcons, driver, <a class="code" href="namespaceirr_1_1io.html#ab1bdc45edb3f94d8319c02bc0f840ee1" title="Type used for all file system related strings.">io::path</a>(<span class="stringliteral">&quot;../../media/icon_crosshairs16x16col.png&quot;</span>), rectIcon );
556 context.addIcon(L<span class="stringliteral">&quot;crosshair_col3&quot;</span>, spriteNonAnimated, <span class="keyword">false</span>);
557
558
559 MyEventReceiver receiver(context);
560 device-&gt;setEventReceiver(&amp;receiver);
561
562 <span class="keywordflow">while</span>(device-&gt;run() &amp;&amp; driver)
563 {
564 <span class="comment">// if (device-&gt;isWindowActive())</span>
565 {
566 <a class="code" href="namespaceirr.html#a0416a53257075833e7002efd0a18e804" title="32 bit unsigned variable.">u32</a> realTimeNow = device-&gt;getTimer()-&gt;getRealTime();
567
568 context.update();
569
570 driver-&gt;beginScene(<span class="keyword">true</span>, <span class="keyword">true</span>, SColor(0,200,200,200));
571
572 env-&gt;drawAll();
573
574 <span class="comment">// draw custom sprite with Irrlicht functions for comparison. It should usually look the same as the cursors.</span>
575 <span class="keywordflow">if</span> ( context.SpriteBox )
576 {
577 <a class="code" href="namespaceirr.html#ac66849b7a6ed16e30ebede579f9b47c6" title="32 bit signed variable.">s32</a> selectedSprite = context.SpriteBox-&gt;getSelected();
578 <span class="keywordflow">if</span> ( selectedSprite &gt;= 0 &amp;&amp; context.Sprites[selectedSprite].SpriteId &gt;= 0 )
579 {
580 SpriteBankIcons-&gt;draw2DSprite(<a class="code" href="namespaceirr.html#a0416a53257075833e7002efd0a18e804" title="32 bit unsigned variable.">u32</a>(context.Sprites[selectedSprite].SpriteId), <a class="code" href="namespaceirr_1_1core.html#a3643c2cc7820dd78cd87e73a46b92145">position2di</a>(580, 140), 0, video::SColor(255, 255, 255, 255), 0, realTimeNow);
581 }
582 }
583
584 driver-&gt;endScene();
585 }
586
587 <span class="comment">// By simulating bad fps we can find out if hardware-support for cursors works or not. If it works the cursor will move as usual,while it otherwise will just update with 2 fps now.</span>
588 <span class="keywordflow">if</span> ( context.SimulateBadFps )
589 {
590 device-&gt;sleep(500); <span class="comment">// 2 fps</span>
591 }
592 <span class="keywordflow">else</span>
593 {
594 device-&gt;sleep(10);
595 }
596 }
597
598 device-&gt;drop();
599
600 <span class="keywordflow">return</span> 0;
601}
602</pre></div> </div></div>
603</div>
604 <div id="nav-path" class="navpath">
605 <ul>
606<!-- window showing the filter options -->
607<div id="MSearchSelectWindow"
608 onmouseover="return searchBox.OnSearchSelectShow()"
609 onmouseout="return searchBox.OnSearchSelectHide()"
610 onkeydown="return searchBox.OnSearchSelectKey(event)">
611<a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(0)"><span class="SelectionMark">&#160;</span>All</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(1)"><span class="SelectionMark">&#160;</span>Classes</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(2)"><span class="SelectionMark">&#160;</span>Namespaces</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(3)"><span class="SelectionMark">&#160;</span>Files</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(4)"><span class="SelectionMark">&#160;</span>Functions</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(5)"><span class="SelectionMark">&#160;</span>Variables</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(6)"><span class="SelectionMark">&#160;</span>Typedefs</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(7)"><span class="SelectionMark">&#160;</span>Enumerations</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(8)"><span class="SelectionMark">&#160;</span>Enumerator</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(9)"><span class="SelectionMark">&#160;</span>Friends</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(10)"><span class="SelectionMark">&#160;</span>Defines</a></div>
612
613<!-- iframe showing the search results (closed by default) -->
614<div id="MSearchResultsWindow">
615<iframe src="javascript:void(0)" frameborder="0"
616 name="MSearchResults" id="MSearchResults">
617</iframe>
618</div>
619
620
621 <li class="footer">
622<a href="http://irrlicht.sourceforge.net" target="_blank">Irrlicht
623Engine</a> Documentation &copy; 2003-2012 by Nikolaus Gebhardt. Generated on Tue Nov 6 2012 11:06:02 for Irrlicht 3D Engine by
624<a href="http://www.doxygen.org/index.html" target="_blank">Doxygen</a> 1.7.5.1 </li>
625 </ul>
626 </div>
627
628
629</body>
630</html>