aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/libraries/irrlicht-1.8.1/doc/html/example024.html
blob: 73773d8f9dfd9de8a349c6a5a16ad7a338ee9101 (plain)
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
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
<!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>Irrlicht 3D Engine: Tutorial 24: CursorControl</title>

<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript">
  $(document).ready(initResizable);
</script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/search.js"></script>
<script type="text/javascript">
  $(document).ready(function() { searchBox.OnSelectItem(0); });
</script>

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


<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  
  <td id="projectlogo"><img alt="Logo" src="irrlichtlogo.png"/></td>
  
  
  <td style="padding-left: 0.5em;">
   <div id="projectname">Irrlicht 3D Engine
   
   </div>
   
  </td>
  
  
  
   
   <td>        <div id="MSearchBox" class="MSearchBoxInactive">
        <span class="left">
          <img id="MSearchSelect" src="search/mag_sel.png"
               onmouseover="return searchBox.OnSearchSelectShow()"
               onmouseout="return searchBox.OnSearchSelectHide()"
               alt=""/>
          <input type="text" id="MSearchField" value="Search" accesskey="S"
               onfocus="searchBox.OnSearchFieldFocus(true)" 
               onblur="searchBox.OnSearchFieldFocus(false)" 
               onkeyup="searchBox.OnSearchFieldChange(event)"/>
          </span><span class="right">
            <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
          </span>
        </div>
</td>
   
  
 </tr>
 </tbody>
</table>
</div>

<!-- Generated by Doxygen 1.7.5.1 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
<script type="text/javascript" src="dynsections.js"></script>
</div>
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
  initNavTree('example024.html','');
</script>
<div id="doc-content">
<div class="header">
  <div class="headertitle">
<div class="title">Tutorial 24: CursorControl </div>  </div>
</div>
<div class="contents">
<div class="textblock"><div class="image">
<img src="024shot.jpg" alt="024shot.jpg"/>
</div>
 <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>
<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>
<span class="preprocessor">#include &quot;<a class="code" href="driver_choice_8h.html">driverChoice.h</a>&quot;</span>

<span class="keyword">using namespace </span>irr;
<span class="keyword">using namespace </span>core;
<span class="keyword">using namespace </span>scene;
<span class="keyword">using namespace </span>video;
<span class="keyword">using namespace </span>io;
<span class="keyword">using namespace </span>gui;

<span class="preprocessor">#ifdef _IRR_WINDOWS_</span>
<span class="preprocessor"></span><span class="preprocessor">#pragma comment(lib, &quot;Irrlicht.lib&quot;)</span>
<span class="preprocessor"></span><span class="preprocessor">#endif</span>
<span class="preprocessor"></span>
<span class="keyword">const</span> <span class="keywordtype">int</span> DELAY_TIME = 3000;

<span class="keyword">enum</span> ETimerAction
{
    ETA_MOUSE_VISIBLE,
    ETA_MOUSE_INVISIBLE,
};
</pre></div><p>Structure to allow delayed execution of some actions. </p>
<div class="fragment"><pre class="fragment"><span class="keyword">struct </span>TimerAction
{
    <a class="code" href="namespaceirr.html#a0416a53257075833e7002efd0a18e804" title="32 bit unsigned variable.">u32</a> TargetTime;
    ETimerAction Action;
};
</pre></div><div class="fragment"><pre class="fragment"><span class="keyword">struct </span>SAppContext
{
    SAppContext()
    : Device(0), InfoStatic(0), EventBox(0), CursorBox(0), SpriteBox(0)
    , ButtonSetVisible(0), ButtonSetInvisible(0), ButtonSimulateBadFps(0)
    , ButtonChangeIcon(0)
    , SimulateBadFps(false)
    {
    }

    <span class="keywordtype">void</span> update()
    {
        <span class="keywordflow">if</span> (!Device)
            <span class="keywordflow">return</span>;
        <a class="code" href="namespaceirr.html#a0416a53257075833e7002efd0a18e804" title="32 bit unsigned variable.">u32</a> timeNow = Device-&gt;getTimer()-&gt;getTime();
        <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 )
        {
            <span class="keywordflow">if</span> ( timeNow &gt;= TimerActions[i].TargetTime )
            {
                runTimerAction(TimerActions[i]);
                TimerActions.erase(i);
            }
            <span class="keywordflow">else</span>
            {
                ++i;
            }
        }
    }

    <span class="keywordtype">void</span> runTimerAction(<span class="keyword">const</span> TimerAction&amp; action)
    {
        <span class="keywordflow">if</span> (ETA_MOUSE_VISIBLE == action.Action)
        {
            Device-&gt;getCursorControl()-&gt;setVisible(<span class="keyword">true</span>);
            ButtonSetVisible-&gt;setEnabled(<span class="keyword">true</span>);
        }
        <span class="keywordflow">else</span> <span class="keywordflow">if</span> ( ETA_MOUSE_INVISIBLE == action.Action)
        {
            Device-&gt;getCursorControl()-&gt;setVisible(<span class="keyword">false</span>);
            ButtonSetInvisible-&gt;setEnabled(<span class="keyword">true</span>);
        }
    }
