reportlab/platypus/layout.py
author rgbecker
Tue, 16 May 2000 16:15:16 +0000
changeset 221 3d71b66b14c6
parent 212 b04e22acb4fa
child 226 a9acb67cdef7
permissions -rwxr-xr-x
Changes related to removal of SimpleFlowDocument
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
6
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
     1
###############################################################################
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
     2
#
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
     3
#	ReportLab Public License Version 1.0
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
     4
#
117
fd3682228853 XML Tagged Paragraph parser changes
rgbecker
parents: 104
diff changeset
     5
#	Except for the change of names the spirit and intention of this
fd3682228853 XML Tagged Paragraph parser changes
rgbecker
parents: 104
diff changeset
     6
#	license is the same as that of Python
6
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
     7
#
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
     8
#	(C) Copyright ReportLab Inc. 1998-2000.
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
     9
#
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
    10
#
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
    11
# All Rights Reserved
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
    12
#
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
    13
# Permission to use, copy, modify, and distribute this software and its
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
    14
# documentation for any purpose and without fee is hereby granted, provided
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
    15
# that the above copyright notice appear in all copies and that both that
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
    16
# copyright notice and this permission notice appear in supporting
7
ca9eb4f68eab License text fixes
rgbecker
parents: 6
diff changeset
    17
# documentation, and that the name of ReportLab not be used
6
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
    18
# in advertising or publicity pertaining to distribution of the software
22
dcfc888b1062 GMCM's memleak fixed
rgbecker
parents: 16
diff changeset
    19
# without specific, written prior permission.
dcfc888b1062 GMCM's memleak fixed
rgbecker
parents: 16
diff changeset
    20
#
6
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
    21
#
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
    22
# Disclaimer
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
    23
#
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
    24
# ReportLab Inc. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
    25
# SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS,
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
    26
# IN NO EVENT SHALL ReportLab BE LIABLE FOR ANY SPECIAL, INDIRECT
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
    27
# OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
    28
# OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
    29
# OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
22
dcfc888b1062 GMCM's memleak fixed
rgbecker
parents: 16
diff changeset
    30
# PERFORMANCE OF THIS SOFTWARE.
6
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
    31
#
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
    32
###############################################################################
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
    33
#	$Log: layout.py,v $
221
3d71b66b14c6 Changes related to removal of SimpleFlowDocument
rgbecker
parents: 212
diff changeset
    34
#	Revision 1.26  2000/05/16 16:15:16  rgbecker
3d71b66b14c6 Changes related to removal of SimpleFlowDocument
rgbecker
parents: 212
diff changeset
    35
#	Changes related to removal of SimpleFlowDocument
3d71b66b14c6 Changes related to removal of SimpleFlowDocument
rgbecker
parents: 212
diff changeset
    36
#
212
b04e22acb4fa Splitting changes
rgbecker
parents: 196
diff changeset
    37
#	Revision 1.25  2000/05/15 13:36:11  rgbecker
b04e22acb4fa Splitting changes
rgbecker
parents: 196
diff changeset
    38
#	Splitting changes
221
3d71b66b14c6 Changes related to removal of SimpleFlowDocument
rgbecker
parents: 212
diff changeset
    39
#	
196
b2545a941a37 Fixes to BasicFrame split method
rgbecker
parents: 191
diff changeset
    40
#	Revision 1.24  2000/05/12 12:52:00  rgbecker
b2545a941a37 Fixes to BasicFrame split method
rgbecker
parents: 191
diff changeset
    41
#	Fixes to BasicFrame split method
212
b04e22acb4fa Splitting changes
rgbecker
parents: 196
diff changeset
    42
#	
191
c4907a8ee681 Removed usage of spaceBefore/After in wrap methods
rgbecker
parents: 185
diff changeset
    43
#	Revision 1.23  2000/05/11 14:02:14  rgbecker
c4907a8ee681 Removed usage of spaceBefore/After in wrap methods
rgbecker
parents: 185
diff changeset
    44
#	Removed usage of spaceBefore/After in wrap methods
196
b2545a941a37 Fixes to BasicFrame split method
rgbecker
parents: 191
diff changeset
    45
#	
185
b68f142d9302 Added softspace handling
rgbecker
parents: 184
diff changeset
    46
#	Revision 1.22  2000/05/10 13:04:35  rgbecker
b68f142d9302 Added softspace handling
rgbecker
parents: 184
diff changeset
    47
#	Added softspace handling
191
c4907a8ee681 Removed usage of spaceBefore/After in wrap methods
rgbecker
parents: 185
diff changeset
    48
#	
184
bd625c2fecf1 Flowable.split should return list
rgbecker
parents: 178
diff changeset
    49
#	Revision 1.21  2000/05/10 09:54:40  rgbecker
bd625c2fecf1 Flowable.split should return list
rgbecker
parents: 178
diff changeset
    50
#	Flowable.split should return list
185
b68f142d9302 Added softspace handling
rgbecker
parents: 184
diff changeset
    51
#	
178
0d2557b905da Fix _doNothing argument name
rgbecker
parents: 168
diff changeset
    52
#	Revision 1.20  2000/04/28 13:39:12  rgbecker
0d2557b905da Fix _doNothing argument name
rgbecker
parents: 168
diff changeset
    53
#	Fix _doNothing argument name
184
bd625c2fecf1 Flowable.split should return list
rgbecker
parents: 178
diff changeset
    54
#	
168
02bac1346c69 Tables changed to use reportlab.lib.colors instead of
andy_robinson
parents: 164
diff changeset
    55
#	Revision 1.19  2000/04/26 11:07:15  andy_robinson
02bac1346c69 Tables changed to use reportlab.lib.colors instead of
andy_robinson
parents: 164
diff changeset
    56
#	Tables changed to use reportlab.lib.colors instead of
02bac1346c69 Tables changed to use reportlab.lib.colors instead of
andy_robinson
parents: 164
diff changeset
    57
#	the six hard-coded color strings there previously.
178
0d2557b905da Fix _doNothing argument name
rgbecker
parents: 168
diff changeset
    58
#	
164
b5f77d851755 Factored out BasicFrame from SimpleFrame
rgbecker
parents: 133
diff changeset
    59
#	Revision 1.18  2000/04/25 15:42:04  rgbecker
b5f77d851755 Factored out BasicFrame from SimpleFrame
rgbecker
parents: 133
diff changeset
    60
#	Factored out BasicFrame from SimpleFrame
168
02bac1346c69 Tables changed to use reportlab.lib.colors instead of
andy_robinson
parents: 164
diff changeset
    61
#	
133
ba7b4eb9be6c Debugging xml changes
rgbecker
parents: 128
diff changeset
    62
#	Revision 1.17  2000/04/14 16:12:11  rgbecker
ba7b4eb9be6c Debugging xml changes
rgbecker
parents: 128
diff changeset
    63
#	Debugging xml changes
164
b5f77d851755 Factored out BasicFrame from SimpleFrame
rgbecker
parents: 133
diff changeset
    64
#	
128
a0676f013314 Splitting layout.py
rgbecker
parents: 122
diff changeset
    65
#	Revision 1.16  2000/04/14 11:54:57  rgbecker
a0676f013314 Splitting layout.py
rgbecker
parents: 122
diff changeset
    66
#	Splitting layout.py
133
ba7b4eb9be6c Debugging xml changes
rgbecker
parents: 128
diff changeset
    67
#	
122
fd68411f49db Drawable ==> Flowable
rgbecker
parents: 120
diff changeset
    68
#	Revision 1.15  2000/04/14 08:56:20  rgbecker
fd68411f49db Drawable ==> Flowable
rgbecker
parents: 120
diff changeset
    69
#	Drawable ==> Flowable
128
a0676f013314 Splitting layout.py
rgbecker
parents: 122
diff changeset
    70
#	
120
8fd42911c1d0 Fixed SimpleFrame.add
rgbecker
parents: 119
diff changeset
    71
#	Revision 1.14  2000/04/13 17:06:40  rgbecker
8fd42911c1d0 Fixed SimpleFrame.add
rgbecker
parents: 119
diff changeset
    72
#	Fixed SimpleFrame.add
122
fd68411f49db Drawable ==> Flowable
rgbecker
parents: 120
diff changeset
    73
#	
119
b4dc589c8364 <para> tag added in layout.py paraparser.py
rgbecker
parents: 117
diff changeset
    74
#	Revision 1.13  2000/04/13 14:48:41  rgbecker
b4dc589c8364 <para> tag added in layout.py paraparser.py
rgbecker
parents: 117
diff changeset
    75
#	<para> tag added in layout.py paraparser.py
120
8fd42911c1d0 Fixed SimpleFrame.add
rgbecker
parents: 119
diff changeset
    76
#	
117
fd3682228853 XML Tagged Paragraph parser changes
rgbecker
parents: 104
diff changeset
    77
#	Revision 1.12  2000/04/12 16:26:51  rgbecker
fd3682228853 XML Tagged Paragraph parser changes
rgbecker
parents: 104
diff changeset
    78
#	XML Tagged Paragraph parser changes
119
b4dc589c8364 <para> tag added in layout.py paraparser.py
rgbecker
parents: 117
diff changeset
    79
#	
104
c7458ac2abd2 fixes related to offset
rgbecker
parents: 103
diff changeset
    80
