ウインドウの部品をどのように配置(レイアウト)するかを決めるものである。
レイアウトは入れ子にすることができる。
(あるレイアウトの中で別のレイアウトを使うことができる)
複数のレイアウトを使用するとウイジェットの位置を変えたり、折り畳んだりすることができる。
その時どこまでが一つのレイアウトの範囲になるかを指定するためにsetParentを使用する。
下の2つの例の違いを比べてみよ。
window;
columnLayout;
frameLayout -collapsable true;
columnLayout;
button -label "button1";
setParent ..;
setParent ..;
frameLayout -collapsable true;
button -label "button2";
setParent ..;
showWindow;
window;
columnLayout;
frameLayout -collapsable true;
columnLayout;
button -label "button1";
frameLayout -collapsable true;
button -label "button2";
showWindow;
window;
string $form = `formLayout -numberOfDivisions 100`;
string $b1 = `button -label "button1"`;
string $b2 = `button -label "button2"`;
string $b3 = `button -label "button3"`;
string $b4 = `button -label "button4"`;
formLayout -edit
-attachForm $b1 "top" 5
-attachForm $b1 "left" 5
-attachControl $b1 "bottom" 15 $b2
-attachPosition $b1 "right" 0 55
-attachNone $b2 "top"
-attachForm $b2 "left" 10
-attachForm $b2 "bottom" 10
-attachForm $b2 "right" 10
-attachForm $b3 "top" 5
-attachPosition $b3 "left" 0 70
-attachControl $b3 "bottom" 25 $b4
-attachForm $b3 "right" 5
-attachNone $b4 "top"
-attachPosition $b4 "left" 0 60
-attachControl $b4 "bottom" 35 $b2
-attachForm $b4 "right" 5
$form;
showWindow;