width -= (hPadding << 1);
int availableWidth = width;
// each field reduces our available width
int maxHeight = 0; // Calculate max height as we go
int fieldCount = getFieldCount();
Field child;
for (int i = 0; i < fieldCount; i++) {
child = getField(i);
if (hasField(title) && child == title) {
continue;
// Layout title last, separately
}
layoutChild(child, availableWidth, height);
XYRect childExtent = child.getExtent();
availableWidth -= childExtent.width;
if (hasField(icon) && child == icon) {
// skip the interior padding loss.
} else {
availableWidth -= interiorPadding;
}
maxHeight = Math.max(maxHeight, childExtent.height);
}
// Layout Title with remaining space
if (hasField(title)) {
child = title;
layoutChild(child, availableWidth, height);
XYRect childExtent = child.getExtent();
availableWidth -= childExtent.width + interiorPadding;
maxHeight = Math.max(maxHeight, childExtent.height);
}
// Set Positions
if (hasField(icon)) {