dabo Commit
Revision 6544
Date: 2011-04-13 16:42:01 -0700 (Wed, 13 Apr 2011)
Author: Paul
Trac: http://trac.dabodev.com/changeset/6544
Changed:
U trunk/dabo/lib/reportWriter.py
U trunk/ide/ReportDesigner.py
Log:
Deprecated Frameset/Paragraph; Added Memo which accomplishes the same
thing in the same way but the appdev doesn't need to know about the
hierarchy.
Removed the auto-updating of the _def default properties when the main
property changes, as it was causing unneeded cruft in the rfxml.
Changed default expr of String and Memo to "String" and "Memo",
respectively.
I'm going to think about whether or not to raise deprecation warnings
upon encountering Frameset/Paragraphs. I may just offer the conversion
in the designer and leave Frameset/Paragraph in the report writer
forever for backward compatibility.
Diff:
Modified: trunk/dabo/lib/reportWriter.py
===================================================================
--- trunk/dabo/lib/reportWriter.py 2011-04-06 23:33:02 UTC (rev 6543)
+++ trunk/dabo/lib/reportWriter.py 2011-04-13 23:42:01 UTC (rev 6544)
@@ -295,7 +295,9 @@
defProp = "%s_def" % prop
if defProp[-8:] == "_def_def":
defProp = None
- if defProp and self.getProp(prop, evaluate=False) ==
self.getProp(defProp, evaluate=False):
+ if False:
+ ## (after using it for a week, I think default props
shouldn't be changed automatically)
+ if defProp and self.getProp(prop, evaluate=False) ==
self.getProp(defProp, evaluate=False):
# Okay to change the _def prop since it looks
like the appdev
# hasn't explicitly set it.
self[defProp] = val
@@ -704,7 +706,7 @@
"""Represents a text string."""
def initAvailableProps(self):
super(String, self).initAvailableProps()
- self.AvailableProps["expr"] = toPropDict(str, None,
+ self.AvailableProps["expr"] = toPropDict(str, "String",
"""Specifies the string to print.""")
self.AvailableProps["BorderWidth"] = toPropDict(float, 0,
@@ -760,6 +762,45 @@
self.MajorProperty = "expr"
+
+class Memo(String):
+ """Represents a string object that can span multiple lines."""
+ def initAvailableProps(self):
+ super(Memo, self).initAvailableProps()
+
+ del self.AvailableProps["ScalePercent"]
+ del self.AvailableProps["Align"]
+
+ self.AvailableProps["expr"]["default"] = "Memo"
+
+ self.AvailableProps["PadLeft"] = toPropDict(float, 0,
+ """Specifies the padding on the left side of
the frame.""")
+
+ self.AvailableProps["PadRight"] = toPropDict(float, 0,
+ """Specifies the padding on the right side of
the frame.""")
+
+ self.AvailableProps["PadTop"] = toPropDict(float, 0,
+ """Specifies the padding on the top side of the
frame.""")
+
+ self.AvailableProps["PadBottom"] = toPropDict(float, 0,
+ """Specifies the padding on the bottom side of
the frame.""")
+
+ self.AvailableProps["ColumnCount"] = toPropDict(int, 1,
+ """Specifies the number of columns in the memo.
+
+ Each column will be equal in width.
+ """)
+
+ self.AvailableProps["Leading"] = toPropDict(float, None,
+ """Specifies the font leading (how much space
to leave between baselines).
+
+ For no leading (descenders of the upper line
overlapping ascenders from
+ the lower line), set Leading the same as
FontSize. To have reportlab choose
+ a default leading, set Leading to None.
+ """)
+
+
+
class Image(Drawable):
"""Represents an image."""
def initAvailableProps(self):
@@ -931,7 +972,7 @@
class Frameset(Drawable):
- """Represents a frameset."""
+ """Represents a frameset. DEPRECATED; Use Memo instead."""
def initAvailableProps(self):
super(Frameset, self).initAvailableProps()
@@ -967,7 +1008,7 @@
class Paragraph(Drawable):
- """Represents a paragraph."""
+ """Represents a paragraph. DEPRECATED; Use Memo instead."""
def initAvailableProps(self):
super(Paragraph, self).initAvailableProps()
self.AvailableProps["Style"] = toPropDict(str, "Normal",
@@ -979,7 +1020,7 @@
self.AvailableProps["FontName"] = toPropDict(str, "Helvetica",
"""Specifies the font name.""")
- self.AvailableProps["Leading"] = toPropDict(float, 0,
+ self.AvailableProps["Leading"] = toPropDict(float, None,
"""Specifies the font leading.""")
self.AvailableProps["SpaceAfter"] = toPropDict(float, 0,
@@ -1185,7 +1226,7 @@
height = obj.getProp("Height")
if height is not None:
height = self.getPt(height)
- if objType == "Frameset":
+ if objType in ("Frameset", "Memo"):
if vAnchor == "bottom":
y = y + height
elif vAnchor == "middle":
@@ -1401,9 +1442,9 @@
s = unicode(s)
func(posx, 0, s)
- elif objType == "Frameset":
- # A frame is directly related to reportlab's platypus
Frame.
-
+ elif objType in ("Frameset", "Memo"):
+ # Frameset is deprecated; Memo is what to use now. Memo
abstracts away the
+ # Frame/Paragraph hierarchy into one single report
object.
borderWidth = self.getPt(obj.getProp("borderWidth"))
borderColor = obj.getProp("borderColor")
columnCount = obj.getProp("columnCount")
@@ -1412,7 +1453,7 @@
padRight = self.getPt(obj.getProp("padRight"))
padTop = self.getPt(obj.getProp("padTop"))
padBottom = self.getPt(obj.getProp("padBottom"))
- frameId = obj.getProp("frameId")
+ frameId = None if objType == "Memo" else
obj.getProp("frameId")
if deferred:
story = deferred
@@ -1628,15 +1669,19 @@
columnCount = obj.getProp("columnCount")
columnWidth = width/columnCount
- styles_ = styles.getSampleStyleSheet()
+ if isinstance(obj, Memo):
+ # Memo doesn't have any subobjects
+ objects = [obj]
+ style = "Normal"
+ else:
+ # Frameset/Paragraph is deprecated
+ objects = obj["Objects"]
+ style = fobject.getProp("style")
+ s = styles.getSampleStyleSheet()[style]
+ story = []
- objects = obj["Objects"]
- story = []
for fobject in objects:
objNeededHeight = 0
-
- t = fobject.__class__.__name__
- s = styles_[fobject.getProp("style")]
expr = fobject.getProp("expr")
if isinstance(s, basestring):
@@ -1666,7 +1711,7 @@
if "firstLineIndent" in fobject:
s.firstLineIndent =
fobject.getProp("firstLineIndent")
- if t.lower() == "paragraph":
+ if isinstance(fobject, (Memo, Paragraph)):
paras = expr.splitlines()
for idx, para in enumerate(paras):
if len(para) == 0:
@@ -2509,7 +2554,7 @@
"PageForeground": PageForeground, "Rect":
Rectangle,
"Rectangle": Rectangle,
"String": String, "Image": Image, "BarGraph":
BarGraph, "Line": Line,
- "Frameset": Frameset, "Paragraph": Paragraph,
+ "Frameset": Frameset, "Paragraph": Paragraph,
"Memo": Memo,
"Variables": Variables, "Groups": Groups,
"Objects": Objects,
"TestCursor": TestCursor, "TestRecord":
TestRecord,
"SpanningLine": SpanningLine,
"SpanningRectangle": SpanningRectangle,
Modified: trunk/ide/ReportDesigner.py
===================================================================
--- trunk/ide/ReportDesigner.py 2011-04-06 23:33:02 UTC (rev 6543)
+++ trunk/ide/ReportDesigner.py 2011-04-13 23:42:01 UTC (rev 6544)
@@ -231,7 +231,7 @@
if not newObjectMenuCreated and
isinstance(robj, Band):
newObjectMenuCreated = True
objectChoices =
dabo.ui.dMenu(Caption="New object")
- for choice in (Image, Line, Rectangle,
String, Paragraph):
+ for choice in (Image, Line, Rectangle,
String, Memo):
objectChoices.append(choice.__name__,
OnHit=onNewObject, Tag=choice)
objectChoices.appendSeparator()
@@ -1248,9 +1248,6 @@
size[1] += fudge
position[0] -= .5 * fudge
position[1] -= .5 * fudge
- if isinstance(obj, (Frameset,)):
- # Select the paragraph instead
- obj = obj["Objects"][0]
if mousePos[0] >= position[0] and mousePos[0] <=
position[0] + size[0] \
and mousePos[1] >= position[1] and
mousePos[1] <= position[1] + size[1]:
mouseObj = obj
@@ -1282,6 +1279,8 @@
"""Return the size and position needed to draw the object at
the current zoom factor."""
rw = self._rw
z = self.Parent.ZoomFactor
+ if isinstance(obj, Paragraph):
+ obj = obj.parent.parent ## (the FrameSet)
try:
x = rw.getPt(obj.getProp("x"))
except ValueError:
@@ -1380,7 +1379,7 @@
obj._anchors = {}
- if objType in ("Paragraph", "String"):
+ if objType in ("Memo", "Paragraph", "String"):
dc.SetBackgroundMode(wx.TRANSPARENT)
expr = rdc.getShortExpr(obj.getProp("expr",
evaluate=False))
alignments = {"left": wx.ALIGN_LEFT,
@@ -1437,7 +1436,7 @@
font.Size = fontSize * z
dc.SetFont(font._nativeFont)
- if objType == "String":
+ if objType in ("Memo", "String"):
dc.SetTextForeground(self._rw.getColorTupleFromReportLab(obj.getProp("fontColor")))
top_fudge = .5 ## wx draws a tad too high
_______________________________________________
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]