supernova: c++11 compile fix
[supercollider.git] / Help / GUI / Cocoa-GUI / SCDragSource.html
blobf1b2ef1154571672b5ff50361c8058fe7bfb8bd8
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.43">
9 <style type="text/css">
10 p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.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; color: #001ee6}
13 p.p4 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco; min-height: 12.0px}
14 p.p5 {margin: 0.0px 0.0px 0.0px 57.0px; text-indent: -57.0px; font: 12.0px Helvetica; min-height: 14.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 57.0px; text-indent: -57.0px; font: 9.0px Monaco; min-height: 12.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 85.0px; text-indent: -85.0px; font: 12.0px Helvetica}
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 57.0px; text-indent: -57.0px; font: 14.0px Helvetica; min-height: 17.0px}
21 p.p12 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco}
22 p.p13 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco; color: #bf0000}
23 p.p14 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco; color: #606060}
24 span.s1 {font: 18.0px Helvetica}
25 span.s2 {color: #000000}
26 span.s3 {color: #505fb1}
27 span.s4 {color: #3850cb}
28 span.s5 {color: #6f717e}
29 span.s6 {color: #0000bf}
30 span.s7 {color: #007300}
31 span.s8 {font: 11.0px Monaco}
32 span.s9 {color: #606060}
33 span.Apple-tab-span {white-space:pre}
34 </style>
35 </head>
36 <body>
37 <p class="p1"><span class="s1"><b>SCDragSource<span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></b></span><b>a gui object source for drag and drop</b><span class="s1"><b><span class="Apple-tab-span"> </span></b></span></p>
38 <p class="p2"><br></p>
39 <p class="p3"><span class="s2"><b>Inherits from: </b><a href="../../Core/Object.html"><b>Object</b></a><b> : </b><a href="SCView.html"><b>SCView</b></a><b> : </b><a href="SCStaticTextBase.html"><b>SCStaticTextBase</b></a><b> : </b><a href="SCDragView.html"><b>SCDragView</b></a></span></p>
40 <p class="p4"><br></p>
41 <p class="p1">A gui object which acts as a source a source for drag and drop. See <a href="SCDragView.html"><span class="s3">SCDragView</span></a> for usage and examples, and <a href="SCView.html"><span class="s4">SCView</span></a> for a general description of the drag and drop mechanism.</p>
42 <p class="p5"><br></p>
43 <p class="p6"><b>Creation / Class Methods</b></p>
44 <p class="p7"><br></p>
45 <p class="p8"><b><span class="Apple-tab-span"> </span>*new (parent, bounds)</b></p>
46 <p class="p5"><b><span class="Apple-tab-span"> </span></b></p>
47 <p class="p9"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><b>parent </b>- The parent view.</p>
48 <p class="p9"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><b>bounds </b>- An instance of <a href="../../Geometry/Rect.html"><span class="s5">Rect</span></a>, or a <a href="../../Geometry/Point.html"><span class="s5">Point</span></a> indicating width@height.</p>
49 <p class="p5"><br></p>
50 <p class="p10"><b>Examples</b></p>
51 <p class="p11"><br></p>
52 <p class="p12">(</p>
53 <p class="p13"><span class="s2">s.waitForBoot({<span class="Apple-tab-span"> </span></span>//only needed if you are using sound</p>
54 <p class="p12"><span class="Apple-tab-span"> </span>w=<span class="s6">Window</span>.new.front;</p>
55 <p class="p4"><span class="Apple-tab-span"> </span></p>
56 <p class="p13"><span class="s2"><span class="Apple-tab-span"> </span></span>// store various kinds of objects in the drag source</p>
57 <p class="p4"><span class="Apple-tab-span"> </span></p>
58 <p class="p13"><span class="s2"><span class="Apple-tab-span"> </span></span>// a string source</p>
59 <p class="p12"><span class="Apple-tab-span"> </span>a=<span class="s6">DragSource</span>(w,<span class="s6">Rect</span>(10,10,150,20)).align_(<span class="s7">\center</span>);</p>
60 <p class="p14"><span class="s2"><span class="Apple-tab-span"> </span>a.object=</span>"I am a string source"<span class="s2">;</span></p>
61 <p class="p4"><span class="Apple-tab-span"> </span></p>
62 <p class="p13"><span class="s2"><span class="Apple-tab-span"> </span></span>// a Float source</p>
63 <p class="p12"><span class="Apple-tab-span"> </span>b=<span class="s6">DragSource</span>(w,<span class="s6">Rect</span>(10,40,150,20)).align_(<span class="s7">\center</span>);</p>
64 <p class="p12"><span class="Apple-tab-span"> </span>b.object=2.234;</p>
65 <p class="p4"><span class="Apple-tab-span"> </span></p>
66 <p class="p13"><span class="s2"><span class="Apple-tab-span"> </span></span>// a Point source</p>
67 <p class="p12"><span class="Apple-tab-span"> </span>c=<span class="s6">DragSource</span>(w,<span class="s6">Rect</span>(10,70,150,20)).align_(<span class="s7">\center</span>);</p>
68 <p class="p12"><span class="Apple-tab-span"> </span>c.object=<span class="s6">Point</span>(20,30);</p>
69 <p class="p4"><span class="Apple-tab-span"> </span></p>
70 <p class="p13"><span class="s2"><span class="Apple-tab-span"> </span></span>// A sound function source</p>
71 <p class="p13"><span class="s2"><span class="Apple-tab-span"> </span></span>// dragLabel_() is used for the label while dragging</p>
72 <p class="p12"><span class="Apple-tab-span"> </span>d=<span class="s6">DragSource</span>(w,<span class="s6">Rect</span>(10,100,150,20)).align_(<span class="s7">\center</span>);</p>
73 <p class="p12"><span class="Apple-tab-span"> </span>d.object={<span class="s6">Synth</span>(<span class="s7">\default</span>)};</p>
74 <p class="p14"><span class="s2"><span class="Apple-tab-span"> </span>d.dragLabel=</span>" I am a sound function.\n My dragLabel_() is set \n to inform you about that "<span class="s2">;</span></p>
75 <p class="p4"><span class="Apple-tab-span"> </span></p>
76 <p class="p13"><span class="s2"><span class="Apple-tab-span"> </span></span>// A sound function source</p>
77 <p class="p13"><span class="s2"><span class="Apple-tab-span"> </span></span>//here the string label is independent of the content type (Function)</p>
78 <p class="p13"><span class="s2"><span class="Apple-tab-span"> </span></span>// dragLabel_() is used for the label while dragging</p>
79 <p class="p12"><span class="Apple-tab-span"> </span>f=<span class="s6">DragSource</span>(w,<span class="s6">Rect</span>(10,130,150,20)).align_(<span class="s7">\center</span>).setBoth_(<span class="s6">false</span>);</p>
80 <p class="p12"><span class="Apple-tab-span"> </span>f.object={{<span class="s6">SinOsc</span>.ar(440,0,0.4)}.play};</p>
81 <p class="p14"><span class="s2"><span class="Apple-tab-span"> </span>f.string=</span>"My label is independent"<span class="s2">;</span></p>
82 <p class="p14"><span class="s2"><span class="Apple-tab-span"> </span>f.dragLabel=</span>" My dragLabel_() says \n I am dragging a sound function "<span class="s2">;</span></p>
83 <p class="p4"><span class="Apple-tab-span"> </span></p>
84 <p class="p13"><span class="s2"><span class="Apple-tab-span"> </span></span>// receive anthing</p>
85 <p class="p12"><span class="Apple-tab-span"> </span>g=<span class="s6">DragSink</span>(w,<span class="s6">Rect</span>(170,10,200,20)).align_(<span class="s7">\center</span>);</p>
86 <p class="p14"><span class="s2"><span class="Apple-tab-span"> </span>g.string=</span>"recieve anything, do nothing"<span class="s2">;</span></p>
87 <p class="p4"><span class="Apple-tab-span"> </span></p>
88 <p class="p13"><span class="s2"><span class="Apple-tab-span"> </span></span>// receive only floats</p>
89 <p class="p12"><span class="Apple-tab-span"> </span>g=<span class="s6">DragSink</span>(w,<span class="s6">Rect</span>(170,40,200,20)).align_(<span class="s7">\center</span>);</p>
90 <p class="p14"><span class="s2"><span class="Apple-tab-span"> </span>g.string=</span>"I only like floats"<span class="s2">;</span></p>
91 <p class="p12"><span class="Apple-tab-span"> </span>g<span class="s8">.</span>canReceiveDragHandler = { <span class="s6">View</span>.currentDrag.isFloat };</p>
92 <p class="p4"><span class="Apple-tab-span"> </span></p>
93 <p class="p13"><span class="s2"><span class="Apple-tab-span"> </span></span>// receive only numbers and points, and convert them to rects</p>
94 <p class="p12"><span class="Apple-tab-span"> </span>h=<span class="s6">DragSink</span>(w,<span class="s6">Rect</span>(170,70,200,20)).align_(<span class="s7">\center</span>);</p>
95 <p class="p14"><span class="s2"><span class="Apple-tab-span"> </span>h.string=</span>"I convert to Rect"<span class="s2">;</span></p>
96 <p class="p12"><span class="Apple-tab-span"> </span><span class="s8">h.</span>canReceiveDragHandler = {<span class="s6">View</span>.currentDrag.isKindOf(<span class="s6">Number</span>)||<span class="s6">View</span>.currentDrag.isKindOf(<span class="s6">Point</span>)};</p>
97 <p class="p12"><span class="Apple-tab-span"> </span>h.receiveDragHandler={<span class="s6">arg</span> v; h.object=<span class="s6">View</span>.currentDrag.asRect};</p>
98 <p class="p4"><span class="Apple-tab-span"> </span></p>
99 <p class="p13"><span class="s2"><span class="Apple-tab-span"> </span></span>// receive only functions, and try to play them</p>
100 <p class="p12"><span class="Apple-tab-span"> </span>i=<span class="s6">DragSink</span>(w,<span class="s6">Rect</span>(170,100,200,20)).align_(<span class="s7">\center</span>);</p>
101 <p class="p14"><span class="s2"><span class="Apple-tab-span"> </span>i.string=</span>"I evaluate a (sound) function"<span class="s2">;</span></p>
102 <p class="p12"><span class="Apple-tab-span"> </span><span class="s8">i.</span>canReceiveDragHandler = {<span class="s6">View</span>.currentDrag.isKindOf(<span class="s6">Function</span>)};</p>
103 <p class="p12"><span class="Apple-tab-span"> </span>i.receiveDragHandler={<span class="s6">arg</span> v;</p>
104 <p class="p12"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>i.object=<span class="s6">View</span>.currentDrag.value;</p>
105 <p class="p14"><span class="s2"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>i.string=</span>"click here for silence"<span class="s2">;</span></p>
106 <p class="p12"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>i.background_(<span class="s6">Color</span>.red)};</p>
107 <p class="p12"><span class="Apple-tab-span"> </span>i.mouseDownAction_({i.object.free;i.string=<span class="s9">"I evaluate a (sound) function"</span>;i.background_(<span class="s6">Color</span>.clear)});</p>
108 <p class="p4"><span class="Apple-tab-span"> </span></p>
109 <p class="p12"><span class="Apple-tab-span"> </span><span class="s6">StaticText</span>(w,<span class="s6">Rect</span>(10,200,380,50))</p>
110 <p class="p12"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>.stringColor_(<span class="s6">Color</span>.white)</p>
111 <p class="p14"><span class="s2"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>.string_(</span>"Try dragging any item on the left -----&gt; to any item on the right"<span class="s2">);</span></p>
112 <p class="p4"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></p>
113 <p class="p12">});</p>
114 <p class="p12">)</p>
115 <p class="p4"><br></p>
116 <p class="p4"><br></p>
117 </body>
118 </html>