</pre></div><p>Add another icon which the user can click and select as cursor later on. </p>
<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>)
    {
        <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>
        SpriteBox-&gt;addItem(name.c_str(), sprite.SpriteId);
        Sprites.push_back(sprite);

        <span class="comment">// create the cursor together with the icon?</span>
        <span class="keywordflow">if</span> ( addCursor )
        {
</pre></div><p> Here we create a hardware cursor from a sprite </p>
<div class="fragment"><pre class="fragment">            Device-&gt;getCursorControl()-&gt;addIcon(sprite);

            <span class="comment">// ... and add it to the cursors selection listbox to the other system cursors.</span>
            CursorBox-&gt;addItem(name.c_str());
        }
    }

    IrrlichtDevice * Device;
    gui::IGUIStaticText * InfoStatic;
    gui::IGUIListBox * EventBox;
    gui::IGUIListBox * CursorBox;
    gui::IGUIListBox * SpriteBox;
    gui::IGUIButton * ButtonSetVisible;
    gui::IGUIButton * ButtonSetInvisible;
    gui::IGUIButton * ButtonSimulateBadFps;
    gui::IGUIButton * ButtonChangeIcon;
    array&lt;TimerAction&gt; TimerActions;
    <span class="keywordtype">bool</span> SimulateBadFps;
    array&lt;SCursorSprite&gt; Sprites;
};
</pre></div><p>Helper function to print mouse event names into a stringw </p>
<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)
{
    <span class="keywordflow">switch</span> ( event.MouseInput.Event )
    {
        <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>;
        <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>;
        <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>;
        <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>;
        <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>;
        <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>;
        <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>;
        <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>;
        <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>;
        <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>;
        <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>;
        <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>;
        <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>;
        <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>;
        <span class="keywordflow">default</span>:
        <span class="keywordflow">break</span>;
    }
}
</pre></div><p>Helper function to print all the state information which get from a mouse-event into a stringw </p>
<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)
{
    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>);
    result += <a class="code" href="namespaceirr_1_1core.html#aef83fafbb1b36fcce44c07c9be23a7f2" title="Typedef for wide character strings.">stringw</a>(event.MouseInput.X);
    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>);

    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>);
    result += <a class="code" href="namespaceirr_1_1core.html#aef83fafbb1b36fcce44c07c9be23a7f2" title="Typedef for wide character strings.">stringw</a>(event.MouseInput.Y);
    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>);


    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>);
    result += <a class="code" href="namespaceirr_1_1core.html#aef83fafbb1b36fcce44c07c9be23a7f2" title="Typedef for wide character strings.">stringw</a>(event.MouseInput.Wheel);
    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>);

    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>);
    <span class="keywordflow">if</span> ( event.MouseInput.Shift )
        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>);
    <span class="keywordflow">else</span>
        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>);

    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>);
    <span class="keywordflow">if</span> ( event.MouseInput.Control )
        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>);
    <span class="keywordflow">else</span>
        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>);

    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>);
    result += <a class="code" href="namespaceirr_1_1core.html#aef83fafbb1b36fcce44c07c9be23a7f2" title="Typedef for wide character strings.">stringw</a>(event.MouseInput.ButtonStates);
    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>);

    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>);
    <span class="keywordflow">if</span> ( event.MouseInput.isLeftPressed() )
        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>);
    <span class="keywordflow">else</span>
        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>);

    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>);
    <span class="keywordflow">if</span> ( event.MouseInput.isRightPressed() )
        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>);
    <span class="keywordflow">else</span>
        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>);

    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>);
    <span class="keywordflow">if</span> ( event.MouseInput.isMiddlePressed() )
        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>);
    <span class="keywordflow">else</span>
        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>);

    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>);

    PrintMouseEventName(event, result);

    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>);
}
</pre></div><p>A typical event receiver. </p>
<div class="fragment"><pre class="fragment"><span class="keyword">class </span>MyEventReceiver : <span class="keyword">public</span> IEventReceiver
{
<span class="keyword">public</span>:
    MyEventReceiver(SAppContext &amp; context) : Context(context) { }

    <span class="keyword">virtual</span> <span class="keywordtype">bool</span> OnEvent(<span class="keyword">const</span> SEvent&amp; event)
    {
        <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> )
        {
            <span class="keywordflow">switch</span> ( event.GUIEvent.EventType )
            {
                <span class="keywordflow">case</span> <a class="code" href="namespaceirr_1_1gui.html#aeac71ad17341a4b6e9026ae11d576808a308ee345c92444931f83e48354072d98" title="A button was clicked.">EGET_BUTTON_CLICKED</a>:
                {
                    <a class="code" href="namespaceirr.html#a0416a53257075833e7002efd0a18e804" title="32 bit unsigned variable.">u32</a> timeNow = Context.Device-&gt;getTimer()-&gt;getTime();
                    TimerAction action;
                    action.TargetTime = timeNow + DELAY_TIME;
                    <span class="keywordflow">if</span> ( event.GUIEvent.Caller == Context.ButtonSetVisible )
                    {
                        action.Action = ETA_MOUSE_VISIBLE;
                        Context.TimerActions.push_back(action);
                        Context.ButtonSetVisible-&gt;setEnabled(<span class="keyword">false</span>);
                    }
                    <span class="keywordflow">else</span> <span class="keywordflow">if</span> ( event.GUIEvent.Caller == Context.ButtonSetInvisible )
                    {
                        action.Action = ETA_MOUSE_INVISIBLE;
                        Context.TimerActions.push_back(action);
                        Context.ButtonSetInvisible-&gt;setEnabled(<span class="keyword">false</span>);
                    }
                    <span class="keywordflow">else</span> <span class="keywordflow">if</span> ( event.GUIEvent.Caller == Context.ButtonSimulateBadFps )
                    {
                        Context.SimulateBadFps = Context.ButtonSimulateBadFps-&gt;isPressed();
                    }
                    <span class="keywordflow">else</span> <span class="keywordflow">if</span> ( event.GUIEvent.Caller == Context.ButtonChangeIcon )
                    {
</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>
<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();
                        <a class="code" href="namespaceirr.html#ac66849b7a6ed16e30ebede579f9b47c6" title="32 bit signed variable.">s32</a> selectedSprite = Context.SpriteBox-&gt;getSelected();
                        <span class="keywordflow">if</span> ( selectedCursor &gt;= 0 &amp;&amp; selectedSprite &gt;= 0 )
                        {
</pre></div><p>This does replace the icon. </p>
<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] );
</pre></div><p>Do also show the new icon. </p>
<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) );
                        }
                    }
                }
                <span class="keywordflow">break</span>;
                <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>:
                <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>:
                {
                    <span class="keywordflow">if</span> ( event.GUIEvent.Caller == Context.CursorBox )
                    {
</pre></div><p>Find out which cursor the user selected </p>
<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();
                        <span class="keywordflow">if</span> ( selected &gt;= 0 )
                        {
</pre></div><p>Here we set the new cursor icon which will now be used within our window. </p>
<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) );
                        }
                    }
                }
                <span class="keywordflow">break</span>;
                <span class="keywordflow">default</span>:
                <span class="keywordflow">break</span>;
            }
        }

        <span class="keywordflow">if</span> (event.EventType == <a class="code" href="namespaceirr.html#ac9eed96e06e85ce3c86fcbbbe9e48a0caa230b748674e074aa67f661819ad5891" title="A mouse input event.">EET_MOUSE_INPUT_EVENT</a>)
        {
            <a class="code" href="namespaceirr_1_1core.html#aef83fafbb1b36fcce44c07c9be23a7f2" title="Typedef for wide character strings.">stringw</a> infoText;
            PrintMouseState(event, infoText);
            Context.InfoStatic-&gt;setText(infoText.c_str());
            <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>
            {
                infoText = L<span class="stringliteral">&quot;&quot;</span>;
                PrintMouseEventName(event, infoText);
                Context.EventBox-&gt;insertItem(0, infoText.c_str(), -1);
            }
        }

        <span class="keywordflow">return</span> <span class="keyword">false</span>;
    }

