[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gnue] r8126 - trunk/gnue-common/src/printing/pdftable
From: |
jamest |
Subject: |
[gnue] r8126 - trunk/gnue-common/src/printing/pdftable |
Date: |
Tue, 10 Jan 2006 20:44:57 -0600 (CST) |
Author: jamest
Date: 2006-01-10 20:44:57 -0600 (Tue, 10 Jan 2006)
New Revision: 8126
Modified:
trunk/gnue-common/src/printing/pdftable/pdftable.py
trunk/gnue-common/src/printing/pdftable/sample.py
Log:
added support for addLine so pdf table can add check register style lines
under standard rows
Modified: trunk/gnue-common/src/printing/pdftable/pdftable.py
===================================================================
--- trunk/gnue-common/src/printing/pdftable/pdftable.py 2006-01-10 13:54:19 UTC
(rev 8125)
+++ trunk/gnue-common/src/printing/pdftable/pdftable.py 2006-01-11 02:44:57 UTC
(rev 8126)
@@ -450,6 +450,86 @@
self.y -= tracking
+ def addLine(self, string, borders=None):
+ """
+ Adds a single line of text instead of a row to a table.
+
+ Usefull in reproducing a check register style printout.
+
+ @param String: The string to print
+ @param borders: A list containing the border widths to use on the line.
+ Sequence is in the order Top, Right, Bottom, Left (TRBL)
+ which I believe is how CSS does it
+ """
+ canvas = self.canvas
+
+ font, size, tracking = fontDefs['dataFont']
+ fontWidth = self.dataFontWidth
+
+ size = size * self.scale
+ tracking = tracking * self.scale
+
+ if self.y - tracking < self.miny:
+ self.newPage()
+
+ boxy = self.y - (tracking-size)*1.5
+ boxh = tracking
+
+ # Use the same highlighting as the pervious row printed
+ highlighted = divmod((self.highlightIndex-1),4)[1]>1 # Use the same
highlighting
+ if highlighted:
+ # If there is a bottom border we need to not draw over the top
+ # of the previous rows border. Currently minimum must be 1 point
+ adjustment = max([self._currentSection['columnBottomBorder'][0],1])
+ self.drawHorizBorderedBox(leftmargin, boxy, self.width-leftmargin*2,
+ boxh-adjustment, highlightColor, lines=0)
+
+ # Place a border around the memo line
+ if borders:
+ topBorder, rightBorder, bottomBorder, leftBorder = borders
+
+ # Top
+ if topBorder:
+ canvas.setLineWidth(topBorder*self.scale)
+ canvas.line(leftmargin, boxy + boxh, self.width-leftmargin, boxy +
boxh)
+
+ #Right
+ if rightBorder:
+ canvas.setLineWidth(rightBorder*self.scale)
+ canvas.line(self.width-leftmargin, boxy, self.width-leftmargin, boxy +
boxh)
+
+ # Bottom
+ if bottomBorder:
+ canvas.setLineWidth(bottomBorder*self.scale)
+ canvas.line(leftmargin, boxy, self.width-leftmargin, boxy)
+ # Left
+ if leftBorder:
+ canvas.setLineWidth(leftBorder*self.scale)
+ canvas.line(leftmargin, boxy, leftmargin, boxy + boxh)
+
+ canvas.setFont(font, size)
+ hlx1 = leftmargin
+
+ if string:
+ # Clip text, if needed
+ restore = False
+ if fontWidth(string, size) > self.width-leftmargin*2:
+ restore = True
+ canvas.saveState()
+ path = canvas.beginPath()
+ # Vertical is overkill, but only interested in horizontal
+ path.rect(leftmargin,self.y-tracking, self.width-leftmargin*2,
tracking*3)
+ canvas.clipPath(path, stroke=0, fill=0)
+
+ canvas.drawString(leftmargin,self.y,string)
+
+ # Restore from clipping
+ if restore:
+ canvas.restoreState()
+
+ self.y -= tracking
+
+
# ==========================================================================
# Private functions
# ==========================================================================
Modified: trunk/gnue-common/src/printing/pdftable/sample.py
===================================================================
--- trunk/gnue-common/src/printing/pdftable/sample.py 2006-01-10 13:54:19 UTC
(rev 8125)
+++ trunk/gnue-common/src/printing/pdftable/sample.py 2006-01-11 02:44:57 UTC
(rev 8126)
@@ -56,8 +56,8 @@
writer = pdftable(f)
- writer.setFullTitle([("Quarterly Sales Report", titleFont),
- ('2002 - 2004', title2Font),
+ writer.setFullTitle([("Quarterly Sales Report", fontDefs['titleFont']),
+ ('2002 - 2004', fontDefs['title2Font']),
])
# ========================================================================
@@ -167,6 +167,7 @@
# Fill with data
for row in self._generateSalesData(store['modelLines']):
writer.addRow(row)
+# writer.addLine("Test Line", borders=[0,.25,.25,.25])
# We won't compute totals in this sample
writer.addRow(["Total 1"]+['0']*24, style='Subtotal')
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [gnue] r8126 - trunk/gnue-common/src/printing/pdftable,
jamest <=