1118 # Draws the connector |
1118 # Draws the connector |
1119 def Draw(self, dc): |
1119 def Draw(self, dc): |
1120 dc.SetPen(self.Pen) |
1120 dc.SetPen(self.Pen) |
1121 dc.SetBrush(wx.WHITE_BRUSH) |
1121 dc.SetBrush(wx.WHITE_BRUSH) |
1122 parent_pos = self.ParentBlock.GetPosition() |
1122 parent_pos = self.ParentBlock.GetPosition() |
|
1123 |
|
1124 if getattr(dc, "printing", False): |
|
1125 name_size = dc.GetTextExtent(self.Name) |
|
1126 else: |
|
1127 name_size = self.NameSize |
|
1128 |
1123 if self.Negated: |
1129 if self.Negated: |
1124 # If connector is negated, draw a circle |
1130 # If connector is negated, draw a circle |
1125 xcenter = parent_pos[0] + self.Pos.x + (CONNECTOR_SIZE * self.Direction[0]) / 2 |
1131 xcenter = parent_pos[0] + self.Pos.x + (CONNECTOR_SIZE * self.Direction[0]) / 2 |
1126 ycenter = parent_pos[1] + self.Pos.y + (CONNECTOR_SIZE * self.Direction[1]) / 2 |
1132 ycenter = parent_pos[1] + self.Pos.y + (CONNECTOR_SIZE * self.Direction[1]) / 2 |
1127 dc.DrawCircle(xcenter, ycenter, CONNECTOR_SIZE / 2) |
1133 dc.DrawCircle(xcenter, ycenter, CONNECTOR_SIZE / 2) |
1138 dc.DrawLine(xstart, ystart, xstart + 4, ystart + 4) |
1144 dc.DrawLine(xstart, ystart, xstart + 4, ystart + 4) |
1139 xend = xstart + CONNECTOR_SIZE * self.Direction[0] |
1145 xend = xstart + CONNECTOR_SIZE * self.Direction[0] |
1140 yend = ystart + CONNECTOR_SIZE * self.Direction[1] |
1146 yend = ystart + CONNECTOR_SIZE * self.Direction[1] |
1141 dc.DrawLine(xstart + self.Direction[0], ystart + self.Direction[1], xend, yend) |
1147 dc.DrawLine(xstart + self.Direction[0], ystart + self.Direction[1], xend, yend) |
1142 if self.Direction[0] != 0: |
1148 if self.Direction[0] != 0: |
1143 ytext = parent_pos[1] + self.Pos.y - self.NameSize[1] / 2 |
1149 ytext = parent_pos[1] + self.Pos.y - name_size[1] / 2 |
1144 if self.Direction[0] < 0: |
1150 if self.Direction[0] < 0: |
1145 xtext = parent_pos[0] + self.Pos.x + 5 |
1151 xtext = parent_pos[0] + self.Pos.x + 5 |
1146 else: |
1152 else: |
1147 xtext = parent_pos[0] + self.Pos.x - (self.NameSize[0] + 5) |
1153 xtext = parent_pos[0] + self.Pos.x - (name_size[0] + 5) |
1148 if self.Direction[1] != 0: |
1154 if self.Direction[1] != 0: |
1149 xtext = parent_pos[0] + self.Pos.x - self.NameSize[0] / 2 |
1155 xtext = parent_pos[0] + self.Pos.x - name_size[0] / 2 |
1150 if self.Direction[1] < 0: |
1156 if self.Direction[1] < 0: |
1151 ytext = parent_pos[1] + self.Pos.y + 5 |
1157 ytext = parent_pos[1] + self.Pos.y + 5 |
1152 else: |
1158 else: |
1153 ytext = parent_pos[1] + self.Pos.y - (self.NameSize[1] + 5) |
1159 ytext = parent_pos[1] + self.Pos.y - (name_size[1] + 5) |
1154 # Draw the text |
1160 # Draw the text |
1155 dc.DrawText(self.Name, xtext, ytext) |
1161 dc.DrawText(self.Name, xtext, ytext) |
1156 |
1162 |
1157 |
1163 |
1158 #------------------------------------------------------------------------------- |
1164 #------------------------------------------------------------------------------- |