def next_field_pad(pos_prev, offset, width, display):
    """
    Local helper calculates padding required for a given previous position,
    field offset and field width.

    pos_prev    Position following previous field
    offset      Offset of next field
    width       Width of next field 
    display     True if next field is to be displayed, otherwise False.

    Returns a tuple containing::
    [0] True if next field is to be placed on next row
    [1] Amount of padding (0..11) to be added from end of last field or start of row
    [2] Position of next free space after new element
    """
    if not display:
        # Field not to be displayed
        return (False, 0, pos_prev)
    if (offset < pos_prev) or (offset+width > 12):
        # Force to next row
        next_row = True
        padding  = offset
    else:
        # Same row
        next_row = False
        padding  = offset - pos_prev
    pos_next = offset + width
    return (next_row, padding, pos_next)