2 summary:: Superclass of layouts that distribute views in a line
3 categories:: GUI>Layout
4 related:: Guides/GUI-Layout-Management
7 The two subclasses - QHLayout and QVLayout - distribute views in a horizontal or vertical line, respectively.
9 subsection:: Fine tuning
11 Each item can be assigned a stretch factor and an 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 added with link::#-add:: method or for an already contained item with link::#-setStretch:: and link::#-setAlignment:: methods.
13 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 QLineLayout and immediately fill it with items given as arguments.
30 A sequence of items that the layout will distribute in the given order. An item can be a QView, a QLayout, nil (for stretchable empty space) or an Integer (for fixed-size empty space). You can assign stretch factor and/or 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. If the item is nil only the stretch parameter will have effect; if the item is an integer none of the parameters will have any effect. For example:
35 [Button().states_([["Foo"]]), stretch:1, align:\bottomLeft],
37 [TextView().string_("Bar\nBar\nBar\n"), s:3],
47 Add an item to the right or the bottom end of the line, for QHLayout and QVLayout respectively.
50 The item can be a QView, a QLayout, an Integer (specifying amount in pixels of empty space) or nil (for stretchable empty space). If the item is nil the align argument will have no effect; if the item is an Integer none of the other arguments will have any effect.
53 An integer stretch factor.
56 A symbol expressing the alignment.
60 Set stretch factor of an item contained in the layout.
63 A QView or QLayout managed by the layout.
66 An integer stretch factor.
70 Set stretch factor of an item contained in the layout at given index.
73 An integer position of an item in the layout.
76 An integer stretch factor.
80 Set alignment of an item contained in the layout.
83 A QView or a QLayout managed by the layout.
86 A symbol expressing the alignment.
89 METHOD:: setAlignmentAt
90 Set alignment of an item contained in the layout at given index.
93 An integer position of an item in the layout.
96 A symbol expressing the alignment.
100 Try resizing the window created by the following code.
107 QButton().states_([["Foo"]]),
108 [QTextField().string_("Bar"), stretch:1],
109 [QTextField().string_("BarBarBar"), stretch:4]