Curl
 

Menu
 Chapter.1
 Chapter.2
 Chapter.3
 Chapter.4
 Chapter.5
 Chapter.6
 Chapter.7
 Chapter.8
 Chapter.9
 Chapter.10
 
 
■HBoxとVBox

複数のGraphicオブジェクトを横や縦に揃えて並べたい場合がよくあります。
オブジェクトを水平方向に左から右へ配置する手段としてはHBoxがあり、
オブジェクトを垂直方向に上から下にに配置する手段としてはVBoxがあります。

ほかのコンテナの場合と同様に、add メソッドを使用すれば、コンテナの作成時、または作成後に追加できます。

【HBoxとVBox】
{curl 6.0 applet}
{curl-file-attributes character-encoding = "shift-jis"}
{VBox
{HBox spacing= 6pt, background="wheat",
"これは水平のHBoxです。",
{RegularPolygonGraphic sides=4, width= 1cm, height= 1cm},
{RegularPolygonGraphic sides=6, width= 1cm, height= 1cm},
{RegularPolygonGraphic sides=8, width= 1cm, height= 1cm}
},
{VBox spacing= 6pt, background="cyan",
"これは垂直方向のVBoxです。",
{RegularPolygonGraphic sides=4, width= 1cm, height= 1cm},
{RegularPolygonGraphic sides=6, width= 1cm, height= 1cm},
{RegularPolygonGraphic sides=8, width= 1cm, height= 1cm}
}
}



HBoxVBoxを使用してオブジェクト同士が相互に重ならないように配置しています。
さらに2つのボックスを別の VBoxの中に含めており、それによって2つのボックスの配置も制御しています。

HBoxVBoxはそれぞれの子オブジェクトを1行または1列に並べて配置します。
ユーザーがウインドウサイズを変更するとそれに合わせて HBoxVBoxはグラフィックを伸長したり圧縮したりします。詳しくは次章で説明します。

HBoxVBox内のオブジェクトの配置は、valignhalign キーワードを使用して調整できます。
具体的には前章の『Tableセル内のオブジェクトの配置』 で説明したとおりです。

Chapter.7(Part.4)へ戻る
Chapter.8(Part.2)へ進む