reportlab/platypus/flowables.py
changeset 2113 e82d8b3880d8
parent 2080 39156f56ab6f
child 2158 e9c34b93e317
equal deleted inserted replaced
2112:8281bbabfd67 2113:e82d8b3880d8
     1 #copyright ReportLab Inc. 2000
     1 #copyright ReportLab Inc. 2000
     2 #see license.txt for license details
     2 #see license.txt for license details
     3 #history http://cvs.sourceforge.net/cgi-bin/cvsweb.cgi/reportlab/platypus/flowables.py?cvsroot=reportlab
     3 #history http://cvs.sourceforge.net/cgi-bin/cvsweb.cgi/reportlab/platypus/flowables.py?cvsroot=reportlab
     4 #$Header: /tmp/reportlab/reportlab/platypus/flowables.py,v 1.40 2003/09/18 09:07:37 rgbecker Exp $
     4 #$Header: /tmp/reportlab/reportlab/platypus/flowables.py,v 1.41 2003/11/09 00:54:22 andy_robinson Exp $
     5 __version__=''' $Id: flowables.py,v 1.40 2003/09/18 09:07:37 rgbecker Exp $ '''
     5 __version__=''' $Id: flowables.py,v 1.41 2003/11/09 00:54:22 andy_robinson Exp $ '''
     6 __doc__="""
     6 __doc__="""
     7 A flowable is a "floating element" in a document whose exact position is determined by the
     7 A flowable is a "floating element" in a document whose exact position is determined by the
     8 other elements that precede it, such as a paragraph, a diagram interspersed between paragraphs,
     8 other elements that precede it, such as a paragraph, a diagram interspersed between paragraphs,
     9 a section header, etcetera.  Examples of non-flowables include page numbering annotations,
     9 a section header, etcetera.  Examples of non-flowables include page numbering annotations,
    10 headers, footers, fixed diagrams or logos, among others.
    10 headers, footers, fixed diagrams or logos, among others.
    36 from reportlab.pdfbase import pdfutils
    36 from reportlab.pdfbase import pdfutils
    37 
    37 
    38 from reportlab.rl_config import defaultPageSize
    38 from reportlab.rl_config import defaultPageSize
    39 PAGE_HEIGHT = defaultPageSize[1]
    39 PAGE_HEIGHT = defaultPageSize[1]
    40 
    40 
       
    41 
       
    42 class TraceInfo:
       
    43     "Holder for info about where an object originated"
       
    44     def __init__(self):
       
    45         self.srcFile = '(unknown)'
       
    46         self.startLineNo = -1
       
    47         self.startLinePos = -1
       
    48         self.endLineNo = -1
       
    49         self.endLinePos = -1
       
    50         
    41 #############################################################
    51 #############################################################
    42 #   Flowable Objects - a base class and a few examples.
    52 #   Flowable Objects - a base class and a few examples.
    43 #   One is just a box to get some metrics.  We also have
    53 #   One is just a box to get some metrics.  We also have
    44 #   a paragraph, an image and a special 'page break'
    54 #   a paragraph, an image and a special 'page break'
    45 #   object which fills the space.
    55 #   object which fills the space.
    60 
    70 
    61         #these are hints to packers/frames as to how the floable should be positioned
    71         #these are hints to packers/frames as to how the floable should be positioned
    62         self.hAlign = 'LEFT'    #CENTER/CENTRE or RIGHT
    72         self.hAlign = 'LEFT'    #CENTER/CENTRE or RIGHT
    63         self.vAlign = 'BOTTOM'  #MIDDLE or TOP
    73         self.vAlign = 'BOTTOM'  #MIDDLE or TOP
    64 
    74 
       
    75         #optional holder for trace info
       
    76         self._traceInfo = None
       
    77         
    65 
    78 
    66     def _drawOn(self,canv):
    79     def _drawOn(self,canv):
    67         '''ensure canv is set on and then draw'''
    80         '''ensure canv is set on and then draw'''
    68         self.canv = canv
    81         self.canv = canv
    69         self.draw()#this is the bit you overload
    82         self.draw()#this is the bit you overload
   489 
   502 
   490     def draw(self):
   503     def draw(self):
   491         canv = self.canv
   504         canv = self.canv
   492         self.I.drawOn(canv,self.width-self.wI-self.xpad,self.height-self.hI)
   505         self.I.drawOn(canv,self.width-self.wI-self.xpad,self.height-self.hI)
   493         self.P.drawOn(canv,0,0)
   506         self.P.drawOn(canv,0,0)
       
   507 
       
   508 class FailOnWrap(Flowable):
       
   509     def wrap(self, availWidth, availHeight):
       
   510         raise ValueError("FailOnWrap flowable wrapped and failing as ordered!")
       
   511     
       
   512     def draw(self):
       
   513         pass
       
   514 
       
   515 class FailOnDraw(Flowable):
       
   516     def wrap(self, availWidth, availHeight):
       
   517         return (0,0)
       
   518     
       
   519     def draw(self):
       
   520         raise ValueError("FailOnDraw flowable drawn, and failing as ordered!")