IBM Forms: Understanding Itemlocation
The Itemlocation list is the heart and soul of IBM Form's layout capabilities. Its well described in the documentation and the Forms courses and tutorials, but there are a few key points that newbies - and I - often forget.
Order Matters
The order of items in the itemlocation list matters. The position of an item has four independant axis. The first two are the x, y position of the top left corner of the item. (0,0 is the top left corner of the page / pane). The second two are the width and height of the item. The items in an itemlocation list override previous items in the same list, but only certain axis! So the "below" list item overrides any previous x, y coordinates, but not the width or height. An x item overrides only any previoiusly set x axis - any previously set y value, even if it is relatively positioned, remains in force! So an "After" followed by an "x" will set absolute positioning for the x axis, and relative positioning for the y axis.
To further complicate matters, certain itemlocation entries only modify an axis. In particular, OffsetX / OffsetY modify, but do not override, any previoius x / y axis values previously set.
You can usually guess the axis that is changed by an itemlocation entry by it's name. So "Alignr2r" affects the right side of an item, and thus must override the width axis, leaving the height, x and y values unchanged.
One last example: "Alignt2b" sets the vertical position of the item so the top of the item aligns with the bottom of the argument item. So "Alignt2b" overrides the "y" value, leaving the other axis unchanged. Conversley, "Alignb2t" sets the height, and only the height, of an item so the bottom aligns with the top of another item.
Understand the defaults
Remember that "<after compute='itemprevious'/>" is always an unwritten 0th itemlocation list element! You can use this to keep things simple.
Say if you have a list of labels on the left followed by a list of fields on the right. You want the left sides of the fields to line up vertically (at x = 120 say), and you want each field to line up horizontally with it's label. Then make sure in the source that you have labelN followed by fieldN (N = 1, ... , n), and the item location for each field need only be a slngle x value: "<x>120</x>". The y value will be set by the unwritten default, "<after compute='itemprevious'/>".
So if you want something to be beside (to the right of) the previous item (in the build order!) with a small space between, the only item location element you need is an offsetx (for a relative gap) or an x for an absolute horizontal position.
If there is no previous item - that is, if the item is the first element in a pane, or the first element on a form page, it will have an "invisible" x=0, y=0 positioning as the default. So for the first item (the first item in the XML file, no necessarilly the first on the page visually!) in a table row pane, you usually want it at the top left of the pane - and in that case there is no need to enter anything as the default is (0,0) anyway.