#	Revision 1.11  2000/04/10 14:08:19  rgbecker
c7458ac2abd2 fixes related to offset
rgbecker
parents: 103
diff changeset
    81
#	fixes related to offset
117
fd3682228853 XML Tagged Paragraph parser changes
rgbecker
parents: 104
diff changeset
    82
#	
103
dd883bfb651b Typo fixes for justified paras
rgbecker
parents: 95
diff changeset
    83
#	Revision 1.10  2000/04/10 12:25:10  rgbecker
dd883bfb651b Typo fixes for justified paras
rgbecker
parents: 95
diff changeset
    84
#	Typo fixes for justified paras
104
c7458ac2abd2 fixes related to offset
rgbecker
parents: 103
diff changeset
    85
#	
95
f662b290f216 Color fixes/changes
rgbecker
parents: 77
diff changeset
    86
#	Revision 1.9  2000/04/07 12:31:29  rgbecker
f662b290f216 Color fixes/changes
rgbecker
parents: 77
diff changeset
    87
#	Color fixes/changes
103
dd883bfb651b Typo fixes for justified paras
rgbecker
parents: 95
diff changeset
    88
#	
77
a5d452cb7a5d Removed some old comments; tweaks to experimental Outline methods.
andy_robinson
parents: 42
diff changeset
    89
#	Revision 1.8  2000/04/06 09:52:02  andy_robinson
a5d452cb7a5d Removed some old comments; tweaks to experimental Outline methods.
andy_robinson
parents: 42
diff changeset
    90
#	Removed some old comments; tweaks to experimental Outline methods.
95
f662b290f216 Color fixes/changes
rgbecker
parents: 77
diff changeset
    91
#	
42
ba8c232f544e Moved inch and cm definitions to reportlab.lib.units and amended all demos
andy_robinson
parents: 22
diff changeset
    92
#	Revision 1.7  2000/03/08 13:06:39  andy_robinson
ba8c232f544e Moved inch and cm definitions to reportlab.lib.units and amended all demos
andy_robinson
parents: 22
diff changeset
    93
#	Moved inch and cm definitions to reportlab.lib.units and amended all demos
77
a5d452cb7a5d Removed some old comments; tweaks to experimental Outline methods.
andy_robinson
parents: 42
diff changeset
    94
#	
22
dcfc888b1062 GMCM's memleak fixed
rgbecker
parents: 16
diff changeset
    95
#	Revision 1.6  2000/02/23 10:53:33  rgbecker
dcfc888b1062 GMCM's memleak fixed
rgbecker
parents: 16
diff changeset
    96
#	GMCM's memleak fixed
42
ba8c232f544e Moved inch and cm definitions to reportlab.lib.units and amended all demos
andy_robinson
parents: 22
diff changeset
    97
#	
16
f9c7525619fb Docstring & other fixes
rgbecker
parents: 10
diff changeset
    98
#	Revision 1.5  2000/02/17 02:09:05  rgbecker
f9c7525619fb Docstring & other fixes
rgbecker
parents: 10
diff changeset
    99
#	Docstring & other fixes
22
dcfc888b1062 GMCM's memleak fixed
rgbecker
parents: 16
diff changeset
   100
#	
10
0cb88428a663 Conversion to reportlab package
rgbecker
parents: 7
diff changeset
   101
#	Revision 1.4  2000/02/16 09:42:50  rgbecker
0cb88428a663 Conversion to reportlab package
rgbecker
parents: 7
diff changeset
   102
#	Conversion to reportlab package
16
f9c7525619fb Docstring & other fixes
rgbecker
parents: 10
diff changeset
   103
#	
7
ca9eb4f68eab License text fixes
rgbecker
parents: 6
diff changeset
   104
#	Revision 1.3  2000/02/15 17:55:59  rgbecker
ca9eb4f68eab License text fixes
rgbecker
parents: 6
diff changeset
   105
#	License text fixes
10
0cb88428a663 Conversion to reportlab package
rgbecker
parents: 7
diff changeset
   106
#	
6
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   107
#	Revision 1.2  2000/02/15 15:47:09  rgbecker
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   108
#	Added license, __version__ and Logi comment
7
ca9eb4f68eab License text fixes
rgbecker
parents: 6
diff changeset
   109
#	
221
3d71b66b14c6 Changes related to removal of SimpleFlowDocument
rgbecker
parents: 212
diff changeset
   110
__version__=''' $Id: layout.py,v 1.26 2000/05/16 16:15:16 rgbecker Exp $ '''
16
f9c7525619fb Docstring & other fixes
rgbecker
parents: 10
diff changeset
   111
__doc__="""
f9c7525619fb Docstring & other fixes
rgbecker
parents: 10
diff changeset
   112
Page Layout And TYPography Using Scripts
f9c7525619fb Docstring & other fixes
rgbecker
parents: 10
diff changeset
   113
a page layout API on top of PDFgen
f9c7525619fb Docstring & other fixes
rgbecker
parents: 10
diff changeset
   114
currently working on paragraph wrapping stuff.
f9c7525619fb Docstring & other fixes
rgbecker
parents: 10
diff changeset
   115
"""
0
f19e0a2433ab Initial revision
gmcm
parents:
diff changeset
   116
6
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   117
# 200-10-13 gmcm
117
fd3682228853 XML Tagged Paragraph parser changes
rgbecker
parents: 104
diff changeset
   118
#	packagizing
fd3682228853 XML Tagged Paragraph parser changes
rgbecker
parents: 104
diff changeset
   119
#	rewrote grid stuff - now in tables.py
0
f19e0a2433ab Initial revision
gmcm
parents:
diff changeset
   120
f19e0a2433ab Initial revision
gmcm
parents:
diff changeset
   121
import string
f19e0a2433ab Initial revision
gmcm
parents:
diff changeset
   122
10
0cb88428a663 Conversion to reportlab package
rgbecker
parents: 7
diff changeset
   123
from reportlab.pdfgen import canvas
42
ba8c232f544e Moved inch and cm definitions to reportlab.lib.units and amended all demos
andy_robinson
parents: 22
diff changeset
   124
from reportlab.lib.units import inch
128
a0676f013314 Splitting layout.py
rgbecker
parents: 122
diff changeset
   125
from reportlab.lib.colors import red
42
ba8c232f544e Moved inch and cm definitions to reportlab.lib.units and amended all demos
andy_robinson
parents: 22
diff changeset
   126
119
b4dc589c8364 <para> tag added in layout.py paraparser.py
rgbecker
parents: 117
diff changeset
   127
from reportlab.lib.pagesizes import DEFAULT_PAGE_SIZE
0
f19e0a2433ab Initial revision
gmcm
parents:
diff changeset
   128
PAGE_HEIGHT = DEFAULT_PAGE_SIZE[1]
f19e0a2433ab Initial revision
gmcm
parents:
diff changeset
   129
117
fd3682228853 XML Tagged Paragraph parser changes
rgbecker
parents: 104
diff changeset
   130
#############################################################
122
fd68411f49db Drawable ==> Flowable
rgbecker
parents: 120
diff changeset
   131
#	Flowable Objects - a base class and a few examples.
117
fd3682228853 XML Tagged Paragraph parser changes
rgbecker
parents: 104
diff changeset
   132
#	One is just a box to get some metrics.	We also have
fd3682228853 XML Tagged Paragraph parser changes
rgbecker
parents: 104
diff changeset
   133
#	a paragraph, an image and a special 'page break'
fd3682228853 XML Tagged Paragraph parser changes
rgbecker
parents: 104
diff changeset
   134
#	object which fills the space.
168
02bac1346c69 Tables changed to use reportlab.lib.colors instead of
andy_robinson
parents: 164
diff changeset
   135
#############################################################
122
fd68411f49db Drawable ==> Flowable
rgbecker
parents: 120
diff changeset
   136
class Flowable:
117
fd3682228853 XML Tagged Paragraph parser changes
rgbecker
parents: 104
diff changeset
   137
	"""Abstract base class for things to be drawn.	Key concepts:
fd3682228853 XML Tagged Paragraph parser changes
rgbecker
parents: 104
diff changeset
   138
	1. It knows its size
fd3682228853 XML Tagged Paragraph parser changes
rgbecker
parents: 104
diff changeset
   139
	2. It draws in its own coordinate system (this requires the
fd3682228853 XML Tagged Paragraph parser changes
rgbecker
parents: 104
diff changeset
   140
		base API to provide a translate() function.
fd3682228853 XML Tagged Paragraph parser changes
rgbecker
parents: 104
diff changeset
   141
	"""
fd3682228853 XML Tagged Paragraph parser changes
rgbecker
parents: 104
diff changeset
   142
	def __init__(self):
fd3682228853 XML Tagged Paragraph parser changes
rgbecker
parents: 104
diff changeset
   143
		self.width = 0
fd3682228853 XML Tagged Paragraph parser changes
rgbecker
parents: 104
diff changeset
   144
		self.height = 0
fd3682228853 XML Tagged Paragraph parser changes
rgbecker
parents: 104
diff changeset
   145
		self.wrapped = 0
0
f19e0a2433ab Initial revision
gmcm
parents:
diff changeset
   146
117
fd3682228853 XML Tagged Paragraph parser changes
rgbecker
parents: 104
diff changeset
   147
	def drawOn(self, canvas, x, y):
