Next / Previous / Contents / TCC Help System / NM Tech homepage

45.4. PhysRow.html(): Render as XHTML

cbchistlib.py
# - - -   P h y s R o w . h t m l

    def html(self, sox, rowx):
        '''Render self as XHTML using the appearance for row (rowx).
        '''

There are two rules governing the thickening of top cell borders. The first row has a thick top border; see Section 13.4.16, “CLASS_FIRST. After that, every row that is a multiple of ROW_GROUPING has a medium top border; see Section 13.4.18, “CLASS_TOPPER.

For a discussion of the general approach to combining CSS classes from multiple sources, see Section 4.5, “CSS considerations in page design”. This is implemented by creating a dictionary named addCss that may or may not contain CSS class markup, and passing that dictionary down to the cell renderer to be combined with its CSS for thickening left borders.

cbchistlib.py
        #-- 1
        if rowx == 0:
            addCss = CLASS_FIRST
        elif (rowx % ROW_GROUPING) == 0:
            addCss = CLASS_TOPPER
        else:
            addCss = None

Not all physical rows even have a cell in the row-label column: if this is a continuation row, the first cell is omitted because the first physical row of this logical row had a row label that spanned the first column of all the physical rows.

If the row label is spanned (that is, self._span > 0), we add the th element generated by the RowLabel instance, then add to that element a rowspan attribute for the number of rows specified by self._span.

cbchistlib.py
        #-- 2
        # [ sox  +:=  a new tr start tag
        #   tr  :=  the sox.Elt for that element ]
        tr = sox.start("tr")

        #-- 3
        # [ if self._span is 0 ->
        #     I
        #   else ->
        #     sox  +:=  a th et.Element representing self._rowLabel
        #         with a rowspan attribute whose value is self._span ]
        if self._span > 0:
            self._rowLabel.html(sox, rowspan=str(self._span))

More CSS attributes may be added to thicken the rules on the left side of columns whose index is a multiple of COL_GROUPING.

cbchistlib.py
        #-- 4
        # [ tr  +:=  elements of self._cellList rendered as XHTML ]
        for colx, cell in enumerate(self._cellList):
            #-- 4 body
            # [ if colx is a multiple of COL_GROUPING ->
            #     sox  +:=  a new td representing cell with the additional
            #        style classes in addCss and CLASS_LEFTER
            #   else ->
            #     sox  +:=  a new td representing cell with the additional
            #        style classes in addCss ]
            if (colx % COL_GROUPING) == 0:
                css = combineCss(addCss, CLASS_LEFTER)
            else:
                css = addCss
            cell.html(sox, css)

        #-- 5
        tr.end()