Include a header file required for build on mac 10.4
[supercollider.git] / Help / GUI / SimpleController.html
blob499dd986d58810ea27fea7d47895bf1c5e3b91e0
1 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
2 <html>
3 <head>
4 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
5 <meta http-equiv="Content-Style-Type" content="text/css">
6 <title></title>
7 <meta name="Generator" content="Cocoa HTML Writer">
8 <meta name="CocoaVersion" content="949.46">
9 <style type="text/css">
10 p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 18.0px Helvetica}
11 p.p2 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica; min-height: 14.0px}
12 p.p3 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica}
13 p.p4 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica; color: #002de8; min-height: 14.0px}
14 p.p5 {margin: 0.0px 0.0px 0.0px 0.0px; font: 18.0px Helvetica; min-height: 22.0px}
15 p.p6 {margin: 0.0px 0.0px 0.0px 0.0px; font: 14.0px Helvetica}
16 p.p7 {margin: 0.0px 0.0px 0.0px 0.0px; font: 14.0px Helvetica; min-height: 17.0px}
17 p.p8 {margin: 0.0px 0.0px 0.0px 57.0px; text-indent: -57.0px; font: 12.0px Helvetica}
18 p.p9 {margin: 0.0px 0.0px 0.0px 57.0px; text-indent: -57.0px; font: 12.0px Helvetica; min-height: 14.0px}
19 p.p10 {margin: 0.0px 0.0px 0.0px 57.0px; text-indent: -57.0px; font: 14.0px Helvetica}
20 p.p11 {margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color: #93320e; min-height: 14.0px}
21 p.p12 {margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color: #000000}
22 p.p13 {margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color: #000000; min-height: 14.0px}
23 p.p14 {margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color: #0000bf}
24 p.p15 {margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color: #bf0000}
25 span.s1 {color: #0000ff}
26 span.s2 {color: #0000bf}
27 span.s3 {color: #007300}
28 span.s4 {color: #000000}
29 span.s5 {color: #606060}
30 span.Apple-tab-span {white-space:pre}
31 </style>
32 </head>
33 <body>
34 <p class="p1"><b>SimpleController</b></p>
35 <p class="p2"><br></p>
36 <p class="p3">SimpleController can be used as a controller according to the model-view-controller (M-V-C) paradigm. It provides an <a href="../Collections/IdentityDictionary.html"><span class="s1">IdentityDictionary</span></a> of actions, which are called whenever the attached model sends a notification by calling <b>changed</b>.</p>
37 <p class="p4"><br></p>
38 <p class="p5"><br></p>
39 <p class="p6"><b>Class Methods</b></p>
40 <p class="p7"><br></p>
41 <p class="p8"><b><span class="Apple-tab-span"> </span>*new(model)</b></p>
42 <p class="p9"><b><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></b></p>
43 <p class="p8"><b><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></b>Creates a SimpleController instance with the <b>model</b> to be observed. <b>Model</b> can an object of any class</p>
44 <p class="p9"><br></p>
45 <p class="p6"><b>Instance Methods</b></p>
46 <p class="p2"><br></p>
47 <p class="p8"><span class="Apple-tab-span"> </span><b>put(what, action)</b></p>
48 <p class="p9"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></p>
49 <p class="p8"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>Register an action, which is called when the model invokes <b>changed(what, moreArgs)</b>.</p>
50 <p class="p9"><span class="Apple-tab-span"> </span></p>
51 <p class="p9"><br></p>
52 <p class="p10"><b>Examples:</b></p>
53 <p class="p11"><br></p>
54 <p class="p12">(</p>
55 <p class="p12"><span class="Apple-tab-span"> </span><span class="s2">var</span> controller, model, view;</p>
56 <p class="p13"><span class="Apple-tab-span"> </span></p>
57 <p class="p12"><span class="Apple-tab-span"> </span>model = <span class="s2">Ref</span>(0.5);</p>
58 <p class="p12"><span class="Apple-tab-span"> </span>controller = <span class="s2">SimpleController</span>(model);</p>
59 <p class="p12"><span class="Apple-tab-span"> </span>controller.put(<span class="s3">\value</span>,<span class="Apple-converted-space"> </span></p>
60 <p class="p14"><span class="s4"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>{</span>|theChanger, what, moreArgs|<span class="s4"><span class="Apple-converted-space"> </span></span></p>
61 <p class="p12"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>view.value_(theChanger.value);</p>
62 <p class="p12"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>});</p>
63 <p class="p13"><span class="Apple-tab-span"> </span></p>
64 <p class="p12"><span class="Apple-tab-span"> </span>view = <span class="s2">Slider</span>(<span class="s2">Window</span>(<span class="s5">"slider"</span>, <span class="s2">Rect</span>(100, 100, 330, 38)).front, <span class="s2">Rect</span>(5, 5, 320, 20));</p>
65 <p class="p12"><span class="Apple-tab-span"> </span>view.onClose_{controller.remove};</p>
66 <p class="p13"><span class="Apple-tab-span"> </span></p>
67 <p class="p15"><span class="s4"><span class="Apple-tab-span"> </span></span>// run a routine to change the model's value:</p>
68 <p class="p12"><span class="Apple-tab-span"> </span>r{</p>
69 <p class="p12"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>100.do{</p>
70 <p class="p12"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>model.value_(1.0.rand.postln).changed(<span class="s3">\value</span>);</p>
71 <p class="p12"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>0.5.wait;</p>
72 <p class="p12"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>}</p>
73 <p class="p12"><span class="Apple-tab-span"> </span>}.play(<span class="s2">AppClock</span>)</p>
74 <p class="p12">)</p>
75 </body>
76 </html>