fd3682228853 XML Tagged Paragraph parser changes
rgbecker
parents: 104
diff changeset
   148
		"Tell it to draw itself on the canvas.	Do not override"
fd3682228853 XML Tagged Paragraph parser changes
rgbecker
parents: 104
diff changeset
   149
		self.canv = canvas
fd3682228853 XML Tagged Paragraph parser changes
rgbecker
parents: 104
diff changeset
   150
		self.canv.saveState()
fd3682228853 XML Tagged Paragraph parser changes
rgbecker
parents: 104
diff changeset
   151
		self.canv.translate(x, y)
0
f19e0a2433ab Initial revision
gmcm
parents:
diff changeset
   152
117
fd3682228853 XML Tagged Paragraph parser changes
rgbecker
parents: 104
diff changeset
   153
		self.draw()   #this is the bit you overload
fd3682228853 XML Tagged Paragraph parser changes
rgbecker
parents: 104
diff changeset
   154
fd3682228853 XML Tagged Paragraph parser changes
rgbecker
parents: 104
diff changeset
   155
		self.canv.restoreState()
fd3682228853 XML Tagged Paragraph parser changes
rgbecker
parents: 104
diff changeset
   156
		del self.canv
22
dcfc888b1062 GMCM's memleak fixed
rgbecker
parents: 16
diff changeset
   157
dcfc888b1062 GMCM's memleak fixed
rgbecker
parents: 16
diff changeset
   158
117
fd3682228853 XML Tagged Paragraph parser changes
rgbecker
parents: 104
diff changeset
   159
	def wrap(self, availWidth, availHeight):
fd3682228853 XML Tagged Paragraph parser changes
rgbecker
parents: 104
diff changeset
   160
		"""This will be called by the enclosing frame before objects
fd3682228853 XML Tagged Paragraph parser changes
rgbecker
parents: 104
diff changeset
   161
		are asked their size, drawn or whatever.  It returns the
fd3682228853 XML Tagged Paragraph parser changes
rgbecker
parents: 104
diff changeset
   162
		size actually used."""
fd3682228853 XML Tagged Paragraph parser changes
rgbecker
parents: 104
diff changeset
   163
		return (self.width, self.height)
fd3682228853 XML Tagged Paragraph parser changes
rgbecker
parents: 104
diff changeset
   164
196
b2545a941a37 Fixes to BasicFrame split method
rgbecker
parents: 191
diff changeset
   165
	def split(self, availWidth, availheight):
178
0d2557b905da Fix _doNothing argument name
rgbecker
parents: 168
diff changeset
   166
		"""This will be called by more sophisticated frames when
196
b2545a941a37 Fixes to BasicFrame split method
rgbecker
parents: 191
diff changeset
   167
		wrap fails. Stupid flowables should return []. Clever flowables
178
0d2557b905da Fix _doNothing argument name
rgbecker
parents: 168
diff changeset
   168
		should split themselves and return a list of flowables"""
184
bd625c2fecf1 Flowable.split should return list
rgbecker
parents: 178
diff changeset
   169
		return []
178
0d2557b905da Fix _doNothing argument name
rgbecker
parents: 168
diff changeset
   170
191
c4907a8ee681 Removed usage of spaceBefore/After in wrap methods
rgbecker
parents: 185
diff changeset
   171
	def getSpaceAfter(self):
c4907a8ee681 Removed usage of spaceBefore/After in wrap methods
rgbecker
parents: 185
diff changeset
   172
		if hasattr(self,'spaceAfter'): return self.spaceAfter
c4907a8ee681 Removed usage of spaceBefore/After in wrap methods
rgbecker
parents: 185
diff changeset
   173
		elif hasattr(self,'style') and hasattr(self.style,'spaceAfter'): return self.style.spaceAfter
c4907a8ee681 Removed usage of spaceBefore/After in wrap methods
rgbecker
parents: 185
diff changeset
   174
		else: return 0
c4907a8ee681 Removed usage of spaceBefore/After in wrap methods
rgbecker
parents: 185
diff changeset
   175
c4907a8ee681 Removed usage of spaceBefore/After in wrap methods
rgbecker
parents: 185
diff changeset
   176
	def getSpaceBefore(self):
c4907a8ee681 Removed usage of spaceBefore/After in wrap methods
rgbecker
parents: 185
diff changeset
   177
		if hasattr(self,'spaceBefore'): return self.spaceBefore
c4907a8ee681 Removed usage of spaceBefore/After in wrap methods
rgbecker
parents: 185
diff changeset
   178
		elif hasattr(self,'style') and hasattr(self.style,'spaceBefore'): return self.style.spaceBefore
c4907a8ee681 Removed usage of spaceBefore/After in wrap methods
rgbecker
parents: 185
diff changeset
   179
		else: return 0
185
b68f142d9302 Added softspace handling
rgbecker
parents: 184
diff changeset
   180
122
fd68411f49db Drawable ==> Flowable
rgbecker
parents: 120
diff changeset
   181
class XBox(Flowable):
fd68411f49db Drawable ==> Flowable
rgbecker
parents: 120
diff changeset
   182
	"""Example flowable - a box with an x through it and a caption.
117
fd3682228853 XML Tagged Paragraph parser changes
rgbecker
parents: 104
diff changeset
   183
	This has a known size, so does not need to respond to wrap()."""
fd3682228853 XML Tagged Paragraph parser changes
rgbecker
parents: 104
diff changeset
   184
	def __init__(self, width, height, text = 'A Box'):
122
fd68411f49db Drawable ==> Flowable
rgbecker
parents: 120
diff changeset
   185
		Flowable.__init__(self)
117
fd3682228853 XML Tagged Paragraph parser changes
rgbecker
parents: 104
diff changeset
   186
		self.width = width
fd3682228853 XML Tagged Paragraph parser changes
rgbecker
parents: 104
diff changeset
   187
		self.height = height
fd3682228853 XML Tagged Paragraph parser changes
rgbecker
parents: 104
diff changeset
   188
		self.text = text
fd3682228853 XML Tagged Paragraph parser changes
rgbecker
parents: 104
diff changeset
   189
fd3682228853 XML Tagged Paragraph parser changes
rgbecker
parents: 104
diff changeset
   190
	def draw(self):
fd3682228853 XML Tagged Paragraph parser changes
rgbecker
parents: 104
diff changeset
   191
		self.canv.rect(0, 0, self.width, self.height)
fd3682228853 XML Tagged Paragraph parser changes
rgbecker
parents: 104
diff changeset
   192
		self.canv.line(0, 0, self.width, self.height)
fd3682228853 XML Tagged Paragraph parser changes
rgbecker
parents: 104
diff changeset
   193
		self.canv.line(0, self.height, self.width, 0)
fd3682228853 XML Tagged Paragraph parser changes
rgbecker
parents: 104
diff changeset
   194
fd3682228853 XML Tagged Paragraph parser changes
rgbecker
parents: 104
diff changeset
   195
		#centre the text
fd3682228853 XML Tagged Paragraph parser changes
rgbecker
parents: 104
diff changeset
   196
		self.canv.setFont('Times-Roman',12)
fd3682228853 XML Tagged Paragraph parser changes
rgbecker
parents: 104
diff changeset
   197
		self.canv.drawCentredString(0.5*self.width, 0.5*self.height, self.text)
fd3682228853 XML Tagged Paragraph parser changes
rgbecker
parents: 104
diff changeset
   198
122
fd68411f49db Drawable ==> Flowable
rgbecker
parents: 120
diff changeset
   199
class Preformatted(Flowable):
117
fd3682228853 XML Tagged Paragraph parser changes
rgbecker
parents: 104
diff changeset
   200
	"""This is like the HTML <PRE> tag.  The line breaks are exactly where you put
fd3682228853 XML Tagged Paragraph parser changes
rgbecker
parents: 104
diff changeset
   201
	them, and it will not be wrapped.  So it is much simpler to implement!"""
fd3682228853 XML Tagged Paragraph parser changes
rgbecker
parents: 104
diff changeset
   202
	def __init__(self, text, style, bulletText = None, dedent=0):
fd3682228853 XML Tagged Paragraph parser changes
rgbecker
parents: 104
diff changeset
   203
		self.style = style
fd3682228853 XML Tagged Paragraph parser changes
rgbecker
parents: 104
diff changeset
   204
		self.bulletText = bulletText
fd3682228853 XML Tagged Paragraph parser changes
rgbecker
parents: 104
diff changeset
   205
fd3682228853 XML Tagged Paragraph parser changes
rgbecker
parents: 104
diff changeset
   206
		#tidy up text - carefully, it is probably code.  If people want to
fd3682228853 XML Tagged Paragraph parser changes
rgbecker
parents: 104
diff changeset
   207
		#indent code within a source script, you can supply an arg to dedent
fd3682228853 XML Tagged Paragraph parser changes
rgbecker
parents: 104
diff changeset
   208
		#and it will chop off that many character, otherwise it leaves
fd3682228853 XML Tagged Paragraph parser changes
rgbecker
parents: 104
diff changeset
   209
		#left edge intact.
fd3682228853 XML Tagged Paragraph parser changes
rgbecker
parents: 104
diff changeset
   210
fd3682228853 XML Tagged Paragraph parser changes
rgbecker
parents: 104
diff changeset
   211
		templines = string.split(text, '\n')
