reportlab/platypus/tables.py
changeset 248 c103b7a55e79
parent 221 3d71b66b14c6
child 253 cfcf8d555a2c
equal deleted inserted replaced
247:5d531acd7059 248:c103b7a55e79
    29 # OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
    29 # OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
    30 # PERFORMANCE OF THIS SOFTWARE. 
    30 # PERFORMANCE OF THIS SOFTWARE. 
    31 #
    31 #
    32 ###############################################################################
    32 ###############################################################################
    33 #	$Log: tables.py,v $
    33 #	$Log: tables.py,v $
       
    34 #	Revision 1.10  2000/05/26 09:49:23  rgbecker
       
    35 #	Color fixes; thanks to J Alet
       
    36 #
    34 #	Revision 1.9  2000/05/16 16:15:16  rgbecker
    37 #	Revision 1.9  2000/05/16 16:15:16  rgbecker
    35 #	Changes related to removal of SimpleFlowDocument
    38 #	Changes related to removal of SimpleFlowDocument
    36 #
    39 #	
    37 #	Revision 1.8  2000/04/26 11:07:15  andy_robinson
    40 #	Revision 1.8  2000/04/26 11:07:15  andy_robinson
    38 #	Tables changed to use reportlab.lib.colors instead of
    41 #	Tables changed to use reportlab.lib.colors instead of
    39 #	the six hard-coded color strings there previously.
    42 #	the six hard-coded color strings there previously.
    40 #	
    43 #	
    41 #	Revision 1.7  2000/04/14 12:17:05  rgbecker
    44 #	Revision 1.7  2000/04/14 12:17:05  rgbecker
    54 #	License text fixes
    57 #	License text fixes
    55 #	
    58 #	
    56 #	Revision 1.2  2000/02/15 15:47:09  rgbecker
    59 #	Revision 1.2  2000/02/15 15:47:09  rgbecker
    57 #	Added license, __version__ and Logi comment
    60 #	Added license, __version__ and Logi comment
    58 #	
    61 #	
    59 __version__=''' $Id: tables.py,v 1.9 2000/05/16 16:15:16 rgbecker Exp $ '''
    62 __version__=''' $Id: tables.py,v 1.10 2000/05/26 09:49:23 rgbecker Exp $ '''
    60 __doc__="""
    63 __doc__="""
    61 Tables are created by passing the constructor a tuple of column widths, a tuple of row heights and the data in
    64 Tables are created by passing the constructor a tuple of column widths, a tuple of row heights and the data in
    62 row order. Drawing of the table can be controlled by using a TableStyle instance. This allows control of the
    65 row order. Drawing of the table can be controlled by using a TableStyle instance. This allows control of the
    63 color and weight of the lines (if any), and the font, alignment and padding of the text.
    66 color and weight of the lines (if any), and the font, alignment and padding of the text.
    64 """
    67 """
   219         for cmd, (sc, sr), (ec, er), color in self._bkgrndcmds:
   222         for cmd, (sc, sr), (ec, er), color in self._bkgrndcmds:
   220             if sc < 0: sc = sc + self._ncols
   223             if sc < 0: sc = sc + self._ncols
   221             if ec < 0: ec = ec + self._ncols
   224             if ec < 0: ec = ec + self._ncols
   222             if sr < 0: sr = sr + self._nrows
   225             if sr < 0: sr = sr + self._nrows
   223             if er < 0: er = er + self._nrows
   226             if er < 0: er = er + self._nrows
   224             if type(color) is _stringtype:
   227             color = colors.toColor(color, colors.Color(1,1,1))
   225                 color = COLORS.get(values[0], (1,1,1))
       
   226             x0 = self._colpositions[sc]
   228             x0 = self._colpositions[sc]
   227             y0 = self._rowpositions[sr]
   229             y0 = self._rowpositions[sr]
   228             x1 = self._colpositions[ec+1]
   230             x1 = self._colpositions[ec+1]
   229             y1 = self._rowpositions[er+1]
   231             y1 = self._rowpositions[er+1]
   230             self.canv.setFillColor(color)
   232             self.canv.setFillColor(color)
   231             self.canv.rect(x0, y0, x1-x0, y1-y0,stroke=0,fill=1)
   233             self.canv.rect(x0, y0, x1-x0, y1-y0,stroke=0,fill=1)
       
   234 
   232     def _drawCell(self, cellval, cellstyle, (colpos, rowpos), (colwidth, rowheight)):
   235     def _drawCell(self, cellval, cellstyle, (colpos, rowpos), (colwidth, rowheight)):
   233         #print "cellstyle is ", repr(cellstyle), id(cellstyle)
   236         #print "cellstyle is ", repr(cellstyle), id(cellstyle)
   234         if self._curcellstyle is not cellstyle:
   237         if self._curcellstyle is not cellstyle:
   235             cur = self._curcellstyle
   238             cur = self._curcellstyle
   236             if cur is None or cellstyle.color != cur.color:
   239             if cur is None or cellstyle.color != cur.color:
   275     cellstyles[i][j] = new
   278     cellstyles[i][j] = new
   276     if op == 'FONT':
   279     if op == 'FONT':
   277         new.fontname = values[0]
   280         new.fontname = values[0]
   278         new.fontsize = values[1]
   281         new.fontsize = values[1]
   279     elif op == 'TEXTCOLOR':
   282     elif op == 'TEXTCOLOR':
   280         if type(values[0]) is _stringtype:
   283         new.color = colors.toColor(values[0], colors.Color(0,0,0))
   281             new.color = COLORS.get(values[0], (0,0,0))
       
   282         else:
       
   283             new.color = values[0]
       
   284     elif op in ('ALIGN', 'ALIGNMENT'):
   284     elif op in ('ALIGN', 'ALIGNMENT'):
   285         new.alignment = values[0]
   285         new.alignment = values[0]
   286     elif op == 'LEFTPADDING':
   286     elif op == 'LEFTPADDING':
   287         new.leftPadding = values[0]
   287         new.leftPadding = values[0]
   288     elif op == 'RIGHTPADDING':
   288     elif op == 'RIGHTPADDING':