/usr/share/SuperCollider/HelpSource/Classes/Window.schelp is in supercollider-common 1:3.8.0~repack-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 | CLASS:: Window
summary:: Top-level container of views
categories:: GUI>Views
DESCRIPTION::
The Window is the most fundamental element of the GUI. It occupies a rectangular space on the screen within which other GUI elements (Views) are displayed.
A child view is added into a window by passing the window to the view's constructor. See link::Classes/View#*new::.
note::
There is no distinction between windows, views, and containers; a View can be displayed directly on screen, and can contain other views. Therefore, visual descriptions of Window and most of the methods that are specific to Window in other GUI kits, also apply to and make part of View in Qt, and are thus shared by all its subclasses.
The Window class is provided in Qt GUI for compatibility as well as convenience: e.g. unlike View, Window will be created by default in the center of the screen, and various aspects can be conveniently controlled using its constructor arguments.
::
The Window is usually drawn with a bar on its top edge that displays the window's title which you can set in the link::#*new#constructor::, or using link::#-name::.
CLASSMETHODS::
PRIVATE:: key
METHOD:: new
Creates a new Window instance. You will need to call link::#-front:: on it to become visible.
argument:: name
A String for the text that will be displayed in the title bar. The default is 'panel'.
argument:: bounds
A Rect specifying position and size of the window. The size does not include the border and title bar. Position is measured from the bottom-left corner of the screen (this is different than link::Classes/View#-bounds::). The default is size 400x400 at position 128x64, but in Qt the window is centered on the screen by default.
argument:: resizable
A Boolean indicating whether this window is resizable by the user. The default is code::true::.
argument:: border
A Boolean indicating whether this window has a border. Borderless windows have no title bar and thus can only be closed in code. The default is code::true::.
argument:: server
This is a dummy argument which is here to provide compatibility with SwingOSC and has no effect.
argument:: scroll
A Boolean indicating whether this window will add scrollbars if its contents exceed its bounds. If this is set to code::true::, then link::Classes/View#-resize:: settings will be ignored for contained views. The default is false.
METHOD:: allWindows
An array of all existing Window instances.
METHOD:: closeAll
Calls link::#-close:: an all existing Window instances.
METHOD:: initAction
The default action object to be evaluated whenever a new Window is instantiated.
METHOD:: screenBounds
Returns a Rect with the size of the screen in pixels
METHOD:: availableBounds
Returns a Rect describing the area of the screen that windows can actually occupy (i.e. excluding the Mac dock, the task bar, or similar).
INSTANCEMETHODS::
SUBSECTION:: View hierarchy
METHOD:: view
When a Window is created, it creates a container view, accessible using this method, that occupies the whole area of the window, and which will be used as the actual parent of the child widgets.
returns::
A View.
METHOD:: asView
Equivalent to link::#-view::
METHOD:: currentSheet
note:: Only in Cocoa GUI ::
returns:
The current modal sheet attached to this window, if it exists. See link::Classes/SCModalSheet::.
SUBSECTION:: Visibility
METHOD:: front
Displays the window on the screen (This has the same effect as setting link::#-visible:: to true).
METHOD:: minimize
Hides the window, only keeping its representation in the dock, taskbar, etc..
METHOD:: unminimize
Restores the window's previous state after being minimized.
METHOD:: fullScreen
Displays the window full-screen.
METHOD:: endFullScreen
Restores the window's previous state after being displayed full-screen.
METHOD:: alwaysOnTop
Whether the window should always stay on top of other windows, even when it is not the active one.
argument::
A Boolean.
METHOD:: visible
Whether the window is visible.
Setting this to code::true:: has the same effect as link::#-front::, and setting it to false closes the window without destroying it.
argument::
A Boolean.
METHOD:: close
Closes and destroys the window.
METHOD:: isClosed
returns:: A Boolean stating whether the view has been closed.
SUBSECTION:: Geometry
METHOD:: bounds
The position and size of the window. The position is relative to the bottom-left corner of the screen.
argument::
A Rect or a Point interpreted link::Classes/Point#-asRect#as Rect::.
returns::
A Rect.
METHOD:: setTopLeftBounds
A convenience method that, unlike link::#-bounds::, sets the bounds by measuring position from the top-left corner of the screen, and vertically offset by code::menuSpacer::.
argument:: rect
A Rect.
argument:: menuSpacer
An Integer amount of pixels.
METHOD:: setInnerExtent
Resizes the window, keeping its position intact.
This is equivalent to link::Classes/View#-resizeTo:: called on the link::#-view::.
argument:: w
An Integer width in pixels.
argument:: h
An Integer height in pixels.
METHOD:: sizeHint
Redirects to link::Classes/View#-sizeHint:: of the link::#-view::.
METHOD:: minSizeHint
Redirects to link::Classes/View#-minSizeHint:: of the link::#-view::.
METHOD:: addFlowLayout
A convenience method which sets code::decorator:: of the link::#-view:: to a new instance of FlowLayout. See link::Classes/FlowLayout:: for examples.
argument:: margin
A Point describing the link::Classes/FlowLayout#-margin#margin:: of the FlowLayout.
argument:: gap
A Point describing the link::Classes/FlowLayout#-gap#gap:: of the FlowLayout.
returns:: The new FlowLayout instance.
METHOD:: layout
Redirects to link::Classes/View#-layout:: of the link::#-view::.
SUBSECTION:: Appearance
METHOD:: name
The title of the window.
argument::
A String.
METHOD:: background
The background color of the window.
argument::
A Color.
METHOD:: alpha
The transparency of the window.
argument::
A Float between 0.0 (invisible) and 1.0 (opaque).
METHOD:: refresh
Redraws the window and all its children.
SUBSECTION:: Interaction
METHOD:: userCanClose
Whether the user can close the window. The default is code::true::.
argument::
A Boolean.
METHOD:: acceptsClickThrough
Whether the window receives clicks when it is not front-most. The default is code::true::.
argument::
A Boolean.
METHOD:: acceptsMouseOver
Whether the window and all its children receive mouse-over events. The default is code::false::.
See also: link::Classes/View#-acceptsMouseOver:: and link::Classes/View#-mouseOverAction::.
argument::
A Boolean.
SUBSECTION:: Actions and hooks
METHOD:: drawFunc
Just like the link::Classes/UserView::, the window can be given a Function to evaluate whenever it is asked to redraw itself, so you can use the link::Classes/Pen:: class to draw on the window. See link::Classes/UserView#-drawFunc:: for explanation.
argument::
A Function.
METHOD:: toFrontAction
The action object to be evaluated whenever the window becomes the active one.
METHOD:: endFrontAction
The action object to be evaluated whenever the window ceases to be the active one.
METHOD:: onClose
The action object to be evaluated when the window is closed.
METHOD:: addToOnClose
Adds an object to link::#-onClose::, wrapping the current value into an Array, if it is not yet.
METHOD:: removeFromOnClose
Removes an object from link::#-onClose::, if the latter is an Array.
EXAMPLES::
subsection:: Adding Views
code::
(
var w;
w = Window("my name is... panel", Rect(128, 64, 340, 360));
32.do({ arg i;
b = Button(w, Rect(rrand(20,300),rrand(20,300), 75, 24));
b.states = [["Start "++i, Color.black, Color.rand],
["Stop "++i, Color.white, Color.red]];
});
w.front;
)
::
subsection:: Using Decorator
code::
(
var w;
w = Window("my name is... panel", Rect(128, 64, 340, 360));
w.view.decorator = FlowLayout(w.view.bounds);
// w.addFlowLayout; // you can als write this instead of the line above
w.view.background = Color(0.6,0.8,0.8);
32.do({ arg i;
b = Button(w, Rect(rrand(20,300),rrand(20,300), 75, 24));
b.states = [["Start "++i, Color.black, Color.rand],
["Stop "++i, Color.white, Color.red]];
});
w.front;
)
::
subsection:: Setting Bounds
code::
// use screenbounds for precise placement from the top
(
x = Window.new("test", Rect(100,Window.screenBounds.height-180,300,100));x.front;
)
// bounds.top refers to the bottom edge of the window,
// measured from the bottom of the screen. Different than in View.
x.bounds_(Rect(100,400,300,300));
::
subsection:: Borderless Window
code::
w = Window.new(border:false).front; // can't be manually closed
w.close; // so close it in code
::
subsection:: Window with Scrollers
code::
(
w = Window(scroll: true); // you must set this when the window is created
c = Slider2D(w, Rect(0, 0, 1500, 300));
d = Slider(w, Rect(0, 310, 20, 300));
c.background = Color.grey.alpha = 0.6;
d.background = Color.grey.alpha = 0.6;
w.front;
)
::
subsection::onClose
code::
(
x = Window.new.front;
x.alpha = 0.8;
x.onClose_({ y = Synth.new(\default) }); //close the window and the synth plays
)
x.close;
y.free;
::
subsection:: Using Layouts
Layouts are used to organize view sizes automatically. See: link::Guides/GUI-Layout-Management::.
note:: Only in Cocoa GUI ::
code::
// make a window and a layout
(
w = Window(bounds:Rect(700,200,200,200));
h = HLayout();
v = VLayout(h);
w.layout = v;
w.front;
w.alwaysOnTop = true;
)
// add views step by step
v.add(k = Slider());
h.add(Slider());
h.add(Slider());
k.orientation = \horizontal;
h.add(g = VLayout(), 2, \left);
g.add(TextView());
g.add(TextView().string_("sand and hand"));
v.add(Button());
v.add(Button());
v.add(Button());
g.add(Button());
g.margins = [1, 1, 1, 1];
h.margins = [1, 1, 1, 1] * 23;
v.margins = [1, 1, 1, 1] * 5;
h.add(g = VLayout(), 1, \left);
g.add(g = HLayout(), 1, \left);
5.do { g.add(Slider().orientation_(\vertical)) };
::
subsection:: Drawing on Window with Pen
code::
(
var w, much = 0.02, string, synth;
w = Window.new("gui", Rect(100, 100, 300, 500)).front;
w.view.background_(Color.new255(153, 255, 102).vary);
string = "gui ".dup(24).join;
w.drawFunc = Routine {
var i = 0;
var size = 40;
var func = { |i, j| sin(i * 0.07 + (j * 0.0023) + 1.5pi) * much + 1 };
var scale;
var font = Font("Helvetica", 40).boldVariant;
loop {
i = i + 1;
Pen.font = font;
string.do { |char, j|
scale = func.value(i, j).dup(6);
Pen.fillColor = Color.new255(0, 120, 120).vary;
Pen.matrix = scale * #[1, 0, 0, 1, 1, 0];
Pen.stringAtPoint(char.asString,
((size * (j % 9)) - 10) @ (size * (j div: 9))
);
};
0.yield // stop here, return something unimportant
}
};
{ while { w.isClosed.not } { w.refresh; 0.04.wait; } }.fork(AppClock);
w.front;
)
::
|