fd3682228853 XML Tagged Paragraph parser changes
rgbecker
parents: 104
diff changeset
   212
		self.lines = []
fd3682228853 XML Tagged Paragraph parser changes
rgbecker
parents: 104
diff changeset
   213
		for line in templines:
fd3682228853 XML Tagged Paragraph parser changes
rgbecker
parents: 104
diff changeset
   214
			line = string.rstrip(line[dedent:])
fd3682228853 XML Tagged Paragraph parser changes
rgbecker
parents: 104
diff changeset
   215
			self.lines.append(line)
fd3682228853 XML Tagged Paragraph parser changes
rgbecker
parents: 104
diff changeset
   216
		#don't want the first or last to be empty
fd3682228853 XML Tagged Paragraph parser changes
rgbecker
parents: 104
diff changeset
   217
		while string.strip(self.lines[0]) == '':
fd3682228853 XML Tagged Paragraph parser changes
rgbecker
parents: 104
diff changeset
   218
			self.lines = self.lines[1:]
fd3682228853 XML Tagged Paragraph parser changes
rgbecker
parents: 104
diff changeset
   219
		while string.strip(self.lines[-1]) == '':
fd3682228853 XML Tagged Paragraph parser changes
rgbecker
parents: 104
diff changeset
   220
			self.lines = self.lines[:-1]
fd3682228853 XML Tagged Paragraph parser changes
rgbecker
parents: 104
diff changeset
   221
fd3682228853 XML Tagged Paragraph parser changes
rgbecker
parents: 104
diff changeset
   222
	def wrap(self, availWidth, availHeight):
fd3682228853 XML Tagged Paragraph parser changes
rgbecker
parents: 104
diff changeset
   223
		self.width = availWidth
191
c4907a8ee681 Removed usage of spaceBefore/After in wrap methods
rgbecker
parents: 185
diff changeset
   224
		self.height = self.style.leading*len(self.lines)
117
fd3682228853 XML Tagged Paragraph parser changes
rgbecker
parents: 104
diff changeset
   225
		return (self.width, self.height)
fd3682228853 XML Tagged Paragraph parser changes
rgbecker
parents: 104
diff changeset
   226
fd3682228853 XML Tagged Paragraph parser changes
rgbecker
parents: 104
diff changeset
   227
	def draw(self):
fd3682228853 XML Tagged Paragraph parser changes
rgbecker
parents: 104
diff changeset
   228
		#call another method for historical reasons.  Besides, I
fd3682228853 XML Tagged Paragraph parser changes
rgbecker
parents: 104
diff changeset
   229
		#suspect I will be playing with alternate drawing routines
fd3682228853 XML Tagged Paragraph parser changes
rgbecker
parents: 104
diff changeset
   230
		#so not doing it here makes it easier to switch.
fd3682228853 XML Tagged Paragraph parser changes
rgbecker
parents: 104
diff changeset
   231
fd3682228853 XML Tagged Paragraph parser changes
rgbecker
parents: 104
diff changeset
   232
		cur_x = self.style.leftIndent
191
c4907a8ee681 Removed usage of spaceBefore/After in wrap methods
rgbecker
parents: 185
diff changeset
   233
		cur_y = self.height - self.style.fontSize
117
fd3682228853 XML Tagged Paragraph parser changes
rgbecker
parents: 104
diff changeset
   234
		self.canv.addLiteral('%PreformattedPara')
fd3682228853 XML Tagged Paragraph parser changes
rgbecker
parents: 104
diff changeset
   235
fd3682228853 XML Tagged Paragraph parser changes
rgbecker
parents: 104
diff changeset
   236
		tx = self.canv.beginText(cur_x, cur_y)
fd3682228853 XML Tagged Paragraph parser changes
rgbecker
parents: 104
diff changeset
   237
		#set up the font etc.
fd3682228853 XML Tagged Paragraph parser changes
rgbecker
parents: 104
diff changeset
   238
		tx.setFont(self.style.fontName,
fd3682228853 XML Tagged Paragraph parser changes
rgbecker
parents: 104
diff changeset
   239
				   self.style.fontSize,
fd3682228853 XML Tagged Paragraph parser changes
rgbecker
parents: 104
diff changeset
   240
				   self.style.leading)
fd3682228853 XML Tagged Paragraph parser changes
rgbecker
parents: 104
diff changeset
   241
fd3682228853 XML Tagged Paragraph parser changes
rgbecker
parents: 104
diff changeset
   242
		for text in self.lines:
fd3682228853 XML Tagged Paragraph parser changes
rgbecker
parents: 104
diff changeset
   243
			tx.textLine(text)
fd3682228853 XML Tagged Paragraph parser changes
rgbecker
parents: 104
diff changeset
   244
		self.canv.drawText(tx)
fd3682228853 XML Tagged Paragraph parser changes
rgbecker
parents: 104
diff changeset
   245
122
fd68411f49db Drawable ==> Flowable
rgbecker
parents: 120
diff changeset
   246
class Image(Flowable):
117
fd3682228853 XML Tagged Paragraph parser changes
rgbecker
parents: 104
diff changeset
   247
	def __init__(self, filename, width=None, height=None):
fd3682228853 XML Tagged Paragraph parser changes
rgbecker
parents: 104
diff changeset
   248
		"""If size to draw at not specified, get it from the image."""
fd3682228853 XML Tagged Paragraph parser changes
rgbecker
parents: 104
diff changeset
   249
		import Image  #this will raise an error if they do not have PIL.
fd3682228853 XML Tagged Paragraph parser changes
rgbecker
parents: 104
diff changeset
   250
		self.filename = filename
fd3682228853 XML Tagged Paragraph parser changes
rgbecker
parents: 104
diff changeset
   251
		print 'Creating Image for', filename
fd3682228853 XML Tagged Paragraph parser changes
rgbecker
parents: 104
diff changeset
   252
		img = Image.open(filename)
fd3682228853 XML Tagged Paragraph parser changes
rgbecker
parents: 104
diff changeset
   253
		(self.imageWidth, self.imageHeight) = img.size
fd3682228853 XML Tagged Paragraph parser changes
rgbecker
parents: 104
diff changeset
   254
		if width:
fd3682228853 XML Tagged Paragraph parser changes
rgbecker
parents: 104
diff changeset
   255
			self.drawWidth = width
fd3682228853 XML Tagged Paragraph parser changes
rgbecker
parents: 104
diff changeset
   256
		else:
fd3682228853 XML Tagged Paragraph parser changes
rgbecker
parents: 104
diff changeset
   257
			self.drawWidth = self.imageWidth
fd3682228853 XML Tagged Paragraph parser changes
rgbecker
parents: 104
diff changeset
   258
		if height:
fd3682228853 XML Tagged Paragraph parser changes
rgbecker
parents: 104
diff changeset
   259
			self.drawHeight = height
fd3682228853 XML Tagged Paragraph parser changes
rgbecker
parents: 104
diff changeset
   260
		else:
fd3682228853 XML Tagged Paragraph parser changes
rgbecker
parents: 104
diff changeset
   261
			self.drawHeight = self.imageHeight
fd3682228853 XML Tagged Paragraph parser changes
rgbecker
parents: 104
diff changeset
   262
fd3682228853 XML Tagged Paragraph parser changes
rgbecker
parents: 104
diff changeset
   263
	def wrap(self, availWidth, availHeight):
fd3682228853 XML Tagged Paragraph parser changes
rgbecker
parents: 104
diff changeset
   264
		#the caller may decide it does not fit.
fd3682228853 XML Tagged Paragraph parser changes
rgbecker
parents: 104
diff changeset
   265
		self.availWidth = availWidth
fd3682228853 XML Tagged Paragraph parser changes
rgbecker
parents: 104
diff changeset
   266
		return (self.drawWidth, self.drawHeight)
fd3682228853 XML Tagged Paragraph parser changes
rgbecker
parents: 104
diff changeset
   267
fd3682228853 XML Tagged Paragraph parser changes
rgbecker
parents: 104
diff changeset
   268
	def draw(self):
fd3682228853 XML Tagged Paragraph parser changes
rgbecker
parents: 104
diff changeset
   269
		#center it
fd3682228853 XML Tagged Paragraph parser changes
rgbecker
parents: 104
diff changeset
   270
		startx = 0.5 * (self.availWidth - self.drawWidth)
fd3682228853 XML Tagged Paragraph parser changes
rgbecker
parents: 104
diff changeset
   271
		self.canv.drawInlineImage(self.filename,
fd3682228853 XML Tagged Paragraph parser changes
rgbecker
parents: 104
diff changeset
   272
								  startx,
fd3682228853 XML Tagged Paragraph parser changes
rgbecker
parents: 104
diff changeset
   273
								  0,
fd3682228853 XML Tagged Paragraph parser changes
rgbecker
parents: 104
diff changeset
   274
								  self.drawWidth,
fd3682228853 XML Tagged Paragraph parser changes
rgbecker
parents: 104
diff changeset
   275
								  self.drawHeight
fd3682228853 XML Tagged Paragraph parser changes
rgbecker
parents: 104
diff changeset
   276
								  )
122
fd68411f49db Drawable ==> Flowable
rgbecker
parents: 120
diff changeset
   277
