src/reportlab/platypus/tables.py
changeset 3504 1d048454e4fe
parent 3502 b2c9927314fc
child 3507 5d4f0215bd8f
equal deleted inserted replaced
3502:b2c9927314fc 3504:1d048454e4fe
    22 from reportlab.lib.styles import PropertySet, ParagraphStyle, _baseFontName
    22 from reportlab.lib.styles import PropertySet, ParagraphStyle, _baseFontName
    23 from reportlab.lib import colors
    23 from reportlab.lib import colors
    24 from reportlab.lib.utils import fp_str
    24 from reportlab.lib.utils import fp_str
    25 from reportlab.pdfbase.pdfmetrics import stringWidth
    25 from reportlab.pdfbase.pdfmetrics import stringWidth
    26 
    26 
    27 class CellStyle(PropertySet):
       
    28     defaults = {
       
    29         'fontname':_baseFontName,
       
    30         'fontsize':10,
       
    31         'leading':12,
       
    32         'leftPadding':6,
       
    33         'rightPadding':6,
       
    34         'topPadding':3,
       
    35         'bottomPadding':3,
       
    36         'firstLineIndent':0,
       
    37         'color':colors.black,
       
    38         'alignment': 'LEFT',
       
    39         'background': colors.white,
       
    40         'valign': 'BOTTOM',
       
    41         'href': None,
       
    42         'destination':None,
       
    43         }
       
    44 
       
    45 LINECAPS={None: None, 'butt':0,'round':1,'projecting':2,'squared':2}
    27 LINECAPS={None: None, 'butt':0,'round':1,'projecting':2,'squared':2}
    46 LINEJOINS={None: None, 'miter':0, 'mitre':0, 'round':1,'bevel':2}
    28 LINEJOINS={None: None, 'miter':0, 'mitre':0, 'round':1,'bevel':2}
    47 
    29 
    48 # experimental replacement
    30 class CellStyle(PropertySet):
    49 class CellStyle1(PropertySet):
       
    50     fontname = _baseFontName
    31     fontname = _baseFontName
    51     fontsize = 10
    32     fontsize = 10
    52     leading = 12
    33     leading = 12
    53     leftPadding = 6
    34     leftPadding = 6
    54     rightPadding = 6
    35     rightPadding = 6
    55     topPadding = 3
    36     topPadding = 3
    56     bottomPadding = 3
    37     bottomPadding = 3
    57     firstLineIndent = 0
    38     firstLineIndent = 0
    58     color = colors.black
    39     color = 'black'
    59     alignment = 'LEFT'
    40     alignment = 'LEFT'
    60     background = colors.white
    41     background = 'white'
    61     valign = "BOTTOM"
    42     valign = "BOTTOM"
    62     href = None
    43     href = None
    63     destination = None
    44     destination = None
    64     def __init__(self, name, parent=None):
    45     def __init__(self, name, parent=None):
    65         self.name = name
    46         self.name = name
    66         if parent is not None:
    47         if parent is not None:
    67             parent.copy(self)
    48             parent.copy(self)
    68     def copy(self, result=None):
    49     def copy(self, result=None):
    69         if result is None:
    50         if result is None:
    70             result = CellStyle1()
    51             result = CellStyle()
    71         for name in dir(self):
    52         for name in dir(self):
    72             setattr(result, name, getattr(self, name))
    53             setattr(result, name, getattr(self, name))
    73         return result
    54         return result
    74 CellStyle = CellStyle1
       
    75 
    55 
    76 class TableStyle:
    56 class TableStyle:
    77     def __init__(self, cmds=None, parent=None, **kw):
    57     def __init__(self, cmds=None, parent=None, **kw):
    78         #handle inheritance from parent first.
    58         #handle inheritance from parent first.
    79         commands = []
    59         commands = []