Include a header file required for build on mac 10.4
[supercollider.git] / Help / GUI / Cocoa-GUI / SCWindow.html
blob66169eac9512ca624c35716b161d6c1a38a4cfd3
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.54">
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: #0000eb}
14 p.p5 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica; color: #0000b4; 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 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: 9.0px Monaco}
21 p.p12 {margin: 0.0px 0.0px 0.0px 57.0px; text-indent: -57.0px; font: 9.0px Monaco; color: #ba0000}
22 p.p13 {margin: 0.0px 0.0px 0.0px 57.0px; text-indent: -57.0px; font: 14.0px Helvetica}
23 p.p14 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco}
24 p.p15 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco; color: #ba0000}
25 span.s1 {font: 18.0px Helvetica}
26 span.s2 {color: #0000b4}
27 span.s3 {color: #000000}
28 span.s4 {text-decoration: underline}
29 span.s5 {text-decoration: underline ; color: #0000b4}
30 span.s6 {text-decoration: underline ; color: #0000eb}
31 span.s7 {color: #3c3c3c}
32 span.s8 {color: #ba0000}
33 span.s9 {font: 9.0px Monaco}
34 span.s10 {color: #006206}
35 span.Apple-tab-span {white-space:pre}
36 </style>
37 </head>
38 <body>
39 <p class="p1"><span class="s1"><b>SCWindow<span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></b></span><b>Cocoa user interface window</b><span class="s1"><b><span class="Apple-tab-span"> </span></b></span></p>
40 <p class="p2"><br></p>
41 <p class="p1"><b>Inherits from: </b><a href="../../Core/Object.html"><span class="s2"><b>Object</b></span></a></p>
42 <p class="p3"><br></p>
43 <p class="p1">A class representing a user interface window in the Cocoa gui system on OSX.</p>
44 <p class="p2"><br></p>
45 <p class="p1">Besides providing a window in which to host <a href="SCView.html"><span class="s2">SCView</span></a>, SCWindow is also a canvas on which you can draw using Pen. See the <a href="SCPen.html"><span class="s2">SCPen</span></a> file for many examples.</p>
46 <p class="p2"><br></p>
47 <p class="p1">For modal versions of SCWindow see <a href="SCModalWindow.html"><span class="s2">SCModalWindow</span></a> and <a href="SCModalSheet.html"><span class="s2">SCModalSheet</span></a><span class="s2">.</span></p>
48 <p class="p2"><br></p>
49 <p class="p4"><span class="s3"><b>See also: </b><a href="SCView.html"><span class="s4">SCView</span></a>, <a href="../GUI-Tools/GUI.html"><span class="s4">GUI</span></a>, <a href="SCScrollTopView.html"><span class="s4">SCScrollTopView</span></a>, <a href="SCPen.html"><span class="s5">SCPen</span></a></span><span class="s2">, <a href="SCUserView.html"><span class="s6">SCUserView</span></a>, <a href="SCImage/SCImage.html"><span class="s6">SCImage</span></a></span><span class="s5">,</span><span class="s3"> <a href="SCModalWindow.html"><span class="s5">SCModalWindow</span></a>, <a href="SCModalSheet.html"><span class="s5">SCModalSheet</span></a></span></p>
50 <p class="p4"><span class="s3"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><a href="SCVLayoutView.html"><span class="s5">SCVLayoutView</span></a></span><span class="s2">, <a href="SCHLayoutView.html"><span class="s6">SCHLayoutView</span></a>, <a href="../GUI-Tools/FlowLayout.html"><span class="s6">FlowLayout</span></a></span></p>
51 <p class="p5"><span class="Apple-tab-span"> </span></p>
52 <p class="p6"><b>Some Important Issues Regarding SCWindow</b></p>
53 <p class="p2"><br></p>
54 <p class="p1">If you try to set parameters of a Window or a GUI widget from a<span class="Apple-converted-space">  </span>Routine , which uses the <a href="../../Scheduling/SystemClock.html"><span class="s2">SystemClock</span></a> by default, you must wrap it in a deferred function: { myWindow.bounds_( Rect(100,500,200,200) ) }.defer .<span class="Apple-converted-space">  </span>You do not need to use .defer, if you use the <a href="../../Scheduling/AppClock.html"><span class="s2">AppClock</span></a>.</p>
55 <p class="p2"><br></p>
56 <p class="p6"><b>Creation / Class Methods</b></p>
57 <p class="p7"><br></p>
58 <p class="p8"><b><span class="Apple-tab-span"> </span>*new(name, bounds, resizable, border, server, scroll)</b></p>
59 <p class="p9"><b><span class="Apple-tab-span"> </span></b></p>
60 <p class="p8"><b><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></b>Creates a new SCWindow instance. You will need to call <b>front</b> (see below) on it before it will be visible.</p>
61 <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="s2">String</span></a> or <a href="../../Core/Symbol.html"><span class="s2">Symbol</span></a>. The default is 'panel'.</p>
62 <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="s2">Rect</span></a> specifying the location and size of the window. The size does not include the title bar. <b>N.B. </b>Location is measured from the <i>bottom left</i><span class="Apple-tab-span"> </span>of the screen. This is different from view location, which is measured from the <i>upper left</i> of the window (not including the title bar). The default is Rect(128, 64, 400, 400).</p>
63 <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="s2">Boolean</span></a> indicating whether this window can be resized by the user. The default is true.</p>
64 <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="s2">Boolean</span></a> indicating whether this window has a border. Borderless windows have no title bar and thus can only be closed in code. The default is true.</p>
65 <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="s2">GUI</span></a> for more details.</p>
66 <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="s2">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="s2">SCScrollTopView</span></a>. The default is false.</p>
67 <p class="p9"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></p>
68 <p class="p11"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>w = <span class="s2">Window</span>.new;</p>
69 <p class="p12"><span class="s3"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>w.front; </span>// draw it and bring it to the front</p>
70 <p class="p7"><br></p>
71 <p class="p8"><b><span class="Apple-tab-span"> </span>*allWindows</b></p>
72 <p class="p9"><b><span class="Apple-tab-span"> </span></b></p>
73 <p class="p8"><b><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></b>Returns an <a href="../../Collections/Array.html"><span class="s2">Array</span></a> of all open SCWindows.</p>
74 <p class="p9"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></p>
75 <p class="p8"><b><span class="Apple-tab-span"> </span>*initAction</b></p>
76 <p class="p8"><b><span class="Apple-tab-span"> </span>*initAction_(func)</b></p>
77 <p class="p9"><b><span class="Apple-tab-span"> </span></b></p>
78 <p class="p8"><b><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></b>Get/set and action to be performed when any window is created.</p>
79 <p class="p8"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><b>func</b> - An instance of <a href="../../Core/Kernel/Function.html"><span class="s2">Function</span></a> or <a href="../../Core/Kernel/FunctionList.html"><span class="s2">FunctionList</span></a></p>
80 <p class="p9"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></p>
81 <p class="p8"><b><span class="Apple-tab-span"> </span>*closeAll</b></p>
82 <p class="p9"><b><span class="Apple-tab-span"> </span></b></p>
83 <p class="p8"><b><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></b>Closes all open SCWindows.</p>
84 <p class="p9"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></p>
85 <p class="p8"><b><span class="Apple-tab-span"> </span>*screenBounds</b></p>
86 <p class="p9"><b><span class="Apple-tab-span"> </span></b></p>
87 <p class="p8"><b><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></b>Returns a <a href="../../Geometry/Rect.html"><span class="s2">Rect</span></a> indicating the bounds of the current screen in pixels.</p>
88 <p class="p9"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></p>
89 <p class="p9"><br></p>
90 <p class="p13"><b>Instance Methods</b></p>
91 <p class="p9"><span class="Apple-tab-span"> </span></p>
92 <p class="p8"><b><span class="Apple-tab-span"> </span>addFlowLayout(margin, gap)</b></p>
93 <p class="p9"><b><span class="Apple-tab-span"> </span></b><span class="Apple-tab-span"> </span></p>
94 <p class="p8"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>A convenience utility which sets view.decorator to FlowLayout and returns the decorator. See FlowLayout for examples.</p>
95 <p class="p8"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><b>margin</b> - An instance of <a href="../../Geometry/Point.html"><span class="s2">Point</span></a></p>
96 <p class="p8"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><b>gap</b> - An instance of <a href="../../Geometry/Point.html"><span class="s2">Point</span></a></p>
97 <p class="p9"><br></p>
98 <p class="p8"><b><span class="Apple-tab-span"> </span>acceptsClickThrough_(boolean)</b></p>
99 <p class="p8"><b><span class="Apple-tab-span"> </span>acceptsClickThrough</b></p>
100 <p class="p9"><b><span class="Apple-tab-span"> </span></b><span class="Apple-tab-span"> </span></p>
101 <p class="p8"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>Set or return a <a href="../../Core/Boolean.html"><span class="s2">Boolean</span></a> indicating whether or not the window receives clicks when it is not front-most. The default is true.</p>
102 <p class="p9"><br></p>
103 <p class="p8"><b><span class="Apple-tab-span"> </span>acceptsMouseOver_(boolean)</b></p>
104 <p class="p8"><b><span class="Apple-tab-span"> </span>acceptsMouseOver</b></p>
105 <p class="p9"><b><span class="Apple-tab-span"> </span></b><span class="Apple-tab-span"> </span></p>
106 <p class="p8"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>Set or return a <a href="../../Core/Boolean.html"><span class="s2">Boolean</span></a> indicating whether or not the window receives mouseOver events. The default is false.</p>
107 <p class="p9"><b><span class="Apple-tab-span"> </span></b></p>
108 <p class="p8"><b><span class="Apple-tab-span"> </span>alpha_(alpha)</b></p>
109 <p class="p9"><b><span class="Apple-tab-span"> </span></b></p>
110 <p class="p8"><b><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></b>Set the transparency of this window. <b>alpha </b>is a Float between 0.0 (invisible) and 1.0 (opaque).</p>
111 <p class="p9"><br></p>
112 <p class="p8"><b><span class="Apple-tab-span"> </span>alwaysOnTop_(bool)</b></p>
113 <p class="p8"><b><span class="Apple-tab-span"> </span>alwaysOnTop</b></p>
114 <p class="p9"><b><span class="Apple-tab-span"> </span></b><span class="Apple-tab-span"> </span></p>
115 <p class="p8"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>Set or return a <a href="../../Core/Boolean.html"><span class="s2">Boolean</span></a> value indicating whether this window is always front-most. The default is false.</p>
116 <p class="p9"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></p>
117 <p class="p8"><b><span class="Apple-tab-span"> </span>bounds_(argBounds)</b></p>
118 <p class="p8"><b><span class="Apple-tab-span"> </span>bounds</b></p>
119 <p class="p9"><b><span class="Apple-tab-span"> </span></b><span class="Apple-tab-span"> </span></p>
120 <p class="p8"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>Set or return a <a href="../../Geometry/Rect.html"><span class="s2">Rect</span></a> corresponding to the location and size of the window. The size does not include the title bar. <b>N.B. </b>Location is measured from the <i>bottom left</i> of the screen. This is different from view location, which is measured from the <i>upper left</i> of the window (not including the title bar). Note that because of the way Cocoa applications work, setting the bounds doesn't complete until the application finishes its current application event cycle. Thus, if you check the bounds in the same chunk of code, the SCWindow will not yet return the updated values.</p>
121 <p class="p9"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></p>
122 <p class="p11"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>(</p>
123 <p class="p11"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>w = <span class="s2">Window</span>.new(<span class="s7">"test"</span>);</p>
124 <p class="p14"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>w.front;</p>
125 <p class="p14"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>w.bounds = <span class="s2">Rect</span>(150, 450, 150, 150);</p>
126 <p class="p15"><span class="s3"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>w.bounds.postln; </span>// still the old bounds</p>
127 <p class="p14"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>{ w.bounds.postln; <span class="s2">nil</span> }.defer(0.1); <span class="s8">// next application event cycle</span></p>
128 <p class="p14"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>)</p>
129 <p class="p9"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></p>
130 <p class="p8"><b><span class="Apple-tab-span"> </span>close</b></p>
131 <p class="p9"><b><span class="Apple-tab-span"> </span></b></p>
132 <p class="p8"><b><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></b>Closes this window.</p>
133 <p class="p9"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></p>
134 <p class="p8"><span class="Apple-tab-span"> </span><b>drawHook_(function)</b></p>
135 <p class="p8"><b><span class="Apple-tab-span"> </span>drawHook</b></p>
136 <p class="p9"><b><span class="Apple-tab-span"> </span></b><span class="Apple-tab-span"> </span></p>
137 <p class="p8"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>Set or return a drawing <a href="../../Core/Kernel/Function.html"><span class="s2">Function</span></a>. See <a href="../Main-GUI/Pen.html"><span class="s2">Pen</span></a> for more information and many examples.</p>
138 <p class="p9"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></p>
139 <p class="p8"><span class="Apple-tab-span"> </span><b>front</b></p>
140 <p class="p9"><b><span class="Apple-tab-span"> </span></b></p>
141 <p class="p8"><b><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></b>Display this window and bring it to the front.<span class="Apple-tab-span"> </span><b><span class="Apple-tab-span"> </span></b></p>
142 <p class="p9"><b><span class="Apple-tab-span"> </span></b></p>
143 <p class="p8"><b><span class="Apple-tab-span"> </span>fullScreen</b></p>
144 <p class="p8"><b><span class="Apple-tab-span"> </span>endFullScreen</b></p>
145 <p class="p9"><b><span class="Apple-tab-span"> </span></b><span class="Apple-tab-span"> </span></p>
146 <p class="p8"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>Puts the window in or out of full screen mode. Putting a window into fullScreen mode may change its bounds.<span class="Apple-converted-space"> </span></p>
147 <p class="p8"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>Use the <b>escape</b> key to exit full screen mode and close the window.<span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></p>
148 <p class="p8"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="s9">(</span></p>
149 <p class="p11"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>w = <span class="s2">Window</span>.new(border: <span class="s2">false</span>);</p>
150 <p class="p11"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>w.view.background_(<span class="s2">Color</span>.rand);</p>
151 <p class="p11"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>w.front;</p>
152 <p class="p11"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>w.fullScreen;</p>
153 <p class="p11"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="s2">Button</span>.new(w, <span class="s2">Rect</span>(200,200,200,200)).states_([[<span class="s7">"Close Window"</span>]]).action_({w.endFullScreen;w.close});</p>
154 <p class="p11"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>)</p>
155 <p class="p7"><span class="Apple-tab-span"> </span></p>
156 <p class="p8"><span class="s9"><span class="Apple-tab-span"> </span></span><b>isClosed</b></p>
157 <p class="p9"><b><span class="Apple-tab-span"> </span></b></p>
158 <p class="p8"><b><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></b>Returns a <a href="../../Core/Boolean.html"><span class="s2">Boolean</span></a> indicating whether this window has been closed.</p>
159 <p class="p9"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></p>
160 <p class="p8"><span class="s9"><span class="Apple-tab-span"> </span></span><b>minimize</b></p>
161 <p class="p9"><b><span class="Apple-tab-span"> </span></b></p>
162 <p class="p8"><b><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></b>Minimize this window to the dock.</p>
163 <p class="p9"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></p>
164 <p class="p8"><span class="Apple-tab-span"> </span><b>name_(argName)</b></p>
165 <p class="p8"><b><span class="Apple-tab-span"> </span>name</b></p>
166 <p class="p9"><b><span class="Apple-tab-span"> </span></b><span class="Apple-tab-span"> </span></p>
167 <p class="p8"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>Set or return a String corresponding to the text in this window's title bar.</p>
168 <p class="p9"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></p>
169 <p class="p8"><span class="s9"><span class="Apple-tab-span"> </span></span><b>onClose_(val)</b></p>
170 <p class="p8"><b><span class="Apple-tab-span"> </span>onClose</b></p>
171 <p class="p9"><b><span class="Apple-tab-span"> </span></b><span class="Apple-tab-span"> </span></p>
172 <p class="p8"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>Set or return a <a href="../../Core/Kernel/Function.html"><span class="s2">Function</span></a> to be evaluated when the window is closed.</p>
173 <p class="p9"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="s9"><span class="Apple-tab-span"> </span></span></p>
174 <p class="p8"><span class="s9"><span class="Apple-tab-span"> </span></span><b>addToOnClose(function)</b></p>
175 <p class="p8"><b><span class="Apple-tab-span"> </span>removeFromOnClose(funcion)</b></p>
176 <p class="p9"><b><span class="Apple-tab-span"> </span></b><span class="Apple-tab-span"> </span></p>
177 <p class="p8"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>Add or remove a <a href="../../Core/Kernel/Function.html"><span class="s2">Function</span></a> to be evaluated when the window is closed.<span class="s9"><span class="Apple-tab-span"> </span></span></p>
178 <p class="p7"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></p>
179 <p class="p8"><span class="s9"><span class="Apple-tab-span"> </span></span><b>refresh</b></p>
180 <p class="p9"><b><span class="Apple-tab-span"> </span></b></p>
181 <p class="p8"><b><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></b>Force this window and its contents to redraw. This is sometimes necessary in order to update drawing.</p>
182 <p class="p9"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></p>
183 <p class="p8"><span class="Apple-tab-span"> </span><b>setInnerExtent(w,h)</b></p>
184 <p class="p9"><b><span class="Apple-tab-span"> </span></b></p>
185 <p class="p8"><b><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></b>Changes the size of this window while keeping the top left corner fixed. This is the usual desired behavior, as by default Cocoa uses a flipped coordinate system.</p>
186 <p class="p9"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></p>
187 <p class="p8"><span class="Apple-tab-span"> </span><b>setTopLeftBounds(rect,menuSpacer)</b></p>
188 <p class="p9"><b><span class="Apple-tab-span"> </span></b></p>
189 <p class="p8"><b><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></b>Sets the bounds of the window using topLeft as a reference point, just like in View.<span class="Apple-converted-space">  </span>The menuSpacer defaults to 45, the height of the OSX menu bar.</p>
190 <p class="p7"><span class="Apple-tab-span"> </span></p>
191 <p class="p8"><span class="s9"><span class="Apple-tab-span"> </span></span><b>userCanClose_(bool)</b></p>
192 <p class="p8"><b><span class="Apple-tab-span"> </span>userCanClose</b></p>
193 <p class="p9"><b><span class="Apple-tab-span"> </span></b><span class="Apple-tab-span"> </span></p>
194 <p class="p8"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>Set or return a <a href="../../Core/Boolean.html"><span class="s2">Boolean</span></a> value indicating whether the user can close this window by clicking on its close button. The default is true.</p>
195 <p class="p9"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></p>
196 <p class="p8"><span class="Apple-tab-span"> </span><b>view</b></p>
197 <p class="p8"><b><span class="Apple-tab-span"> </span>asView</b></p>
198 <p class="p9"><b><span class="Apple-tab-span"> </span></b></p>
199 <p class="p8"><b><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></b>Returns this window's top level view, which contains all of its other views. This will be an instance of SCTopView or <a href="SCScrollTopView.html"><span class="s2">SCScrollTopView</span></a> depending on the value passed to the <b>scroll</b> argument when the window was created. See <b>*new</b> above.</p>
200 <p class="p9"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></p>
201 <p class="p8"><b><span class="Apple-tab-span"> </span>currentSheet</b></p>
202 <p class="p9"><b><span class="Apple-tab-span"> </span></b><span class="Apple-tab-span"> </span></p>
203 <p class="p8"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>Returnscurrent modal sheet attached to this window, if it exists. See <a href="SCModalSheet.html"><span class="s2">SCModalSheet</span></a></p>
204 <p class="p9"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></p>
205 <p class="p13"><b>Examples</b></p>
206 <p class="p3"><br></p>
207 <p class="p3"><br></p>
208 <p class="p3"><br></p>
209 <p class="p15">//how to add views</p>
210 <p class="p14">(</p>
211 <p class="p14"><span class="s2">var</span> w;</p>
212 <p class="p14">w = <span class="s2">Window</span>(<span class="s7">"my name is... panel"</span>, <span class="s2">Rect</span>(128, 64, 340, 360));</p>
213 <p class="p3"><br></p>
214 <p class="p14">32.do({ <span class="s2">arg</span> i;</p>
215 <p class="p14"><span class="Apple-tab-span"> </span>b = <span class="s2">Button</span>(w, <span class="s2">Rect</span>(rrand(20,300),rrand(20,300), 75, 24));</p>
216 <p class="p14"><span class="Apple-tab-span"> </span>b.states = [[<span class="s7">"Start "</span>++i, <span class="s2">Color</span>.black, <span class="s2">Color</span>.rand],</p>
217 <p class="p14"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>[<span class="s7">"Stop "</span>++i, <span class="s2">Color</span>.white, <span class="s2">Color</span>.red]];</p>
218 <p class="p14">});</p>
219 <p class="p14">w.front;</p>
220 <p class="p14">)</p>
221 <p class="p3"><br></p>
222 <p class="p15">// using a decorator on this window's top view</p>
223 <p class="p14">(</p>
224 <p class="p14"><span class="s2">var</span> w;</p>
225 <p class="p14">w = <span class="s2">Window</span>(<span class="s7">"my name is... panel"</span>, <span class="s2">Rect</span>(128, 64, 340, 360));</p>
226 <p class="p3"><br></p>
227 <p class="p14">w.view.decorator = <span class="s2">FlowLayout</span>(w.view.bounds);</p>
228 <p class="p15">// w.addFlowLayout; // you can als write this instead of the line above</p>
229 <p class="p3"><br></p>
230 <p class="p14">w.view.background = <span class="s2">Color</span>(0.6,0.8,0.8);</p>
231 <p class="p14">32.do({ <span class="s2">arg</span> i;</p>
232 <p class="p14"><span class="Apple-tab-span"> </span>b = <span class="s2">Button</span>(w, <span class="s2">Rect</span>(rrand(20,300),rrand(20,300), 75, 24));</p>
233 <p class="p14"><span class="Apple-tab-span"> </span>b.states = [[<span class="s7">"Start "</span>++i, <span class="s2">Color</span>.black, <span class="s2">Color</span>.rand],</p>
234 <p class="p14"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>[<span class="s7">"Stop "</span>++i, <span class="s2">Color</span>.white, <span class="s2">Color</span>.red]];</p>
235 <p class="p14">});</p>
236 <p class="p3"><br></p>
237 <p class="p14">w.front;</p>
238 <p class="p14">)</p>
239 <p class="p3"><br></p>
240 <p class="p15">// setting bounds</p>
241 <p class="p15">// use screenbounds for precise placement from the top</p>
242 <p class="p3"><br></p>
243 <p class="p14">(</p>
244 <p class="p14">x = <span class="s2">Window</span>.new(<span class="s7">"test"</span>, <span class="s2">Rect</span>(100,<span class="s2">Window</span>.screenBounds.height-180,300,100));x.front;</p>
245 <p class="p14">)</p>
246 <p class="p3"><br></p>
247 <p class="p15">// bounds.top refers to the bottom edge of the window,</p>
248 <p class="p15">// measured from the bottom of the screen. Different than in View.</p>
249 <p class="p14">x.bounds_(<span class="s2">Rect</span>(100,400,300,300));</p>
250 <p class="p3"><br></p>
251 <p class="p3"><br></p>
252 <p class="p3"><br></p>
253 <p class="p15">// borderless windows</p>
254 <p class="p15"><span class="s3">w = </span><span class="s2">Window</span><span class="s3">.new(border:</span><span class="s2">false</span><span class="s3">).front; </span>// can't be manually closed</p>
255 <p class="p15"><span class="s3">w.close; </span>// so close it in code</p>
256 <p class="p3"><br></p>
257 <p class="p15">// onClose</p>
258 <p class="p14">(</p>
259 <p class="p14">x = <span class="s2">Window</span>.new.front;</p>
260 <p class="p14">x.alpha = 0.8;</p>
261 <p class="p15"><span class="s3">x.onClose_({ y = </span><span class="s2">Synth</span><span class="s3">.new(</span><span class="s10">\default</span><span class="s3">) }); </span>//close the window and the synth plays</p>
262 <p class="p14">)</p>
263 <p class="p14">x.close;</p>
264 <p class="p14">y.free;</p>
265 <p class="p3"><br></p>
266 <p class="p15">// a window with scrollers</p>
267 <p class="p14">(</p>
268 <p class="p15"><span class="s3">w = </span><span class="s2">Window</span><span class="s3">(scroll: </span><span class="s2">true</span><span class="s3">); </span>// you must set this when the window is created</p>
269 <p class="p14">c = <span class="s2">Slider2D</span>(w, <span class="s2">Rect</span>(0, 0, 1500, 300));</p>
270 <p class="p14">d = <span class="s2">Slider</span>(w, <span class="s2">Rect</span>(0, 310, 20, 300));</p>
271 <p class="p14">c.background = <span class="s2">Color</span>.grey.alpha = 0.6;</p>
272 <p class="p14">d.background = <span class="s2">Color</span>.grey.alpha = 0.6;</p>
273 <p class="p14">w.front;</p>
274 <p class="p14">)</p>
275 <p class="p3"><br></p>
276 <p class="p3"><br></p>
277 <p class="p15">// drawing dynamically in a window with <a href="../Main-GUI/Pen.html"><span class="s5">Pen</span></a></p>
278 <p class="p14">(</p>
279 <p class="p14"><span class="s2">var</span> w, much = 0.02, string, synth;</p>
280 <p class="p3"><br></p>
281 <p class="p14">w = <span class="s2">Window</span>.new(<span class="s7">"swing"</span>, <span class="s2">Rect</span>(100, 100, 300, 500)).front;</p>
282 <p class="p14">w.view.background_(<span class="s2">Color</span>.new255(153, 255, 102).vary);</p>
283 <p class="p3"><br></p>
284 <p class="p14">string = <span class="s7">"swing "</span>.dup(24).join;</p>
285 <p class="p3"><br></p>
286 <p class="p14">w.drawHook = <span class="s2">Routine</span> {<span class="Apple-tab-span"> </span></p>
287 <p class="p14"><span class="Apple-tab-span"> </span><span class="s2">var</span> i = 0;</p>
288 <p class="p14"><span class="Apple-tab-span"> </span><span class="s2">var</span> size = 40;</p>
289 <p class="p14"><span class="Apple-tab-span"> </span><span class="s2">var</span> func = { <span class="s2">|i, j|</span> sin(i * 0.07 + (j * 0.0023) + 1.5pi) * much + 1 };</p>
290 <p class="p14"><span class="Apple-tab-span"> </span><span class="s2">var</span> scale;</p>
291 <p class="p14"><span class="Apple-tab-span"> </span><span class="s2">Pen</span>.font = <span class="s2">Font</span>(<span class="s7">"Helvetica-Bold"</span>, 40);</p>
292 <p class="p14"><span class="Apple-tab-span"> </span>loop {<span class="Apple-tab-span"> </span></p>
293 <p class="p14"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>i = i + 1;</p>
294 <p class="p14"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>string.do {<span class="Apple-tab-span"> </span><span class="s2">|char, j|</span></p>
295 <p class="p3"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></p>
296 <p class="p14"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>scale = func.value(i, j).dup(6);</p>
297 <p class="p3"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></p>
298 <p class="p14"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="s2">Pen</span>.fillColor = <span class="s2">Color</span>.new255(0, 120, 120).vary;</p>
299 <p class="p14"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="s2">Pen</span>.matrix = scale * #[1, 0, 0, 1, 1, 0];</p>
300 <p class="p14"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="s2">Pen</span>.stringAtPoint(char.asString,</p>
301 <p class="p14"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>((size * (j % 9)) - 10) @ (size * (j div: 9))</p>
302 <p class="p14"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>);</p>
303 <p class="p14"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>};</p>
304 <p class="p15"><span class="s3"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>0.yield </span>// stop here, return something unimportant</p>
305 <p class="p14"><span class="Apple-tab-span"> </span>}</p>
306 <p class="p14">};</p>
307 <p class="p3"><br></p>
308 <p class="p14">fork { while { w.isClosed.not } { defer { w.refresh }; 0.04.wait; } };</p>
309 <p class="p3"><br></p>
310 <p class="p14">w.front;</p>
311 <p class="p3"><br></p>
312 <p class="p14">)</p>
313 <p class="p3"><br></p>
314 </body>
315 </html>