Next / Previous / Contents / Shipman's homepage

7.5. fosoxtest: buildMasters()

This function builds the layout-master-set child of the root element, containing the page layouts and the rules that specify which one gets used for which kind of page. The first order of business is to start the layout-master-set element.

fosoxtest
# - - -   b u i l d M a s t e r s

def buildMasters(s):
    '''Set up all page layout.
    '''
    #-- 1
    # [ s  +:=  a new, open layout-master-set element
    #   layout  :=  a sox.Elt instance representing that element ]
    layout = f.layoutMasterSet(s)

The first simple-page-master is for odd-numbered pages. It contains a region-body element, a region-before element for the header, and a region-after element for the footer. The second simple-page-master has the same structure.

fosoxtest
    #-- 2
    # [ s  +:=  a simple-page-master named ODD_MASTER with
    #       a body of size ODD_DIMS, a header region named
    #       ODD_BEFORE sized by ODD_DIMS, and a footer region
    #       named ODD_AFTER sized by ODD_DIMS ]
    oddMaster = f.simpleMaster(s, ODD_MASTER, ODD_DIMS)
    f.regionBody(s, ODD_DIMS)
    f.regionBefore(s, ODD_BEFORE, ODD_DIMS)
    f.regionAfter(s, ODD_AFTER, ODD_DIMS)
    oddMaster.end()

    #-- 3
    # [ s  +:=  a simple-page-master named EVEN_MASTER with
    #       a body of size EVEN_DIMS, a header region named
    #       EVEN_BEFORE sized by EVEN_DIMS, and a footer region
    #       named EVEN_AFTER sized by EVEN_DIMS ]
    evenMaster = f.simpleMaster(s, EVEN_MASTER, EVEN_DIMS)
    f.regionBody(s, EVEN_DIMS)
    f.regionBefore(s, EVEN_BEFORE, EVEN_DIMS)
    f.regionAfter(s, EVEN_AFTER, EVEN_DIMS)
    evenMaster.end()

The second child of the layout-master-set is the page-sequence-master element, which contains a repeatable-page-master-alternatives element, which in turn contains two conditional-page-master-reference elements that specify the rules for odd and even page formats.

fosoxtest
    #-- 4
    # [ s  +:=  a page-sequence-master element named REPEAT_MASTER,
    #       selecting ODD_MASTER for odd pages and EVEN_MASTER for
    #       even pages ]
    seqMaster = f.pageSequenceMaster(s, REPEAT_MASTER)
    masterAlts = f.repeatablePageMasterAlternatives(s)
    f.conditionalPageMasterReference(s, ODD_MASTER, oddOrEven="odd")
    f.conditionalPageMasterReference(s, EVEN_MASTER, oddOrEven="even")
    masterAlts.end()
    seqMaster.end()

    #-- 5
    # [ s  +:=  (end tag for layout) ]
    layout.end()