graphics/GraphicCommons.py
changeset 213 4931959ea256
parent 208 c70aefcadf66
child 222 8ce5c2635976
--- a/graphics/GraphicCommons.py	Wed Jun 04 17:48:26 2008 +0200
+++ b/graphics/GraphicCommons.py	Mon Jun 23 18:48:49 2008 +0200
@@ -1120,6 +1120,12 @@
         dc.SetPen(self.Pen)
         dc.SetBrush(wx.WHITE_BRUSH)
         parent_pos = self.ParentBlock.GetPosition()
+        
+        if getattr(dc, "printing", False):
+            name_size = dc.GetTextExtent(self.Name)
+        else:
+            name_size = self.NameSize
+        
         if self.Negated:
             # If connector is negated, draw a circle
             xcenter = parent_pos[0] + self.Pos.x + (CONNECTOR_SIZE * self.Direction[0]) / 2
@@ -1140,17 +1146,17 @@
             yend = ystart + CONNECTOR_SIZE * self.Direction[1]
             dc.DrawLine(xstart + self.Direction[0], ystart + self.Direction[1], xend, yend)
         if self.Direction[0] != 0:
-            ytext = parent_pos[1] + self.Pos.y - self.NameSize[1] / 2
+            ytext = parent_pos[1] + self.Pos.y - name_size[1] / 2
             if self.Direction[0] < 0:
                 xtext = parent_pos[0] + self.Pos.x + 5
             else:
-                xtext = parent_pos[0] + self.Pos.x - (self.NameSize[0] + 5)
+                xtext = parent_pos[0] + self.Pos.x - (name_size[0] + 5)
         if self.Direction[1] != 0:
-            xtext = parent_pos[0] + self.Pos.x - self.NameSize[0] / 2
+            xtext = parent_pos[0] + self.Pos.x - name_size[0] / 2
             if self.Direction[1] < 0:
                 ytext = parent_pos[1] + self.Pos.y + 5
             else:
-                ytext = parent_pos[1] + self.Pos.y - (self.NameSize[1] + 5)
+                ytext = parent_pos[1] + self.Pos.y - (name_size[1] + 5)
         # Draw the text
         dc.DrawText(self.Name, xtext, ytext)