class Spacer(Flowable):
117
fd3682228853 XML Tagged Paragraph parser changes
rgbecker
parents: 104
diff changeset
   278
	"""A spacer just takes up space and doesn't draw anything - it can
fd3682228853 XML Tagged Paragraph parser changes
rgbecker
parents: 104
diff changeset
   279
	ensure a gap between objects."""
fd3682228853 XML Tagged Paragraph parser changes
rgbecker
parents: 104
diff changeset
   280
	def __init__(self, width, height):
fd3682228853 XML Tagged Paragraph parser changes
rgbecker
parents: 104
diff changeset
   281
		self.width = width
fd3682228853 XML Tagged Paragraph parser changes
rgbecker
parents: 104
diff changeset
   282
		self.height = height
fd3682228853 XML Tagged Paragraph parser changes
rgbecker
parents: 104
diff changeset
   283
fd3682228853 XML Tagged Paragraph parser changes
rgbecker
parents: 104
diff changeset
   284
	def wrap(self, availWidth, availHeight):
fd3682228853 XML Tagged Paragraph parser changes
rgbecker
parents: 104
diff changeset
   285
		return (self.width, self.height)
fd3682228853 XML Tagged Paragraph parser changes
rgbecker
parents: 104
diff changeset
   286
fd3682228853 XML Tagged Paragraph parser changes
rgbecker
parents: 104
diff changeset
   287
	def draw(self):
fd3682228853 XML Tagged Paragraph parser changes
rgbecker
parents: 104
diff changeset
   288
		pass
fd3682228853 XML Tagged Paragraph parser changes
rgbecker
parents: 104
diff changeset
   289
122
fd68411f49db Drawable ==> Flowable
rgbecker
parents: 120
diff changeset
   290
class PageBreak(Flowable):
117
fd3682228853 XML Tagged Paragraph parser changes
rgbecker
parents: 104
diff changeset
   291
	"""This works by consuming all remaining space in the frame!"""
fd3682228853 XML Tagged Paragraph parser changes
rgbecker
parents: 104
diff changeset
   292
fd3682228853 XML Tagged Paragraph parser changes
rgbecker
parents: 104
diff changeset
   293
	def wrap(self, availWidth, availHeight):
fd3682228853 XML Tagged Paragraph parser changes
rgbecker
parents: 104
diff changeset
   294
		self.width = availWidth
fd3682228853 XML Tagged Paragraph parser changes
rgbecker
parents: 104
diff changeset
   295
		self.height = availHeight
fd3682228853 XML Tagged Paragraph parser changes
rgbecker
parents: 104
diff changeset
   296
		return (availWidth,availHeight)  #step back a point
fd3682228853 XML Tagged Paragraph parser changes
rgbecker
parents: 104
diff changeset
   297
fd3682228853 XML Tagged Paragraph parser changes
rgbecker
parents: 104
diff changeset
   298
	def draw(self):
fd3682228853 XML Tagged Paragraph parser changes
rgbecker
parents: 104
diff changeset
   299
		pass
fd3682228853 XML Tagged Paragraph parser changes
rgbecker
parents: 104
diff changeset
   300
122
fd68411f49db Drawable ==> Flowable
rgbecker
parents: 120
diff changeset
   301
class Macro(Flowable):
117
fd3682228853 XML Tagged Paragraph parser changes
rgbecker
parents: 104
diff changeset
   302
	"""This is not actually drawn (i.e. it has zero height)
fd3682228853 XML Tagged Paragraph parser changes
rgbecker
parents: 104
diff changeset
   303
	but is executed when it would fit in the frame.  Allows direct
fd3682228853 XML Tagged Paragraph parser changes
rgbecker
parents: 104
diff changeset
   304
	access to the canvas through the object 'canvas'"""
fd3682228853 XML Tagged Paragraph parser changes
rgbecker
parents: 104
diff changeset
   305
	def __init__(self, command):
fd3682228853 XML Tagged Paragraph parser changes
rgbecker
parents: 104
diff changeset
   306
		self.command = command
fd3682228853 XML Tagged Paragraph parser changes
rgbecker
parents: 104
diff changeset
   307
	def wrap(self, availWidth, availHeight):
fd3682228853 XML Tagged Paragraph parser changes
rgbecker
parents: 104
diff changeset
   308
		return (0,0)
fd3682228853 XML Tagged Paragraph parser changes
rgbecker
parents: 104
diff changeset
   309
	def draw(self):
fd3682228853 XML Tagged Paragraph parser changes
rgbecker
parents: 104
diff changeset
   310
		exec self.command in globals(), {'canvas':self.canv}
0
f19e0a2433ab Initial revision
gmcm
parents:
diff changeset
   311
164
b5f77d851755 Factored out BasicFrame from SimpleFrame
rgbecker
parents: 133
diff changeset
   312
class BasicFrame:
b5f77d851755 Factored out BasicFrame from SimpleFrame
rgbecker
parents: 133
diff changeset
   313
	'''Abstraction for the definitional part of a Frame
b5f77d851755 Factored out BasicFrame from SimpleFrame
rgbecker
parents: 133
diff changeset
   314
178
0d2557b905da Fix _doNothing argument name
rgbecker
parents: 168
diff changeset
   315
                width                    x2,y2
0d2557b905da Fix _doNothing argument name
rgbecker
parents: 168
diff changeset
   316
    	+---------------------------------+
0d2557b905da Fix _doNothing argument name
rgbecker
parents: 168
diff changeset
   317
    	| l  top padding                r | h
0d2557b905da Fix _doNothing argument name
rgbecker
parents: 168
diff changeset
   318
    	| e +-------------------------+ i | e
0d2557b905da Fix _doNothing argument name
rgbecker
parents: 168
diff changeset
   319
    	| f |                         | g | i
0d2557b905da Fix _doNothing argument name
rgbecker
parents: 168
diff changeset
   320
    	| t |                         | h | g
0d2557b905da Fix _doNothing argument name
rgbecker
parents: 168
diff changeset
   321
    	|   |                         | t | h
0d2557b905da Fix _doNothing argument name
rgbecker
parents: 168
diff changeset
   322
    	| p |                         |   | t
0d2557b905da Fix _doNothing argument name
rgbecker
parents: 168
diff changeset
   323
    	| a |                         | p |
0d2557b905da Fix _doNothing argument name
rgbecker
parents: 168
diff changeset
   324
    	| d |                         | a |
0d2557b905da Fix _doNothing argument name
rgbecker
parents: 168
diff changeset
   325
    	|   |                         | d |
0d2557b905da Fix _doNothing argument name
rgbecker
parents: 168
diff changeset
   326
    	|   +-------------------------+   |
0d2557b905da Fix _doNothing argument name
rgbecker
parents: 168
diff changeset
   327
    	|    bottom padding				  |
0d2557b905da Fix _doNothing argument name
rgbecker
parents: 168
diff changeset
   328
    	+---------------------------------+
0d2557b905da Fix _doNothing argument name
rgbecker
parents: 168
diff changeset
   329
    	(x1,y1)
164
b5f77d851755 Factored out BasicFrame from SimpleFrame
rgbecker
parents: 133
diff changeset
   330
	'''
b5f77d851755 Factored out BasicFrame from SimpleFrame
rgbecker
parents: 133
diff changeset
   331
	def __init__(self, x1, y1, width,height, leftPadding=6, bottomPadding=6,
b5f77d851755 Factored out BasicFrame from SimpleFrame
rgbecker
parents: 133
diff changeset
   332
			rightPadding=6, topPadding=6, id=None, showBoundary=0):
b5f77d851755 Factored out BasicFrame from SimpleFrame
rgbecker
parents: 133
diff changeset
   333
b5f77d851755 Factored out BasicFrame from SimpleFrame
rgbecker
parents: 133
diff changeset
   334
		self.id = id
b5f77d851755 Factored out BasicFrame from SimpleFrame
rgbecker
parents: 133
diff changeset
   335
b5f77d851755 Factored out BasicFrame from SimpleFrame
rgbecker
parents: 133
diff changeset
   336
		#these say where it goes on the page
b5f77d851755 Factored out BasicFrame from SimpleFrame
rgbecker
parents: 133
diff changeset
   337
		self.x1 = x1
b5f77d851755 Factored out BasicFrame from SimpleFrame
rgbecker
parents: 133
diff changeset
   338
		self.y1 = y1
b5f77d851755 Factored out BasicFrame from SimpleFrame
rgbecker
parents: 133
diff changeset
   339
		self.x2 = x1 + width
b5f77d851755 Factored out BasicFrame from SimpleFrame
rgbecker
parents: 133
diff changeset
   340
		self.y2 = y1 + height
b5f77d851755 Factored out BasicFrame from SimpleFrame
rgbecker
parents: 133
diff changeset
   341
b5f77d851755 Factored out BasicFrame from SimpleFrame
rgbecker
parents: 133
diff changeset
   342
		#these create some padding.
b5f77d851755 Factored out BasicFrame from SimpleFrame
rgbecker
parents: 133
diff changeset
   343
		self.leftPadding = leftPadding
b5f77d851755 Factored out BasicFrame from SimpleFrame
rgbecker
parents: 133
diff changeset
   344
		self.bottomPadding = bottomPadding
b5f77d851755 Factored out BasicFrame from SimpleFrame
rgbecker
parents: 133
diff changeset
   345
		self.rightPadding = rightPadding
