author | rgbecker |
Tue, 03 Mar 2009 17:38:41 +0000 | |
changeset 3131 | 0f15fabe9d8d |
parent 3032 | 22224b1b4d24 |
child 3536 | 770d419eef48 |
permissions | -rw-r--r-- |
2332 | 1 |
#Copyright ReportLab Europe Ltd. 2000-2004 |
494 | 2 |
#see license.txt for license details |
2332 | 3 |
#history http://www.reportlab.co.uk/cgi-bin/viewcvs.cgi/public/reportlab/trunk/reportlab/platypus/frames.py |
565 | 4 |
|
2332 | 5 |
__version__=''' $Id$ ''' |
565 | 6 |
|
3032 | 7 |
__doc__="""A frame is a container for content on a page. |
253 | 8 |
""" |
565 | 9 |
|
2500 | 10 |
import logging |
11 |
logger = logging.getLogger('reportlab.platypus') |
|
12 |
||
565 | 13 |
_geomAttr=('x1', 'y1', 'width', 'height', 'leftPadding', 'bottomPadding', 'rightPadding', 'topPadding') |
1231
05dc2104f72d
disable LayoutError error for production use (option to enable for debug)
aaron_watters
parents:
1035
diff
changeset
|
14 |
from reportlab import rl_config |
2379 | 15 |
_FUZZ=rl_config._FUZZ |
1231
05dc2104f72d
disable LayoutError error for production use (option to enable for debug)
aaron_watters
parents:
1035
diff
changeset
|
16 |
|
2735
70cf084e5811
reportlab: fix justification space counting bug and improve tests
rgbecker
parents:
2593
diff
changeset
|
17 |
class ShowBoundaryValue: |
70cf084e5811
reportlab: fix justification space counting bug and improve tests
rgbecker
parents:
2593
diff
changeset
|
18 |
def __init__(self,color=(0,0,0),width=0.1): |
70cf084e5811
reportlab: fix justification space counting bug and improve tests
rgbecker
parents:
2593
diff
changeset
|
19 |
self.color = color |
70cf084e5811
reportlab: fix justification space counting bug and improve tests
rgbecker
parents:
2593
diff
changeset
|
20 |
self.width = width |
70cf084e5811
reportlab: fix justification space counting bug and improve tests
rgbecker
parents:
2593
diff
changeset
|
21 |
|
70cf084e5811
reportlab: fix justification space counting bug and improve tests
rgbecker
parents:
2593
diff
changeset
|
22 |
def __nonzero__(self): |
70cf084e5811
reportlab: fix justification space counting bug and improve tests
rgbecker
parents:
2593
diff
changeset
|
23 |
return self.color is not None and self.width>=0 |
70cf084e5811
reportlab: fix justification space counting bug and improve tests
rgbecker
parents:
2593
diff
changeset
|
24 |
|
253 | 25 |
class Frame: |
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1652
diff
changeset
|
26 |
''' |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1652
diff
changeset
|
27 |
A Frame is a piece of space in a document that is filled by the |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1652
diff
changeset
|
28 |
"flowables" in the story. For example in a book like document most |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1652
diff
changeset
|
29 |
pages have the text paragraphs in one or two frames. For generality |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1652
diff
changeset
|
30 |
a page might have several frames (for example for 3 column text or |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1652
diff
changeset
|
31 |
for text that wraps around a graphic). |
1683 | 32 |
|
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1652
diff
changeset
|
33 |
After creation a Frame is not usually manipulated directly by the |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1652
diff
changeset
|
34 |
applications program -- it is used internally by the platypus modules. |
1683 | 35 |
|
3031 | 36 |
Here is a diagramatid abstraction for the definitional part of a Frame:: |
253 | 37 |
|
38 |
width x2,y2 |
|
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1652
diff
changeset
|
39 |
+---------------------------------+ |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1652
diff
changeset
|
40 |
| l top padding r | h |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1652
diff
changeset
|
41 |
| e +-------------------------+ i | e |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1652
diff
changeset
|
42 |
| f | | g | i |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1652
diff
changeset
|
43 |
| t | | h | g |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1652
diff
changeset
|
44 |
| | | t | h |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1652
diff
changeset
|
45 |
| p | | | t |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1652
diff
changeset
|
46 |
| a | | p | |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1652
diff
changeset
|
47 |
| d | | a | |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1652
diff
changeset
|
48 |
| | | d | |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1652
diff
changeset
|
49 |
| +-------------------------+ | |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1652
diff
changeset
|
50 |
| bottom padding | |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1652
diff
changeset
|
51 |
+---------------------------------+ |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1652
diff
changeset
|
52 |
(x1,y1) <-- lower left corner |
1683 | 53 |
|
3031 | 54 |
NOTE!! Frames are stateful objects. No single frame should be used in |
55 |
two documents at the same time (especially in the presence of multithreading. |
|
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1652
diff
changeset
|
56 |
''' |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1652
diff
changeset
|
57 |
def __init__(self, x1, y1, width,height, leftPadding=6, bottomPadding=6, |
2213 | 58 |
rightPadding=6, topPadding=6, id=None, showBoundary=0, |
2531 | 59 |
overlapAttachedSpace=None,_debug=None): |
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1652
diff
changeset
|
60 |
self.id = id |
2531 | 61 |
self._debug = _debug |
253 | 62 |
|
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1652
diff
changeset
|
63 |
#these say where it goes on the page |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1652
diff
changeset
|
64 |
self.__dict__['_x1'] = x1 |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1652
diff
changeset
|
65 |
self.__dict__['_y1'] = y1 |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1652
diff
changeset
|
66 |
self.__dict__['_width'] = width |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1652
diff
changeset
|
67 |
self.__dict__['_height'] = height |
253 | 68 |
|
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1652
diff
changeset
|
69 |
#these create some padding. |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1652
diff
changeset
|
70 |
self.__dict__['_leftPadding'] = leftPadding |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1652
diff
changeset
|
71 |
self.__dict__['_bottomPadding'] = bottomPadding |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1652
diff
changeset
|
72 |
self.__dict__['_rightPadding'] = rightPadding |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1652
diff
changeset
|
73 |
self.__dict__['_topPadding'] = topPadding |
253 | 74 |
|
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1652
diff
changeset
|
75 |
# if we want a boundary to be shown |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1652
diff
changeset
|
76 |
self.showBoundary = showBoundary |
253 | 77 |
|
2213 | 78 |
if overlapAttachedSpace is None: overlapAttachedSpace = rl_config.overlapAttachedSpace |
79 |
self._oASpace = overlapAttachedSpace |
|
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1652
diff
changeset
|
80 |
self._geom() |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1652
diff
changeset
|
81 |
self._reset() |
253 | 82 |
|
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1652
diff
changeset
|
83 |
def __getattr__(self,a): |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1652
diff
changeset
|
84 |
if a in _geomAttr: return self.__dict__['_'+a] |
2915 | 85 |
raise AttributeError(a) |
410 | 86 |
|
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1652
diff
changeset
|
87 |
def __setattr__(self,a,v): |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1652
diff
changeset
|
88 |
if a in _geomAttr: |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1652
diff
changeset
|
89 |
self.__dict__['_'+a] = v |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1652
diff
changeset
|
90 |
self._geom() |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1652
diff
changeset
|
91 |
else: |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1652
diff
changeset
|
92 |
self.__dict__[a] = v |
410 | 93 |
|
2950 | 94 |
def _saveGeom(self, **kwds): |
95 |
if not self.__dict__.setdefault('_savedGeom',{}): |
|
96 |
for ga in _geomAttr: |
|
97 |
ga = '_'+ga |
|
98 |
self.__dict__['_savedGeom'][ga] = self.__dict__[ga] |
|
99 |
for k,v in kwds.iteritems(): |
|
100 |
setattr(self,k,v) |
|
101 |
||
102 |
def _restoreGeom(self): |
|
103 |
if self.__dict__.get('_savedGeom',None): |
|
104 |
for ga in _geomAttr: |
|
105 |
ga = '_'+ga |
|
106 |
self.__dict__[ga] = self.__dict__[ga]['_savedGeom'] |
|
107 |
del self.__dict__['_savedGeom'] |
|
108 |
self._geom() |
|
109 |
||
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1652
diff
changeset
|
110 |
def _geom(self): |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1652
diff
changeset
|
111 |
self._x2 = self._x1 + self._width |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1652
diff
changeset
|
112 |
self._y2 = self._y1 + self._height |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1652
diff
changeset
|
113 |
#efficiency |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1652
diff
changeset
|
114 |
self._y1p = self._y1 + self._bottomPadding |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1652
diff
changeset
|
115 |
#work out the available space |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1652
diff
changeset
|
116 |
self._aW = self._x2 - self._x1 - self._leftPadding - self._rightPadding |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1652
diff
changeset
|
117 |
self._aH = self._y2 - self._y1p - self._topPadding |
410 | 118 |
|
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1652
diff
changeset
|
119 |
def _reset(self): |
2950 | 120 |
self._restoreGeom() |
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1652
diff
changeset
|
121 |
#drawing starts at top left |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1652
diff
changeset
|
122 |
self._x = self._x1 + self._leftPadding |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1652
diff
changeset
|
123 |
self._y = self._y2 - self._topPadding |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1652
diff
changeset
|
124 |
self._atTop = 1 |
2213 | 125 |
self._prevASpace = 0 |
253 | 126 |
|
2525 | 127 |
# these two should NOT be set on a frame. |
128 |
# they are used when Indenter flowables want |
|
129 |
# to adjust edges e.g. to do nested lists |
|
130 |
self._leftExtraIndent = 0.0 |
|
131 |
self._rightExtraIndent = 0.0 |
|
132 |
||
1923 | 133 |
def _getAvailableWidth(self): |
134 |
return self._aW - self._leftExtraIndent - self._rightExtraIndent |
|
2200
be0cfccc662a
Fixed up tabs and whitespace in all source files
andy_robinson
parents:
2013
diff
changeset
|
135 |
|
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1652
diff
changeset
|
136 |
def _add(self, flowable, canv, trySplit=0): |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1652
diff
changeset
|
137 |
""" Draws the flowable at the current position. |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1652
diff
changeset
|
138 |
Returns 1 if successful, 0 if it would not fit. |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1652
diff
changeset
|
139 |
Raises a LayoutError if the object is too wide, |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1652
diff
changeset
|
140 |
or if it is too high for a totally empty frame, |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1652
diff
changeset
|
141 |
to avoid infinite loops""" |
2950 | 142 |
flowable._frame = self |
143 |
flowable.canv = canv #so they can use stringWidth etc |
|
144 |
try: |
|
145 |
if getattr(flowable,'frameAction',None): |
|
146 |
flowable.frameAction(self) |
|
147 |
return 1 |
|
2525 | 148 |
|
2950 | 149 |
y = self._y |
150 |
p = self._y1p |
|
151 |
s = 0 |
|
152 |
aW = self._getAvailableWidth() |
|
153 |
if not self._atTop: |
|
154 |
s =flowable.getSpaceBefore() |
|
155 |
if self._oASpace: |
|
156 |
s = max(s-self._prevASpace,0) |
|
157 |
h = y - p - s |
|
158 |
if h>0: |
|
159 |
w, h = flowable.wrap(aW, h) |
|
160 |
else: |
|
161 |
return 0 |
|
253 | 162 |
|
2950 | 163 |
h += s |
164 |
y -= h |
|
253 | 165 |
|
2950 | 166 |
if y < p-_FUZZ: |
167 |
if not rl_config.allowTableBoundsErrors and ((h>self._aH or w>aW) and not trySplit): |
|
168 |
from reportlab.platypus.doctemplate import LayoutError |
|
169 |
raise LayoutError("Flowable %s (%sx%s points) too large for frame (%sx%s points)." % ( |
|
170 |
flowable.__class__, w,h, aW,self._aH)) |
|
171 |
return 0 |
|
172 |
else: |
|
173 |
#now we can draw it, and update the current point. |
|
174 |
flowable.drawOn(canv, self._x + self._leftExtraIndent, y, _sW=aW-w) |
|
175 |
flowable.canv=canv |
|
176 |
if self._debug: logger.debug('drew %s' % flowable.identity()) |
|
177 |
s = flowable.getSpaceAfter() |
|
178 |
y -= s |
|
179 |
if self._oASpace: self._prevASpace = s |
|
180 |
if y!=self._y: self._atTop = 0 |
|
181 |
self._y = y |
|
182 |
return 1 |
|
183 |
finally: |
|
3010 | 184 |
#sometimes canv/_frame aren't still on the flowable |
185 |
for a in ('canv', '_frame'): |
|
186 |
if hasattr(flowable,a): |
|
187 |
delattr(flowable,a) |
|
253 | 188 |
|
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1652
diff
changeset
|
189 |
add = _add |
253 | 190 |
|
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1652
diff
changeset
|
191 |
def split(self,flowable,canv): |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1652
diff
changeset
|
192 |
'''Ask the flowable to split using up the available space.''' |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1652
diff
changeset
|
193 |
y = self._y |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1652
diff
changeset
|
194 |
p = self._y1p |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1652
diff
changeset
|
195 |
s = 0 |
2970
17c7629174cf
frames.py: bug & fix in Frame.split contributed by Matt Folwell
rgbecker
parents:
2964
diff
changeset
|
196 |
if not self._atTop: |
17c7629174cf
frames.py: bug & fix in Frame.split contributed by Matt Folwell
rgbecker
parents:
2964
diff
changeset
|
197 |
s = flowable.getSpaceBefore() |
17c7629174cf
frames.py: bug & fix in Frame.split contributed by Matt Folwell
rgbecker
parents:
2964
diff
changeset
|
198 |
if self._oASpace: |
17c7629174cf
frames.py: bug & fix in Frame.split contributed by Matt Folwell
rgbecker
parents:
2964
diff
changeset
|
199 |
s = max(s-self._prevASpace,0) |
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1652
diff
changeset
|
200 |
flowable.canv = canv #some flowables might need this |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1652
diff
changeset
|
201 |
r = flowable.split(self._aW, y-p-s) |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1652
diff
changeset
|
202 |
del flowable.canv |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1652
diff
changeset
|
203 |
return r |
253 | 204 |
|
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1652
diff
changeset
|
205 |
def drawBoundary(self,canv): |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1652
diff
changeset
|
206 |
"draw the frame boundary as a rectangle (primarily for debugging)." |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1652
diff
changeset
|
207 |
from reportlab.lib.colors import Color, CMYKColor, toColor |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1652
diff
changeset
|
208 |
sb = self.showBoundary |
2735
70cf084e5811
reportlab: fix justification space counting bug and improve tests
rgbecker
parents:
2593
diff
changeset
|
209 |
ss = type(sb) in (type(''),type(()),type([])) or isinstance(sb,Color) |
70cf084e5811
reportlab: fix justification space counting bug and improve tests
rgbecker
parents:
2593
diff
changeset
|
210 |
w = -1 |
70cf084e5811
reportlab: fix justification space counting bug and improve tests
rgbecker
parents:
2593
diff
changeset
|
211 |
if ss: |
70cf084e5811
reportlab: fix justification space counting bug and improve tests
rgbecker
parents:
2593
diff
changeset
|
212 |
c = toColor(sb,self) |
70cf084e5811
reportlab: fix justification space counting bug and improve tests
rgbecker
parents:
2593
diff
changeset
|
213 |
ss = c is not self |
70cf084e5811
reportlab: fix justification space counting bug and improve tests
rgbecker
parents:
2593
diff
changeset
|
214 |
elif isinstance(sb,ShowBoundaryValue) and sb: |
70cf084e5811
reportlab: fix justification space counting bug and improve tests
rgbecker
parents:
2593
diff
changeset
|
215 |
c = toColor(sb.color,self) |
70cf084e5811
reportlab: fix justification space counting bug and improve tests
rgbecker
parents:
2593
diff
changeset
|
216 |
w = sb.width |
70cf084e5811
reportlab: fix justification space counting bug and improve tests
rgbecker
parents:
2593
diff
changeset
|
217 |
ss = c is not self |
70cf084e5811
reportlab: fix justification space counting bug and improve tests
rgbecker
parents:
2593
diff
changeset
|
218 |
if ss: |
70cf084e5811
reportlab: fix justification space counting bug and improve tests
rgbecker
parents:
2593
diff
changeset
|
219 |
canv.saveState() |
70cf084e5811
reportlab: fix justification space counting bug and improve tests
rgbecker
parents:
2593
diff
changeset
|
220 |
canv.setStrokeColor(c) |
70cf084e5811
reportlab: fix justification space counting bug and improve tests
rgbecker
parents:
2593
diff
changeset
|
221 |
if w>=0: |
70cf084e5811
reportlab: fix justification space counting bug and improve tests
rgbecker
parents:
2593
diff
changeset
|
222 |
canv.setLineWidth(w) |
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1652
diff
changeset
|
223 |
canv.rect( |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1652
diff
changeset
|
224 |
self._x1, |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1652
diff
changeset
|
225 |
self._y1, |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1652
diff
changeset
|
226 |
self._x2 - self._x1, |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1652
diff
changeset
|
227 |
self._y2 - self._y1 |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1652
diff
changeset
|
228 |
) |
2735
70cf084e5811
reportlab: fix justification space counting bug and improve tests
rgbecker
parents:
2593
diff
changeset
|
229 |
if ss: canv.restoreState() |
1683 | 230 |
|
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1652
diff
changeset
|
231 |
def addFromList(self, drawlist, canv): |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1652
diff
changeset
|
232 |
"""Consumes objects from the front of the list until the |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1652
diff
changeset
|
233 |
frame is full. If it cannot fit one object, raises |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1652
diff
changeset
|
234 |
an exception.""" |
253 | 235 |
|
2532 | 236 |
if self._debug: logger.debug("enter Frame.addFromlist() for frame %s" % self.id) |
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1652
diff
changeset
|
237 |
if self.showBoundary: |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1652
diff
changeset
|
238 |
self.drawBoundary(canv) |
253 | 239 |
|
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1652
diff
changeset
|
240 |
while len(drawlist) > 0: |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1652
diff
changeset
|
241 |
head = drawlist[0] |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1652
diff
changeset
|
242 |
if self.add(head,canv,trySplit=0): |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1652
diff
changeset
|
243 |
del drawlist[0] |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1652
diff
changeset
|
244 |
else: |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1652
diff
changeset
|
245 |
#leave it in the list for later |
2013 | 246 |
break |
2950 | 247 |
|
248 |
def add_generated_content(self,*C): |
|
249 |
self.__dict__.setdefault('_generated_content',[]).extend(C) |
|
3131
0f15fabe9d8d
reportlab: improve information in doctemplate overflow error
rgbecker
parents:
3032
diff
changeset
|
250 |
|
0f15fabe9d8d
reportlab: improve information in doctemplate overflow error
rgbecker
parents:
3032
diff
changeset
|
251 |
def _aSpaceString(self): |
0f15fabe9d8d
reportlab: improve information in doctemplate overflow error
rgbecker
parents:
3032
diff
changeset
|
252 |
return '(%s x %s%s)' % (self._getAvailableWidth(),self._aH,self._atTop and '*' or '') |