dabo Commit
Revision 5170
Date: 2009-04-03 12:25:43 -0700 (Fri, 03 Apr 2009)
Author: Paul
Trac: http://trac.dabodev.com/changeset/5170

Changed:
U   trunk/ide/ReportDesigner.py

Log:
Using a background form (an orderform in PNG format), I did some tedious 
comparisons of text placement on the report designer surface versus the
reportlab-outputted PDF. These were off, mostly due to the fact that the
strings are drawn to the PDF where the y position determines the (left, bottom)
of the font's baseline, whereas the wx position determines the (left, top)
of the entire font. I've also left in some minor fudging.



Diff:
Modified: trunk/ide/ReportDesigner.py
===================================================================
--- trunk/ide/ReportDesigner.py 2009-04-03 19:23:02 UTC (rev 5169)
+++ trunk/ide/ReportDesigner.py 2009-04-03 19:25:43 UTC (rev 5170)
@@ -1282,21 +1282,12 @@
                        size, position = self.getObjSizeAndPosition(obj)
                        rect = [position[0], position[1], size[0], size[1]]
 
-                       if objType == "String":
-                               # wx.DC draws the text string too high versus 
reportlab. This appears to
-                               # be due to Reportlab using true baseline 
(where the lower part of the
-                               # letter y will be below the baseline, while wx 
makes the bottom part of
-                               # the y the bottom.
-                               vFudge = 2
-                               rect[1] = rect[1] + vFudge
-                               rect[3] = rect[3] + vFudge
                        dc.DestroyClippingRegion()
 
                        dc.SetBrush(wx.Brush((0,0,0), wx.TRANSPARENT))
                        dc.SetPen(wx.Pen(selectColor, 0.1, wx.DOT))
-                       
dc.DrawRectangle(position[0],position[1],size[0],size[1])
+                       dc.DrawRectangle(position[0], position[1], size[0], 
size[1])
 
-                       dc.SetClippingRect(rect)
 
                        if objType == "String":
                                dc.SetBackgroundMode(wx.TRANSPARENT)
@@ -1354,12 +1345,23 @@
                                dc.SetFont(font._nativeFont)
                                
dc.SetTextForeground(self._rw.getColorTupleFromReportLab(obj.getProp("fontColor")))
 
+                               top_fudge = .25   ## wx draws a tad too high
+                               left_fudge = .25  ## and a tad too far to the 
left
+                               # We need the y value to match up with the font 
at the baseline, but to clip
+                               # the entire region, including descent.
+                               descent = dc.GetFullTextExtent(expr)[2]
+                               rect[0] += left_fudge
+                               rect[2] += left_fudge
+                               rect[1] += top_fudge
+                               rect[3] += top_fudge + descent
+                               dc.SetClippingRect(rect)
+
                                if False and rotation != 0:
                                        # We lose the ability to have the 
alignment and exact rect positioning.
                                        # But we get to show it rotated. The 
x,y values below are hacks.
                                        dc.DrawRotatedText(expr, 
rect[0]+(rect[2]/4), rect[3] - (rect[3]/2), rotation)
                                else:
-                                       dc.DrawLabel(expr, (rect[0]+2, rect[1], 
rect[2]-4, rect[3]),
+                                       dc.DrawLabel(expr, (rect[0], rect[1], 
rect[2], rect[3]),
                                                        
alignments[alignment]|wx.ALIGN_BOTTOM)
 
                        if objType == "Rectangle":



_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/dabo-dev
Searchable Archives: http://leafe.com/archives/search/dabo-dev
This message: 
http://leafe.com/archives/byMID/[email protected]

Reply via email to