<span class="keyword">private</span>:
    SAppContext &amp; Context;
};
</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>
<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 )
{
    <span class="keywordflow">if</span> ( !spriteBank || !driver || !files.size() )
        <span class="keywordflow">return</span> -1;

    video::ITexture * tex = driver-&gt;getTexture( files[0] );
    <span class="keywordflow">if</span> ( tex )
    {
        array&lt; rect&lt;s32&gt; &gt;&amp; spritePositions = spriteBank-&gt;getPositions();
        <a class="code" href="namespaceirr.html#a0416a53257075833e7002efd0a18e804" title="32 bit unsigned variable.">u32</a> idxRect = spritePositions.size();
        spritePositions.push_back( rect&lt;s32&gt;(0,0, tex-&gt;getSize().Width, tex-&gt;getSize().Height) );

        SGUISprite sprite;
        sprite.frameTime = frameTime;

        array&lt; SGUISprite &gt;&amp; sprites = spriteBank-&gt;getSprites();
        <a class="code" href="namespaceirr.html#a0416a53257075833e7002efd0a18e804" title="32 bit unsigned variable.">u32</a> startIdx = spriteBank-&gt;getTextureCount();
        <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 )
        {
            tex = driver-&gt;getTexture( files[f] );
            <span class="keywordflow">if</span> ( tex )
            {
                spriteBank-&gt;addTexture( driver-&gt;getTexture(files[f]) );
                gui::SGUISpriteFrame frame;
                frame.rectNumber = idxRect;
                frame.textureNumber = startIdx+f;
                sprite.Frames.push_back( frame );
            }
        }

        sprites.push_back( sprite );
        <span class="keywordflow">return</span> sprites.size()-1;
    }

    <span class="keywordflow">return</span> -1;
}
</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>
<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 )
{
    <span class="keywordflow">if</span> ( !spriteBank || !driver || !rects.size() )
        <span class="keywordflow">return</span> -1;

    video::ITexture * tex = driver-&gt;getTexture( file );
    <span class="keywordflow">if</span> ( tex )
    {
        array&lt; rect&lt;s32&gt; &gt;&amp; spritePositions = spriteBank-&gt;getPositions();
        <a class="code" href="namespaceirr.html#a0416a53257075833e7002efd0a18e804" title="32 bit unsigned variable.">u32</a> idxRect = spritePositions.size();
        <a class="code" href="namespaceirr.html#a0416a53257075833e7002efd0a18e804" title="32 bit unsigned variable.">u32</a> idxTex = spriteBank-&gt;getTextureCount();
        spriteBank-&gt;addTexture( tex );

        SGUISprite sprite;
        sprite.frameTime = frameTime;

        array&lt; SGUISprite &gt;&amp; sprites = spriteBank-&gt;getSprites();
        <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 )
        {
            spritePositions.push_back( rects[i] );

            gui::SGUISpriteFrame frame;
            frame.rectNumber = idxRect+i;
            frame.textureNumber = idxTex;
            sprite.Frames.push_back( frame );
        }

        sprites.push_back( sprite );
        <span class="keywordflow">return</span> sprites.size()-1;
    }

    <span class="keywordflow">return</span> -1;
}
</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>
<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 )
{
    <span class="keywordflow">if</span> ( !spriteBank || !driver )
        <span class="keywordflow">return</span> -1;

    video::ITexture * tex = driver-&gt;getTexture( file );
    <span class="keywordflow">if</span> ( tex )
    {
        core::array&lt; core::rect&lt;irr::s32&gt; &gt;&amp; spritePositions = spriteBank-&gt;getPositions();
        spritePositions.push_back( rect );
        array&lt; SGUISprite &gt;&amp; sprites = spriteBank-&gt;getSprites();
        spriteBank-&gt;addTexture( tex );

        gui::SGUISpriteFrame frame;
        frame.rectNumber = spritePositions.size()-1;
        frame.textureNumber = spriteBank-&gt;getTextureCount()-1;

        SGUISprite sprite;
        sprite.frameTime = 0;
        sprite.Frames.push_back( frame );

        sprites.push_back( sprite );

        <span class="keywordflow">return</span> sprites.size()-1;
    }

    <span class="keywordflow">return</span> -1;
}