b5f77d851755 Factored out BasicFrame from SimpleFrame
rgbecker
parents: 133
diff changeset
   346
		self.topPadding = topPadding
0
f19e0a2433ab Initial revision
gmcm
parents:
diff changeset
   347
191
c4907a8ee681 Removed usage of spaceBefore/After in wrap methods
rgbecker
parents: 185
diff changeset
   348
		#efficiency
c4907a8ee681 Removed usage of spaceBefore/After in wrap methods
rgbecker
parents: 185
diff changeset
   349
		self.y1p = self.y1 + bottomPadding
c4907a8ee681 Removed usage of spaceBefore/After in wrap methods
rgbecker
parents: 185
diff changeset
   350
164
b5f77d851755 Factored out BasicFrame from SimpleFrame
rgbecker
parents: 133
diff changeset
   351
		# if we want a boundary to be shown
b5f77d851755 Factored out BasicFrame from SimpleFrame
rgbecker
parents: 133
diff changeset
   352
		self.showBoundary = showBoundary
b5f77d851755 Factored out BasicFrame from SimpleFrame
rgbecker
parents: 133
diff changeset
   353
b5f77d851755 Factored out BasicFrame from SimpleFrame
rgbecker
parents: 133
diff changeset
   354
		self._reset()
b5f77d851755 Factored out BasicFrame from SimpleFrame
rgbecker
parents: 133
diff changeset
   355
b5f77d851755 Factored out BasicFrame from SimpleFrame
rgbecker
parents: 133
diff changeset
   356
	def	_reset(self):
b5f77d851755 Factored out BasicFrame from SimpleFrame
rgbecker
parents: 133
diff changeset
   357
		#work out the available space
b5f77d851755 Factored out BasicFrame from SimpleFrame
rgbecker
parents: 133
diff changeset
   358
		self.width = self.x2 - self.x1 - self.leftPadding - self.rightPadding
b5f77d851755 Factored out BasicFrame from SimpleFrame
rgbecker
parents: 133
diff changeset
   359
		self.height = self.y2 - self.y1 - self.topPadding - self.bottomPadding
b5f77d851755 Factored out BasicFrame from SimpleFrame
rgbecker
parents: 133
diff changeset
   360
		#drawing starts at top left
b5f77d851755 Factored out BasicFrame from SimpleFrame
rgbecker
parents: 133
diff changeset
   361
		self.x = self.x1 + self.leftPadding
b5f77d851755 Factored out BasicFrame from SimpleFrame
rgbecker
parents: 133
diff changeset
   362
		self.y = self.y2 - self.topPadding
185
b68f142d9302 Added softspace handling
rgbecker
parents: 184
diff changeset
   363
		self.atTop = 1
164
b5f77d851755 Factored out BasicFrame from SimpleFrame
rgbecker
parents: 133
diff changeset
   364
b5f77d851755 Factored out BasicFrame from SimpleFrame
rgbecker
parents: 133
diff changeset
   365
	def _add(self, flowable, canv, trySplit=0):
b5f77d851755 Factored out BasicFrame from SimpleFrame
rgbecker
parents: 133
diff changeset
   366
		""" Draws the flowable at the current position.
b5f77d851755 Factored out BasicFrame from SimpleFrame
rgbecker
parents: 133
diff changeset
   367
		Returns 1 if successful, 0 if it would not fit.
b5f77d851755 Factored out BasicFrame from SimpleFrame
rgbecker
parents: 133
diff changeset
   368
		Raises a LayoutError if the object is too wide,
b5f77d851755 Factored out BasicFrame from SimpleFrame
rgbecker
parents: 133
diff changeset
   369
		or if it is too high for a totally empty frame,
b5f77d851755 Factored out BasicFrame from SimpleFrame
rgbecker
parents: 133
diff changeset
   370
		to avoid infinite loops"""
b5f77d851755 Factored out BasicFrame from SimpleFrame
rgbecker
parents: 133
diff changeset
   371
		y = self.y
191
c4907a8ee681 Removed usage of spaceBefore/After in wrap methods
rgbecker
parents: 185
diff changeset
   372
		p = self.y1p
c4907a8ee681 Removed usage of spaceBefore/After in wrap methods
rgbecker
parents: 185
diff changeset
   373
		s = self.atTop and 0 or flowable.getSpaceBefore()
212
b04e22acb4fa Splitting changes
rgbecker
parents: 196
diff changeset
   374
		h = y - p - s
b04e22acb4fa Splitting changes
rgbecker
parents: 196
diff changeset
   375
		if h>0:
b04e22acb4fa Splitting changes
rgbecker
parents: 196
diff changeset
   376
			w, h = flowable.wrap(self.width, h)
b04e22acb4fa Splitting changes
rgbecker
parents: 196
diff changeset
   377
		else:
b04e22acb4fa Splitting changes
rgbecker
parents: 196
diff changeset
   378
			return 0
b04e22acb4fa Splitting changes
rgbecker
parents: 196
diff changeset
   379
191
c4907a8ee681 Removed usage of spaceBefore/After in wrap methods
rgbecker
parents: 185
diff changeset
   380
		h = h + s
212
b04e22acb4fa Splitting changes
rgbecker
parents: 196
diff changeset
   381
		y = y - h
164
b5f77d851755 Factored out BasicFrame from SimpleFrame
rgbecker
parents: 133
diff changeset
   382
b5f77d851755 Factored out BasicFrame from SimpleFrame
rgbecker
parents: 133
diff changeset
   383
		if y < p:
b5f77d851755 Factored out BasicFrame from SimpleFrame
rgbecker
parents: 133
diff changeset
   384
			if ((h > self.height and not trySplit) or w > self.width):
b5f77d851755 Factored out BasicFrame from SimpleFrame
rgbecker
parents: 133
diff changeset
   385
				raise "LayoutError", "Flowable (%dx%d points) too large for frame (%dx%d points)." % (w,h, self.width,self.height)
b5f77d851755 Factored out BasicFrame from SimpleFrame
rgbecker
parents: 133
diff changeset
   386
			return 0
b5f77d851755 Factored out BasicFrame from SimpleFrame
rgbecker
parents: 133
diff changeset
   387
		else:
b5f77d851755 Factored out BasicFrame from SimpleFrame
rgbecker
parents: 133
diff changeset
   388
			#now we can draw it, and update the current point.
b5f77d851755 Factored out BasicFrame from SimpleFrame
rgbecker
parents: 133
diff changeset
   389
			flowable.drawOn(canv, self.x, y)
191
c4907a8ee681 Removed usage of spaceBefore/After in wrap methods
rgbecker
parents: 185
diff changeset
   390
			y = y - flowable.getSpaceAfter()
185
b68f142d9302 Added softspace handling
rgbecker
parents: 184
diff changeset
   391
			self.atTop = 0
164
b5f77d851755 Factored out BasicFrame from SimpleFrame
rgbecker
parents: 133
diff changeset
   392
			self.y = y
b5f77d851755 Factored out BasicFrame from SimpleFrame
rgbecker
parents: 133
diff changeset
   393
			return 1
b5f77d851755 Factored out BasicFrame from SimpleFrame
rgbecker
parents: 133
diff changeset
   394
b5f77d851755 Factored out BasicFrame from SimpleFrame
rgbecker
parents: 133
diff changeset
   395
	add = _add
0
f19e0a2433ab Initial revision
gmcm
parents:
diff changeset
   396
191
c4907a8ee681 Removed usage of spaceBefore/After in wrap methods
rgbecker
parents: 185
diff changeset
   397
	def split(self,flowable):
c4907a8ee681 Removed usage of spaceBefore/After in wrap methods
rgbecker
parents: 185
diff changeset
   398
		'''calls split on the flowable'''
c4907a8ee681 Removed usage of spaceBefore/After in wrap methods
rgbecker
parents: 185
diff changeset
   399
		y = self.y
c4907a8ee681 Removed usage of spaceBefore/After in wrap methods
rgbecker
parents: 185
diff changeset
   400
		p = self.y1p
c4907a8ee681 Removed usage of spaceBefore/After in wrap methods
rgbecker
parents: 185
diff changeset
   401
		s = self.atTop and 0 or flowable.getSpaceBefore()
196
b2545a941a37 Fixes to BasicFrame split method
rgbecker
parents: 191
diff changeset
   402
		return flowable.split(self.width, y-p-s)
191
c4907a8ee681 Removed usage of spaceBefore/After in wrap methods
rgbecker
parents: 185
diff changeset
   403
178
0d2557b905da Fix _doNothing argument name
rgbecker
parents: 168
diff changeset
   404
0
f19e0a2433ab Initial revision
gmcm
parents:
diff changeset
   405
#############################################################
178
0d2557b905da Fix _doNothing argument name
rgbecker
parents: 168
diff changeset
   406
#	A Frame, and a Document Model
0
f19e0a2433ab Initial revision
gmcm
parents:
diff changeset
   407
#############################################################
f19e0a2433ab Initial revision
gmcm
parents:
diff changeset
   408
FrameFullError = "FrameFullError"
f19e0a2433ab Initial revision
gmcm
parents:
diff changeset
   409
LayoutError = "LayoutError"
f19e0a2433ab Initial revision
gmcm
parents:
diff changeset
   410
164
b5f77d851755 Factored out BasicFrame from SimpleFrame
rgbecker
parents: 133
diff changeset
   411
