2 summary:: Superclass of layouts that distribute views in a line
3 categories:: GUI>Kits>Qt
4 related:: Classes/HLayout, Classes/VLayout, Classes/GridLayout, Classes/StackLayout, Guides/GUI-Layout-Management
7 This is an abstract superclass of link::Classes/HLayout:: and link::Classes/VLayout:: which distribute views in a horizontal or vertical line, respectively.
9 subsection:: Fine tuning
11 Each item can be assigned a strong::stretch factor:: and an strong::alignment:: flag to fine tune how its size and position are managed. This can be done at layout link::#*new#construction::, when an item is link::#-add#added:: or link::#-insert#inserted:: or for an already present item with link::#-setStretch:: and link::#-setAlignment:: methods.
13 The strong::stretch factor:: only affects distribution in the direction of the layout (vertical or horizontal). All items have a stretch factor of 0 by default, so only their own preferences will determine space distribution. As soon as an item is assigned a stretch factor higher than 0, the space will be redistributed according to proportions of stretch factors.
15 subsection:: Leaving empty space
17 An empty space with an arbitrary stretch factor may be inserted using nil in place of an item in combination with the stretch factor. Similarily, an empty space of fixed size may be inserted using an integer in place of an item. See link::#*new#constructor:: and link::#-add:: for details.
27 Create a link::Classes/HLayout:: or a link::Classes/VLayout:: and immediately fill it with items given as arguments. (Note that QLineLayout is an abstract class and can not be instantiated, but HLayout and VLayout inherit this constructor).
30 Each item can be a strong::view::, a strong::layout::, strong::nil:: (for stretchable empty space) or an strong::Integer:: (for fixed-size empty space).
34 You can assign a strong::stretch factor:: and/or strong::alignment:: to an item by wrapping it into an array, followed by pairs of ('stretch', factor) and/or ('align', flag). 'stretch' and 'align' may be abbreviated with 's' and 'a'. Simplified syntax for placing key-value pairs into an array comes handy (see link::Reference/Syntax-Shortcuts#creating_arrays_with_key-value_pairs::, and the example below).
36 If the item is a stretchable empty space (nil) alignment will have no effect; if the item is a fixed-size empty space (an Integer), it is unaffected by both the stretch factor and alignment.
42 [Button().states_([["Foo"]]), stretch:1, align:\bottomLeft],
44 [TextView().string_("Bar\nBar\nBar\n"), s:3],
54 Add an item to the right or the bottom end of the line, for HLayout and VLayout respectively.
57 The item can be a strong::view::, a strong::layout::, an strong::Integer:: (specifying amount in pixels of empty space) or strong::nil:: (for stretchable empty space).
60 An integer stretch factor.
63 A symbol expressing the alignment.
66 If the item is a stretchable empty space (nil) the align argument will have no effect; if the item is a fixed-size empty space (an Integer) both stretch and align arguments will have no effect.
70 Insert an item at a specific position.
73 The item can be a strong::view::, a strong::layout::, an strong::Integer:: (specifying amount in pixels of empty space) or strong::nil:: (for stretchable empty space).
76 The integer position among current items at which to insert the new item. If index is smaller than 0 or larger than the current amount of items, the new item will always be added to the end of the line.
79 An integer stretch factor.
82 A symbol expressing the alignment.
85 If the item is a stretchable empty space (nil) the align argument will have no effect; if the item is a fixed-size empty space (an Integer) both stretch and align arguments will have no effect.
90 Set stretch factor of an item contained in the layout.
93 A view or layout managed by this layout, or an Integer index of an item.
96 An integer stretch factor.
100 METHOD:: setAlignment
101 Set alignment of an item contained in the layout.
104 A view or a layout managed by this layout, or an Integer index of an item.
107 A symbol expressing the alignment.
112 Try resizing the window created by the following code.
117 TextView().string_("Foo\nBar\nFoo\nBar\nFoo"),
119 Button().states_([["Foo"]]),
120 [TextField().string_("Bar"), stretch:1],
121 [TextField().string_("BarBarBar"), stretch:4]