<span class="keywordtype">int</span> main()
{
    <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();
    <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>)
        <span class="keywordflow">return</span> 1;

    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));
    <span class="keywordflow">if</span> (device == 0)
        <span class="keywordflow">return</span> 1; <span class="comment">// could not create selected driver.</span>

    <span class="comment">// It&#39;s sometimes of interest to know how the mouse behaves after a resize</span>
    device-&gt;setResizable(<span class="keyword">true</span>);

    device-&gt;setWindowCaption(L<span class="stringliteral">&quot;Cursor control - Irrlicht engine tutorial&quot;</span>);
    video::IVideoDriver* driver = device-&gt;getVideoDriver();
    IGUIEnvironment* env = device-&gt;getGUIEnvironment();

    gui::IGUISpriteBank * SpriteBankIcons;

    SAppContext context;
    context.Device = device;

    rect&lt; s32 &gt; rectInfoStatic(10,10, 200, 200);
    env-&gt;addStaticText (L<span class="stringliteral">&quot;Cursor state information&quot;</span>, rectInfoStatic, <span class="keyword">true</span>, <span class="keyword">true</span>);
    rectInfoStatic.UpperLeftCorner += <a class="code" href="namespaceirr_1_1core.html#ac79bc3704cf28bc1ab72d7cd1cae78d1" title="Typedef for an integer dimension.">dimension2di</a>(0, 15);
    context.InfoStatic = env-&gt;addStaticText (L<span class="stringliteral">&quot;&quot;</span>, rectInfoStatic, <span class="keyword">true</span>, <span class="keyword">true</span>);
    rect&lt; s32 &gt; rectEventBox(10,210, 200, 400);
    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>);
    rectEventBox.UpperLeftCorner += <a class="code" href="namespaceirr_1_1core.html#ac79bc3704cf28bc1ab72d7cd1cae78d1" title="Typedef for an integer dimension.">dimension2di</a>(0, 15);
    context.EventBox = env-&gt;addListBox(rectEventBox);
    rect&lt; s32 &gt; rectCursorBox(210,10, 400, 250);
    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>);
    rectCursorBox.UpperLeftCorner += <a class="code" href="namespaceirr_1_1core.html#ac79bc3704cf28bc1ab72d7cd1cae78d1" title="Typedef for an integer dimension.">dimension2di</a>(0, 15);
    context.CursorBox = env-&gt;addListBox(rectCursorBox);
    rect&lt; s32 &gt; rectSpriteBox(210,260, 400, 400);
    env-&gt;addStaticText (L<span class="stringliteral">&quot;sprites&quot;</span>, rectSpriteBox, <span class="keyword">true</span>, <span class="keyword">true</span>);
    rectSpriteBox.UpperLeftCorner += <a class="code" href="namespaceirr_1_1core.html#ac79bc3704cf28bc1ab72d7cd1cae78d1" title="Typedef for an integer dimension.">dimension2di</a>(0, 15);
    context.SpriteBox = env-&gt;addListBox(rectSpriteBox);

    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> );
    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> );
    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> );
    context.ButtonSimulateBadFps-&gt;setIsPushButton(<span class="keyword">true</span>);
    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> );

    <span class="comment">// set the names for all the system cursors</span>
    <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 )
    {
        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());
    }
