rsc3/doc-schelp/HelpSource/Reference/Resize.scrbl

103 lines
2.2 KiB
Text
Raw Permalink Normal View History

2022-08-24 13:53:18 +00:00
#lang scribble/manual
@(require (for-label racket))
@title{Resize behaviour}
Resize behavior for View and its subclasses@section{categories}
GUI
@section{section}
Description
@section{method}
resize
The link::Classes/View#-resize:: method takes nine different values as argument defining the behavior of the view when the containing window is resized. Each view responds relatively to the stretches of its parent view.
@section{table}
## 1 || 2 || 3
## 4 || 5 || 6
## 7 || 8 || 9
::
@section{list}
## 1 - fixed to left, fixed to top
## 2 - horizontally elastic, fixed to top
## 3 - fixed to right, fixed to top
## 4 - fixed to left, vertically elastic
## 5 - horizontally elastic, vertically elastic
## 6 - fixed to right, vertically elastic
## 7 - fixed to left, fixed to bottom
## 8 - horizontally elastic, fixed to bottom
## 9 - fixed to right, fixed to bottom
::
@section{section}
Examples
@racketblock[
// resize behaviours
// use the PopUpMenus to mix resize modes
(
var a;
a = { |i|
var w, b, x,k,t,p;
k=i;
i = i + 1;
w = Window("resize:"+i, Rect(10 + (k%3 * 220), Window.screenBounds.height- [250,460,670].at(k/3), 200, 180));
b = w.view.bounds;
x = CompositeView(w, w.view.bounds.insetBy(20,20))
.background_(Color.rand)
.resize_(i);
y = CompositeView(x, x.bounds.moveTo(0,0).insetBy(20,20))
.background_(Color.rand)
.resize_(i);
y.decorator = FlowLayout(y.bounds).gap_(0.0 @ 0.0);
t = StaticText(y, Rect(0, 0, 40, 40))
.background_(Color.rand.alpha_(0.8))
.resize_(i)
.string_(i)
.font_(Font("Helvetica", 26));
p=PopUpMenu(y,40@40).items_((1..9).collect(_.asString)).value_(i-1).resize_(i)
.action_{|m| t.string_((m.value+1).asString); [p,t].do(_.resize_(m.value+1))};
w.front;
w.onClose = {a.do(_.close) };
} ! 9;
)
// the popupmenu contains the various modes
(
w = Window("soundfile test", Rect(200, 200, 720, 250));
p = PopUpMenu(w, Rect(10,10,80,24))
.items_( Array.fill(9, {arg i; (i+1).asString;}) )
.action_({ arg sbs;
a.resize_(sbs.value+1);
});
f = SoundFile.new;
f.openRead(Platform.resourceDir +/+ "sounds/a11wlk01.wav");
a = SoundFileView(w, Rect(10,40, 700, 180))
.soundfile_(f)
.readWithTask(0, f.numFrames, showProgress: false )
.resize_(1);
w.front;
)
::
]