Include a header file required for build on mac 10.4
[supercollider.git] / Help / GUI / Cocoa-GUI / SCModalWindow.html
blob73a96eb43535f8dacea821a1e5e73dcbd2e8cce0
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.35">
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: 9.0px Monaco; min-height: 12.0px}
13 p.p4 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica; color: #001bec}
14 p.p5 {margin: 0.0px 0.0px 0.0px 0.0px; font: 14.0px Helvetica}
15 p.p6 {margin: 0.0px 0.0px 0.0px 0.0px; font: 14.0px Helvetica; min-height: 17.0px}
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 57.0px; text-indent: -57.0px; font: 12.0px Helvetica; min-height: 14.0px}
19 p.p10 {margin: 0.0px 0.0px 0.0px 85.0px; text-indent: -85.0px; font: 12.0px Helvetica}
20 p.p11 {margin: 0.0px 0.0px 0.0px 57.0px; text-indent: -57.0px; font: 14.0px Helvetica}
21 p.p12 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco; color: #ae1a19}
22 p.p13 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco}
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: #002afb}
26 span.s3 {color: #000000}
27 span.s4 {text-decoration: underline}
28 span.s5 {color: #001dfd}
29 span.s6 {color: #0038f1}
30 span.s7 {color: #0016bd}
31 span.s8 {color: #606060}
32 span.s9 {color: #2b7000}
33 span.Apple-tab-span {white-space:pre}
34 </style>
35 </head>
36 <body>
37 <p class="p1"><span class="s1"><b>SCModalWindow<span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></b></span><b>an application modal version of SCWindow</b><span class="s1"><b><span class="Apple-tab-span"> </span></b></span></p>
38 <p class="p2"><br></p>
39 <p class="p1"><b>Inherits from: </b><a href="../../Core/Object.html"><span class="s2"><b>Object</b></span></a><b> : </b><a href="SCWindow.html"><span class="s2"><b>SCWindow</b></span></a><b> : SCAbstractModalWindow</b></p>
40 <p class="p3"><br></p>
41 <p class="p1">SCModalWindow is an application modal version of SCWindow. This means that it blocks all other user input until it is dismissed. It is thus useful for alerts, preference panels and other situations which should limit user input.</p>
42 <p class="p2"><br></p>
43 <p class="p4"><span class="s3"><b>See also: </b><a href="SCWindow.html"><span class="s4">SCWindow</span></a>, <a href="SCModalSheet.html"><span class="s4">SCModalSheet</span></a></span></p>
44 <p class="p2"><br></p>
45 <p class="p5"><b>Dismissing App Modal Windows</b></p>
46 <p class="p2"><br></p>
47 <p class="p1">SCModalWindows have non-functional OSX close buttons. It is therefore very important that you add an SCButton or some other GUI widget to allow the user to close the window. As an 'escape hatch' pressing the esc key will kill any application modal window.</p>
48 <p class="p2"><br></p>
49 <p class="p5"><b>Blocking and Multiple App Modal Windows</b></p>
50 <p class="p6"><br></p>
51 <p class="p1">There can only be one active SCModalWindow at any given time. If you attempt to create more than one they will be cued and launched in turn as each is dismissed.</p>
52 <p class="p2"><br></p>
53 <p class="p1"><b>N.B.</b> If you launch multiple app modal windows which will alter the same data, you may need to take special care. You can use the <b>*current </b>class method to check if an app modal window is currently running, and add a <a href="../../Core/Kernel/Function.html"><span class="s5">Function</span></a> to its onClose in order to check if the additional window is still needed once the first one has closed. See below for an example of how to do this.</p>
54 <p class="p2"><br></p>
55 <p class="p5"><b>Creation / Class Methods</b></p>
56 <p class="p7"><br></p>
57 <p class="p8"><b><span class="Apple-tab-span"> </span>*new (name, bounds, resizable, border, server, scroll)</b></p>
58 <p class="p9"><b><span class="Apple-tab-span"> </span></b></p>
59 <p class="p8"><b><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></b>Creates a new SCModalWindow instance. You do not need to call <b>front</b> on it to make it visible.</p>
60 <p class="p10"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><b>name </b>- The name that will be displayed in the title bar. An instance of <a href="../../Collections/String.html"><span class="s6">String</span></a> or <a href="../../Core/Symbol.html"><span class="s6">Symbol</span></a>. The default is 'panel'.</p>
61 <p class="p10"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><b>bounds</b> - A <a href="../../Geometry/Rect.html"><span class="s6">Rect</span></a> or <a href="../../Geometry/Point.html"><span class="s2">Point</span></a> specifying the size of the window. The size does not include the title bar. <b>N.B. </b>App Modal windows are centred on the screen when created, so if you wish to move it for some reason you will need to call <b>bounds_</b> on the window after creation.</p>
62 <p class="p10"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><b>resizable</b> - A <a href="../../Core/Boolean.html"><span class="s6">Boolean</span></a> indicating whether this window can be resized by the user. The default is false.</p>
63 <p class="p10"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><b>border</b> - A <a href="../../Core/Boolean.html"><span class="s6">Boolean</span></a> indicating whether this window has a border. Borderless windows have no title bar. The default is true.</p>
64 <p class="p10"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><b>server</b> - This is a dummy argument which is here to provide compatibility with SwingOSC and has no effect. See <a href="../GUI-Tools/GUI.html"><span class="s6">GUI</span></a> for more details.</p>
65 <p class="p10"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><b>scroll</b> - A <a href="../../Core/Boolean.html"><span class="s6">Boolean</span></a> indicating whether this window will add scrollers if its contents exceed its bounds. If this is set to true resize settings will be ignored for enclosed views. See <a href="SCScrollTopView.html"><span class="s6">SCScrollTopView</span></a>. The default is false.</p>
66 <p class="p7"><br></p>
67 <p class="p7"><br></p>
68 <p class="p11"><b>Accessing Instance and Class Variables</b></p>
69 <p class="p9"><span class="Apple-tab-span"> </span></p>
70 <p class="p8"><b><span class="Apple-tab-span"> </span>*current</b></p>
71 <p class="p9"><b><span class="Apple-tab-span"> </span></b><span class="Apple-tab-span"> </span></p>
72 <p class="p8"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>This returns the currently running app modal window, if it exists, or nil otherwise.</p>
73 <p class="p7"><br></p>
74 <p class="p7"><br></p>
75 <p class="p11"><b>Examples</b></p>
76 <p class="p3"><br></p>
77 <p class="p12">// simple example</p>
78 <p class="p13">(</p>
79 <p class="p13"><span class="s7">var</span> person, win;</p>
80 <p class="p14"><span class="s3">win = </span><span class="s7">SCModalWindow</span><span class="s3">(</span>"What kind of person?"<span class="s3">, 230@60);</span></p>
81 <p class="p13">win.view.decorator = <span class="s7">FlowLayout</span>(win.view.bounds);</p>
82 <p class="p13"><span class="s7">EZPopUpMenu</span>(win, 210@20, <span class="s8">"Are you:"</span>, [<span class="s9">'Dog Person'</span>-&gt;{person = <span class="s8">"Dog Person"</span>}, <span class="s9">'Cat Person'</span>-&gt;{person = <span class="s8">"Cat Person"</span>}], initAction: <span class="s7">true</span>);</p>
83 <p class="p13">win.view.decorator.nextLine.nextLine;</p>
84 <p class="p13"><span class="s7">SCButton</span>(win, <span class="s7">Rect</span>(20,20,210,20))</p>
85 <p class="p13"><span class="Apple-tab-span"> </span>.states_([</p>
86 <p class="p13"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>[<span class="s8">"OK"</span>, <span class="s7">Color</span>.black, <span class="s7">Color</span>.white]</p>
87 <p class="p13"><span class="Apple-tab-span"> </span>])</p>
88 <p class="p13"><span class="Apple-tab-span"> </span>.onClose_({(<span class="s8">"You're a"</span> + person).postln})</p>
89 <p class="p13"><span class="Apple-tab-span"> </span>.action_({ win.close });</p>
90 <p class="p13">)</p>
91 <p class="p3"><br></p>
92 <p class="p12">// multiple windows with state check</p>
93 <p class="p12">// checks against data1 and data2 to see if windows are still needed</p>
94 <p class="p13">(</p>
95 <p class="p13"><span class="s7">var</span> window1, window2, window3;</p>
96 <p class="p13"><span class="s7">var</span> func2, func3;</p>
97 <p class="p13"><span class="s7">var</span> data1 = <span class="s7">false</span>, data2 = <span class="s7">false</span>;</p>
98 <p class="p3"><br></p>
99 <p class="p12">// 1</p>
100 <p class="p13">window1 = <span class="s7">SCModalWindow</span>.new(<span class="s8">"1"</span>);</p>
101 <p class="p13"><span class="s7">SCButton</span>(window1, <span class="s7">Rect</span>(20,20,340,30))</p>
102 <p class="p13"><span class="Apple-tab-span"> </span>.states_([</p>
103 <p class="p13"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>[<span class="s8">"OK"</span>, <span class="s7">Color</span>.black, <span class="s7">Color</span>.red]</p>
104 <p class="p13"><span class="Apple-tab-span"> </span>])</p>
105 <p class="p13"><span class="Apple-tab-span"> </span>.action_({</p>
106 <p class="p12"><span class="s3"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>data1 = </span><span class="s7">true</span><span class="s3">; </span>// we will still need 2</p>
107 <p class="p13"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>window1.close;</p>
108 <p class="p13"><span class="Apple-tab-span"> </span>});</p>
109 <p class="p3"><br></p>
110 <p class="p12">// 2</p>
111 <p class="p13">func2 = {</p>
112 <p class="p13"><span class="s7">var</span> curr;</p>
113 <p class="p13">curr = <span class="s7">SCModalWindow</span>.current;</p>
114 <p class="p13">if(curr.isNil, {</p>
115 <p class="p13"><span class="Apple-tab-span"> </span>if(data1, {</p>
116 <p class="p13"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>window2 = <span class="s7">SCModalWindow</span>.new(<span class="s8">"2"</span>);</p>
117 <p class="p13"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="s7">SCButton</span>(window2, <span class="s7">Rect</span>(20,20,340,30))</p>
118 <p class="p13"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>.states_([</p>
119 <p class="p13"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>[<span class="s8">"OK"</span>, <span class="s7">Color</span>.black, <span class="s7">Color</span>.red]</p>
120 <p class="p13"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>])</p>
121 <p class="p13"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>.action_({</p>
122 <p class="p12"><span class="s3"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>data2 = </span><span class="s7">false</span><span class="s3">; </span>// we won't still need 3</p>
123 <p class="p13"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>window2.close;</p>
124 <p class="p13"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>}).onClose_({2.postln;});</p>
125 <p class="p13"><span class="Apple-tab-span"> </span>});</p>
126 <p class="p13">}, {curr.onClose = curr.onClose.addFunc(func2)});</p>
127 <p class="p13">};</p>
128 <p class="p13">func2.value;</p>
129 <p class="p3"><br></p>
130 <p class="p12">// 3</p>
131 <p class="p13">func3 = {</p>
132 <p class="p13"><span class="s7">var</span> curr;</p>
133 <p class="p13">curr = <span class="s7">SCModalWindow</span>.current;</p>
134 <p class="p13">if(curr.isNil, {</p>
135 <p class="p13"><span class="Apple-tab-span"> </span>if(data2, {</p>
136 <p class="p13"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>window3 = <span class="s7">SCModalWindow</span>.new(<span class="s8">"3"</span>);</p>
137 <p class="p13"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="s7">SCButton</span>(window3, <span class="s7">Rect</span>(20,20,340,30))</p>
138 <p class="p13"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>.states_([</p>
139 <p class="p13"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>[<span class="s8">"OK"</span>, <span class="s7">Color</span>.black, <span class="s7">Color</span>.red]</p>
140 <p class="p13"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>])</p>
141 <p class="p13"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>.action_({ window3.close; })</p>
142 <p class="p13"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>.onClose_({3.postln;});</p>
143 <p class="p13"><span class="Apple-tab-span"> </span>});</p>
144 <p class="p13">}, {curr.onClose = curr.onClose.addFunc(func3)});</p>
145 <p class="p13">};</p>
146 <p class="p13">func3.value;</p>
147 <p class="p13">)</p>
148 <p class="p3"><br></p>
149 </body>
150 </html>