Next / Previous / Contents / Shipman's homepage

19. class BodyLayout: Page geometry

This class's constructor works out the detailed geometry of a page layout, independent of even/odd-page margins and headings.

Here is the class interface:

listext2
# - - - - -   c l a s s   B o d y L a y o u t

class BodyLayout(object):
    '''Describes the geometry of the selected layout options.

      Exports:
        BodyLayout():
          [ return a new BodyLayout instance describing the layout
            specified by Args() ]
        .oddDims:
          [ an h.PageDim representing self's odd-page layout ]
        .evenDims:
          [ an h.PageDim representing self's even-page layout ]
        .oneColWide:
          [ width of one column as an h.FoDim ]
        .oneCharWide:
          [ width of one character as an h.FoDim ]
        .charsPerCol:
          [ number of characters that will fit in one column width,
            >= 1 ]
        .charsPerOver:
          [ number of characters that will fit in an overflow line,
            >= 1]
        .indent:
          [ amount to indent an overflow line as an h.FoDim ]
        .linesPerCol:
          [ number of lines with height specified by Args() that will
            fit in one column ]
    '''

19.1. class BodyLayout: Constants

The PAGE_MARGIN_MAP describes the page margins for the various different layout cases; refer to Section 5.2, “XSL-FO design: General page layout” for illustrations. The FRAME_MARGIN_MAP describes whether the running head is in the before or after region.

listext2
# - - -   B o d y L a y o u t . P A G E _ M A R G I N _ M A P

    # [ PAGE_MARGIN_MAP  :=  a dictionary whose keys are
    #       (isLand,isEven) tuples, where isLand is True for
    #       landscape, and isEven is True for even pages,
    #       and the corresponding key is an h.MarginSet instance
    #       appropriate for the h.PageDim.pageMargin attribute ]
    PAGE_MARGIN_MAP = {
    # (isLand, isEven)
      (False, False):    # Portrait, odd pages
          h.MarginSet(top=NARROW_MARGIN, bot=NARROW_MARGIN,
                      left=BOUND_MARGIN, right=UNBOUND_MARGIN),
      (False, True):     # Portrait, even pages
          h.MarginSet(top=NARROW_MARGIN, bot=NARROW_MARGIN,
                      left=UNBOUND_MARGIN, right=BOUND_MARGIN),
      (True, False):     # Landscape, odd pages
          h.MarginSet(top=BOUND_MARGIN, bot=UNBOUND_MARGIN,
                      left=NARROW_MARGIN, right=NARROW_MARGIN),
      (True, True):      # Landscape, even pages
          h.MarginSet(top=UNBOUND_MARGIN, bot=BOUND_MARGIN,
                      left=NARROW_MARGIN, right=NARROW_MARGIN) }

# - - -   B o d y L a y o u t . F R A M E _ M A R G I N _ M A P

    # [ FRAME_MARGIN_MAP  :=  a dictionary whose keys are
    #       (isLand,isEven) tuples, where isLand is True for
    #       landscape, and isEven is True for even pages,
    #       and the corresponding key is an h.MarginSet instance
    #       appropriate for the h.pageDim.FrameMargin attribute ]
    FRAME_MARGIN_MAP = {
    # (isLand, isEven)
      (False, False):    # Portrait, odd pages
          h.MarginSet(top=HEADING_EXTENT, bot=ZERO_DIM),
      (False, True):     # Portrait, even pages          
          h.MarginSet(top=HEADING_EXTENT, bot=ZERO_DIM),
      (True, False):     # Landscape, odd pages
          h.MarginSet(top=ZERO_DIM, bot=HEADING_EXTENT),
      (True, True):      # Landscape, even pages
          h.MarginSet(top=HEADING_EXTENT, bot=ZERO_DIM) }