class SimpleFrame(BasicFrame):
122
fd68411f49db Drawable ==> Flowable
rgbecker
parents: 120
diff changeset
   412
	"""A region into which flowable objects are to be packed.
117
fd3682228853 XML Tagged Paragraph parser changes
rgbecker
parents: 104
diff changeset
   413
	Flows downwards.  A more general solution is needed which
fd3682228853 XML Tagged Paragraph parser changes
rgbecker
parents: 104
diff changeset
   414
	will allow flows in any direction, including 'across and then
fd3682228853 XML Tagged Paragraph parser changes
rgbecker
parents: 104
diff changeset
   415
	down' for small objects, but this is useful for
fd3682228853 XML Tagged Paragraph parser changes
rgbecker
parents: 104
diff changeset
   416
	many languages now, as long as each object is 'full-width'
fd3682228853 XML Tagged Paragraph parser changes
rgbecker
parents: 104
diff changeset
   417
	(i.e. a paragraph and not a word)."""
fd3682228853 XML Tagged Paragraph parser changes
rgbecker
parents: 104
diff changeset
   418
	def __init__(self, canvas, x1, y1, width,height):
164
b5f77d851755 Factored out BasicFrame from SimpleFrame
rgbecker
parents: 133
diff changeset
   419
		BasicFrame.__init__(self, x1, y1, width,height, leftPadding=6, bottomPadding=6,
b5f77d851755 Factored out BasicFrame from SimpleFrame
rgbecker
parents: 133
diff changeset
   420
			rightPadding=6, topPadding=6, id=None, showBoundary=0)
117
fd3682228853 XML Tagged Paragraph parser changes
rgbecker
parents: 104
diff changeset
   421
		self.canvas = canvas
fd3682228853 XML Tagged Paragraph parser changes
rgbecker
parents: 104
diff changeset
   422
		self.objects = []	#it keeps a list of objects
0
f19e0a2433ab Initial revision
gmcm
parents:
diff changeset
   423
122
fd68411f49db Drawable ==> Flowable
rgbecker
parents: 120
diff changeset
   424
	def add(self, flowable):
164
b5f77d851755 Factored out BasicFrame from SimpleFrame
rgbecker
parents: 133
diff changeset
   425
		r = self._add(flowable, self.canvas)
b5f77d851755 Factored out BasicFrame from SimpleFrame
rgbecker
parents: 133
diff changeset
   426
		if r: self.objects.append(flowable)
b5f77d851755 Factored out BasicFrame from SimpleFrame
rgbecker
parents: 133
diff changeset
   427
		return r
0
f19e0a2433ab Initial revision
gmcm
parents:
diff changeset
   428
117
fd3682228853 XML Tagged Paragraph parser changes
rgbecker
parents: 104
diff changeset
   429
	def addFromList(self, drawlist):
fd3682228853 XML Tagged Paragraph parser changes
rgbecker
parents: 104
diff changeset
   430
		"""Consumes objects from the front of the list until the
fd3682228853 XML Tagged Paragraph parser changes
rgbecker
parents: 104
diff changeset
   431
		frame is full.	If it cannot fit one object, raises
fd3682228853 XML Tagged Paragraph parser changes
rgbecker
parents: 104
diff changeset
   432
		an exception."""
0
f19e0a2433ab Initial revision
gmcm
parents:
diff changeset
   433
117
fd3682228853 XML Tagged Paragraph parser changes
rgbecker
parents: 104
diff changeset
   434
		if self.showBoundary:
fd3682228853 XML Tagged Paragraph parser changes
rgbecker
parents: 104
diff changeset
   435
			self.canvas.rect(
128
a0676f013314 Splitting layout.py
rgbecker
parents: 122
diff changeset
   436
						self.x1,
a0676f013314 Splitting layout.py
rgbecker
parents: 122
diff changeset
   437
						self.y1,
a0676f013314 Splitting layout.py
rgbecker
parents: 122
diff changeset
   438
						self.x2 - self.x1,
a0676f013314 Splitting layout.py
rgbecker
parents: 122
diff changeset
   439
						self.y2 - self.y1
117
fd3682228853 XML Tagged Paragraph parser changes
rgbecker
parents: 104
diff changeset
   440
						)
22
dcfc888b1062 GMCM's memleak fixed
rgbecker
parents: 16
diff changeset
   441
117
fd3682228853 XML Tagged Paragraph parser changes
rgbecker
parents: 104
diff changeset
   442
		while len(drawlist) > 0:
fd3682228853 XML Tagged Paragraph parser changes
rgbecker
parents: 104
diff changeset
   443
			head = drawlist[0]
fd3682228853 XML Tagged Paragraph parser changes
rgbecker
parents: 104
diff changeset
   444
			if self.add(head):
fd3682228853 XML Tagged Paragraph parser changes
rgbecker
parents: 104
diff changeset
   445
				del drawlist[0]
fd3682228853 XML Tagged Paragraph parser changes
rgbecker
parents: 104
diff changeset
   446
			else:
fd3682228853 XML Tagged Paragraph parser changes
rgbecker
parents: 104
diff changeset
   447
				#leave it in the list for later
fd3682228853 XML Tagged Paragraph parser changes
rgbecker
parents: 104
diff changeset
   448
				break
128
a0676f013314 Splitting layout.py
rgbecker
parents: 122
diff changeset
   449
0
f19e0a2433ab Initial revision
gmcm
parents:
diff changeset
   450
class Sequencer:
117
fd3682228853 XML Tagged Paragraph parser changes
rgbecker
parents: 104
diff changeset
   451
	"""Something to make it easy to number paragraphs, sections,
fd3682228853 XML Tagged Paragraph parser changes
rgbecker
parents: 104
diff changeset
   452
	images and anything else. Usage:
fd3682228853 XML Tagged Paragraph parser changes
rgbecker
parents: 104
diff changeset
   453
		>>> seq = layout.Sequencer()
fd3682228853 XML Tagged Paragraph parser changes
rgbecker
parents: 104
diff changeset
   454
		>>> seq.next('Bullets')
fd3682228853 XML Tagged Paragraph parser changes
rgbecker
parents: 104
diff changeset
   455
		1
fd3682228853 XML Tagged Paragraph parser changes
rgbecker
parents: 104
diff changeset
   456
		>>> seq.next('Bullets')
fd3682228853 XML Tagged Paragraph parser changes
rgbecker
parents: 104
diff changeset
   457
		2
fd3682228853 XML Tagged Paragraph parser changes
rgbecker
parents: 104
diff changeset
   458
		>>> seq.next('Bullets')
fd3682228853 XML Tagged Paragraph parser changes
rgbecker
parents: 104
diff changeset
   459
		3
fd3682228853 XML Tagged Paragraph parser changes
rgbecker
parents: 104
diff changeset
   460
		>>> seq.reset('Bullets')
fd3682228853 XML Tagged Paragraph parser changes
rgbecker
parents: 104
diff changeset
   461
		>>> seq.next('Bullets')
fd3682228853 XML Tagged Paragraph parser changes
rgbecker
parents: 104
diff changeset
   462
		1
fd3682228853 XML Tagged Paragraph parser changes
rgbecker
parents: 104
diff changeset
   463
		>>> seq.next('Figures')
fd3682228853 XML Tagged Paragraph parser changes
rgbecker
parents: 104
diff changeset
   464
		1
fd3682228853 XML Tagged Paragraph parser changes
rgbecker
parents: 104
diff changeset
   465
		>>>
fd3682228853 XML Tagged Paragraph parser changes
rgbecker
parents: 104
diff changeset
   466
	I plan to add multi-level linkages, so that Head2 could be reet
fd3682228853 XML Tagged Paragraph parser changes
rgbecker
parents: 104
diff changeset
   467
	"""
fd3682228853 XML Tagged Paragraph parser changes
rgbecker
parents: 104
diff changeset
   468
	def __init__(self):
fd3682228853 XML Tagged Paragraph parser changes
rgbecker
parents: 104
diff changeset
   469
		self.dict = {}
22
dcfc888b1062 GMCM's memleak fixed
rgbecker
parents: 16
diff changeset
   470
117
fd3682228853 XML Tagged Paragraph parser changes
rgbecker
parents: 104
diff changeset
   471
	def next(self, category):
fd3682228853 XML Tagged Paragraph parser changes
rgbecker
parents: 104
diff changeset
   472
		if self.dict.has_key(category):
fd3682228853 XML Tagged Paragraph parser changes
rgbecker
parents: 104
diff changeset
   473
			self.dict[category] = self.dict[category] + 1
fd3682228853 XML Tagged Paragraph parser changes
rgbecker
parents: 104
diff changeset
   474
		else:
fd3682228853 XML Tagged Paragraph parser changes
rgbecker
parents: 104
diff changeset
   475
			self.dict[category] = 1
fd3682228853 XML Tagged Paragraph parser changes
rgbecker
parents: 104
diff changeset
   476
		return self.dict[category]
22
dcfc888b1062 GMCM's memleak fixed
rgbecker
parents: 16
diff changeset
   477
117
fd3682228853 XML Tagged Paragraph parser changes
rgbecker
parents: 104
diff changeset
   478
	def reset(self, category):
fd3682228853 XML Tagged Paragraph parser changes
rgbecker
parents: 104
diff changeset
   479
		self.dict[category] = 0