</pre></div><p>Create sprites which then can be used as cursor icons. </p>
<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>));
    context.SpriteBox-&gt;setSpriteBank(SpriteBankIcons);

    <span class="comment">// create one animated icon from several files</span>
    array&lt; io::path &gt; files;
    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>) );
    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>) );
    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>) );
    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>) );
    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>) );
    SCursorSprite spriteBw; <span class="comment">// the sprite + some additional information needed for cursors</span>
    spriteBw.SpriteId = AddAnimatedIconToSpriteBank( SpriteBankIcons, driver, files, 200 );
    spriteBw.SpriteBank = SpriteBankIcons;
    spriteBw.HotSpot = position2d&lt;s32&gt;(7,7);
    context.addIcon(L<span class="stringliteral">&quot;crosshair_bw&quot;</span>, spriteBw);

    <span class="comment">// create one animated icon from one file</span>
    array&lt; rect&lt;s32&gt; &gt; iconRects;
    iconRects.push_back( rect&lt;s32&gt;(0,0, 16, 16) );
    iconRects.push_back( rect&lt;s32&gt;(16,0, 32, 16) );
    iconRects.push_back( rect&lt;s32&gt;(0,16, 16, 32) );
    iconRects.push_back( rect&lt;s32&gt;(0,16, 16, 32) );
    iconRects.push_back( rect&lt;s32&gt;(16,0, 32, 16) );
    SCursorSprite spriteCol;    <span class="comment">// the sprite + some additional information needed for cursors</span>
    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 );
    spriteCol.HotSpot = position2d&lt;s32&gt;(7,7);
    spriteCol.SpriteBank = SpriteBankIcons;
    context.addIcon(L<span class="stringliteral">&quot;crosshair_colored&quot;</span>, spriteCol);

    <span class="comment">// Create some non-animated icons</span>
    rect&lt;s32&gt; rectIcon;
    SCursorSprite spriteNonAnimated(SpriteBankIcons, 0, position2d&lt;s32&gt;(7,7));

    rectIcon = rect&lt;s32&gt;(0,0, 16, 16);
    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 );
    context.addIcon(L<span class="stringliteral">&quot;crosshair_col1&quot;</span>, spriteNonAnimated, <span class="keyword">false</span>);

    rectIcon = rect&lt;s32&gt;(16,0, 32, 16);
    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 );
    context.addIcon(L<span class="stringliteral">&quot;crosshair_col2&quot;</span>, spriteNonAnimated, <span class="keyword">false</span>);

    rectIcon = rect&lt;s32&gt;(0,16, 16, 32);
    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 );
    context.addIcon(L<span class="stringliteral">&quot;crosshair_col3&quot;</span>, spriteNonAnimated, <span class="keyword">false</span>);


    MyEventReceiver receiver(context);
    device-&gt;setEventReceiver(&amp;receiver);

    <span class="keywordflow">while</span>(device-&gt;run() &amp;&amp; driver)
    {
        <span class="comment">// if (device-&gt;isWindowActive())</span>
        {
            <a class="code" href="namespaceirr.html#a0416a53257075833e7002efd0a18e804" title="32 bit unsigned variable.">u32</a> realTimeNow = device-&gt;getTimer()-&gt;getRealTime();

            context.update();

            driver-&gt;beginScene(<span class="keyword">true</span>, <span class="keyword">true</span>, SColor(0,200,200,200));

            env-&gt;drawAll();

            <span class="comment">// draw custom sprite with Irrlicht functions for comparison. It should usually look the same as the cursors.</span>
            <span class="keywordflow">if</span> ( context.SpriteBox )
            {
                <a class="code" href="namespaceirr.html#ac66849b7a6ed16e30ebede579f9b47c6" title="32 bit signed variable.">s32</a> selectedSprite = context.SpriteBox-&gt;getSelected();
                <span class="keywordflow">if</span> ( selectedSprite &gt;= 0 &amp;&amp; context.Sprites[selectedSprite].SpriteId &gt;= 0 )
                {
                    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);
                }
            }

            driver-&gt;endScene();
        }

        <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>
        <span class="keywordflow">if</span> ( context.SimulateBadFps )
        {
            device-&gt;sleep(500); <span class="comment">// 2 fps</span>
        }
        <span class="keywordflow">else</span>
        {
            device-&gt;sleep(10);
        }
    }

    device-&gt;drop();

    <span class="keywordflow">return</span> 0;
}
</pre></div> </div></div>
</div>
  <div id="nav-path" class="navpath">
    <ul>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
<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>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>


    <li class="footer">
<a href="http://irrlicht.sourceforge.net" target="_blank">Irrlicht 
Engine</a> Documentation &copy; 2003-2012 by Nikolaus Gebhardt. Generated on Sun Nov 17 2013 20:18:42 for Irrlicht 3D Engine by
<a href="http://www.doxygen.org/index.html" target="_blank">Doxygen</a> 1.7.5.1 </li>
   </ul>
 </div>


</body>
</html>