0
f19e0a2433ab Initial revision
gmcm
parents:
diff changeset
   480
178
0d2557b905da Fix _doNothing argument name
rgbecker
parents: 168
diff changeset
   481
def _doNothing(canvas, doc):
0d2557b905da Fix _doNothing argument name
rgbecker
parents: 168
diff changeset
   482
	"Dummy callback for onPage"
117
fd3682228853 XML Tagged Paragraph parser changes
rgbecker
parents: 104
diff changeset
   483
	pass
0
f19e0a2433ab Initial revision
gmcm
parents:
diff changeset
   484
22
dcfc888b1062 GMCM's memleak fixed
rgbecker
parents: 16
diff changeset
   485
##########################################################
dcfc888b1062 GMCM's memleak fixed
rgbecker
parents: 16
diff changeset
   486
#
dcfc888b1062 GMCM's memleak fixed
rgbecker
parents: 16
diff changeset
   487
#
dcfc888b1062 GMCM's memleak fixed
rgbecker
parents: 16
diff changeset
   488
#
dcfc888b1062 GMCM's memleak fixed
rgbecker
parents: 16
diff changeset
   489
##########################################################
0
f19e0a2433ab Initial revision
gmcm
parents:
diff changeset
   490
class SimpleFlowDocument:
117
fd3682228853 XML Tagged Paragraph parser changes
rgbecker
parents: 104
diff changeset
   491
	"""A sample document that uses a single frame on each page.
fd3682228853 XML Tagged Paragraph parser changes
rgbecker
parents: 104
diff changeset
   492
	The intention is for programmers to create their own document
122
fd68411f49db Drawable ==> Flowable
rgbecker
parents: 120
diff changeset
   493
	models as needed.  This one accepts a list of flowables. You
117
fd3682228853 XML Tagged Paragraph parser changes
rgbecker
parents: 104
diff changeset
   494
	can provide callbacks to decorate the first page and
fd3682228853 XML Tagged Paragraph parser changes
rgbecker
parents: 104
diff changeset
   495
	subsequent pages; these should do headers, footers, sidebars
fd3682228853 XML Tagged Paragraph parser changes
rgbecker
parents: 104
diff changeset
   496
	as needed."""
fd3682228853 XML Tagged Paragraph parser changes
rgbecker
parents: 104
diff changeset
   497
	def __init__(self, filename, pagesize, showBoundary=0):
fd3682228853 XML Tagged Paragraph parser changes
rgbecker
parents: 104
diff changeset
   498
		self.filename = filename
fd3682228853 XML Tagged Paragraph parser changes
rgbecker
parents: 104
diff changeset
   499
		self.pagesize = pagesize
fd3682228853 XML Tagged Paragraph parser changes
rgbecker
parents: 104
diff changeset
   500
		self.showBoundary=showBoundary
fd3682228853 XML Tagged Paragraph parser changes
rgbecker
parents: 104
diff changeset
   501
		#sensibel defaults; override if you wish
fd3682228853 XML Tagged Paragraph parser changes
rgbecker
parents: 104
diff changeset
   502
		self.leftMargin =  inch
fd3682228853 XML Tagged Paragraph parser changes
rgbecker
parents: 104
diff changeset
   503
		self.bottomMargin = inch
fd3682228853 XML Tagged Paragraph parser changes
rgbecker
parents: 104
diff changeset
   504
		self.rightMargin = self.pagesize[0] - inch
fd3682228853 XML Tagged Paragraph parser changes
rgbecker
parents: 104
diff changeset
   505
		self.topMargin = self.pagesize[1] - inch
0
f19e0a2433ab Initial revision
gmcm
parents:
diff changeset
   506
117
fd3682228853 XML Tagged Paragraph parser changes
rgbecker
parents: 104
diff changeset
   507
		# 1-based counting is friendlier for readers
fd3682228853 XML Tagged Paragraph parser changes
rgbecker
parents: 104
diff changeset
   508
		self.page = 1
fd3682228853 XML Tagged Paragraph parser changes
rgbecker
parents: 104
diff changeset
   509
		#set these to drawing procedures of your own
fd3682228853 XML Tagged Paragraph parser changes
rgbecker
parents: 104
diff changeset
   510
		self.onFirstPage = _doNothing
fd3682228853 XML Tagged Paragraph parser changes
rgbecker
parents: 104
diff changeset
   511
		self.onNewPage = _doNothing
22
dcfc888b1062 GMCM's memleak fixed
rgbecker
parents: 16
diff changeset
   512
dcfc888b1062 GMCM's memleak fixed
rgbecker
parents: 16
diff changeset
   513
122
fd68411f49db Drawable ==> Flowable
rgbecker
parents: 120
diff changeset
   514
	def build(self, flowables):
117
fd3682228853 XML Tagged Paragraph parser changes
rgbecker
parents: 104
diff changeset
   515
		canv = canvas.Canvas(self.filename)
fd3682228853 XML Tagged Paragraph parser changes
rgbecker
parents: 104
diff changeset
   516
		#canv.setPageTransition('Dissolve')
0
f19e0a2433ab Initial revision
gmcm
parents:
diff changeset
   517
117
fd3682228853 XML Tagged Paragraph parser changes
rgbecker
parents: 104
diff changeset
   518
		# do page 1
fd3682228853 XML Tagged Paragraph parser changes
rgbecker
parents: 104
diff changeset
   519
		self.onFirstPage(canv, self)
fd3682228853 XML Tagged Paragraph parser changes
rgbecker
parents: 104
diff changeset
   520
		frame1 = SimpleFrame(
fd3682228853 XML Tagged Paragraph parser changes
rgbecker
parents: 104
diff changeset
   521
					canv,
fd3682228853 XML Tagged Paragraph parser changes
rgbecker
parents: 104
diff changeset
   522
					self.leftMargin,
fd3682228853 XML Tagged Paragraph parser changes
rgbecker
parents: 104
diff changeset
   523
					self.bottomMargin,
fd3682228853 XML Tagged Paragraph parser changes
rgbecker
parents: 104
diff changeset
   524
					self.rightMargin - self.leftMargin,
fd3682228853 XML Tagged Paragraph parser changes
rgbecker
parents: 104
diff changeset
   525
					self.topMargin - inch - self.bottomMargin
fd3682228853 XML Tagged Paragraph parser changes
rgbecker
parents: 104
diff changeset
   526
							)
fd3682228853 XML Tagged Paragraph parser changes
rgbecker
parents: 104
diff changeset
   527
		frame1.showBoundary = self.showBoundary
122
fd68411f49db Drawable ==> Flowable
rgbecker
parents: 120
diff changeset
   528
		frame1.addFromList(flowables)
fd68411f49db Drawable ==> Flowable
rgbecker
parents: 120
diff changeset
   529
		#print 'drew page %d, %d objects remaining' % (self.page, len(flowables))
117
fd3682228853 XML Tagged Paragraph parser changes
rgbecker
parents: 104
diff changeset
   530
		# do subsequent pages
122
fd68411f49db Drawable ==> Flowable
rgbecker
parents: 120
diff changeset
   531
		while len(flowables) > 0:
117
fd3682228853 XML Tagged Paragraph parser changes
rgbecker
parents: 104
diff changeset
   532
			canv.showPage()
fd3682228853 XML Tagged Paragraph parser changes
rgbecker
parents: 104
diff changeset
   533
			self.page = self.page + 1
fd3682228853 XML Tagged Paragraph parser changes
rgbecker
parents: 104
diff changeset
   534
			self.onNewPage(canv, self)
fd3682228853 XML Tagged Paragraph parser changes
rgbecker
parents: 104
diff changeset
   535
			frame = SimpleFrame(
fd3682228853 XML Tagged Paragraph parser changes
rgbecker
parents: 104
diff changeset
   536
					canv,
fd3682228853 XML Tagged Paragraph parser changes
rgbecker
parents: 104
diff changeset
   537
					self.leftMargin,
fd3682228853 XML Tagged Paragraph parser changes
rgbecker
parents: 104
diff changeset
   538
					self.bottomMargin,
fd3682228853 XML Tagged Paragraph parser changes
rgbecker
parents: 104
diff changeset
   539
					self.rightMargin - self.leftMargin,
fd3682228853 XML Tagged Paragraph parser changes
rgbecker
parents: 104
diff changeset
   540
					self.topMargin - self.bottomMargin
fd3682228853 XML Tagged Paragraph parser changes
rgbecker
parents: 104
diff changeset
   541
							)
fd3682228853 XML Tagged Paragraph parser changes
rgbecker
parents: 104
diff changeset
   542
			frame.showBoundary = self.showBoundary
122
fd68411f49db Drawable ==> Flowable
rgbecker
parents: 120
diff changeset
   543
			frame.addFromList(flowables)
22
dcfc888b1062 GMCM's memleak fixed
rgbecker
parents: 16
diff changeset
   544
122
fd68411f49db Drawable ==> Flowable
rgbecker
parents: 120
diff changeset
   545
			#print 'drew page %d, %d objects remaining' % (self.page, len(flowables))
22
dcfc888b1062 GMCM's memleak fixed
rgbecker
parents: 16
diff changeset
   546
117
fd3682228853 XML Tagged Paragraph parser changes
rgbecker
parents: 104
diff changeset
   547
		canv.save()