- Fixing editing graphic element (handles, rubberband and highlight) in graphic editor in order to make them keep the same size whatever the zoom factor applied to graphic editor
authorlaurent
Thu, 22 Sep 2011 15:33:31 +0200
changeset 563 3f92a5e18804
parent 562 0ce12552cf36
child 564 5024d42e1050
- Fixing editing graphic element (handles, rubberband and highlight) in graphic editor in order to make them keep the same size whatever the zoom factor applied to graphic editor
- Replace default pen by a pen with miter join property to draw graphic elements without round corner in high zoom factor
- Reduce the default size of fonts in graphic editor
LDViewer.py
PLCOpenEditor.py
SFCViewer.py
Viewer.py
graphics/FBD_Objects.py
graphics/GraphicCommons.py
graphics/LD_Objects.py
graphics/SFC_Objects.py
--- a/LDViewer.py	Thu Sep 22 10:56:52 2011 +0200
+++ b/LDViewer.py	Thu Sep 22 15:33:31 2011 +0200
@@ -259,16 +259,18 @@
                 return i
         return None
 
-    def FindElement(self, pos, exclude_group = False):
+    def FindElement(self, event, exclude_group = False):
         if self.GetDrawingMode() == FREEDRAWING_MODE:
-            return Viewer.FindElement(self, pos, exclude_group)
+            return Viewer.FindElement(self, event, exclude_group)
         
+        dc = self.GetLogicalDC()
+        pos = event.GetLogicalPosition(dc)
         if self.SelectedElement and not isinstance(self.SelectedElement, (Graphic_Group, Wire)):
             if self.SelectedElement.HitTest(pos) or self.SelectedElement.TestHandle(pos) != (0, 0):
                 return self.SelectedElement
         elements = []
         for element in self.GetElements(sort_wires=True):
-            if element.HitTest(pos) or element.TestHandle(pos) != (0, 0):
+            if element.HitTest(pos) or element.TestHandle(event) != (0, 0):
                 elements.append(element)
         if len(elements) == 1:
             return elements[0]
@@ -296,9 +298,7 @@
         if self.GetDrawingMode() == FREEDRAWING_MODE:
             Viewer.OnViewerLeftDown(self, event)
         elif self.Mode == MODE_SELECTION:
-            dc = self.GetLogicalDC()
-            pos = event.GetLogicalPosition(dc)
-            element = self.FindElement(pos)
+            element = self.FindElement(event)
             if self.SelectedElement:
                 if not isinstance(self.SelectedElement, Graphic_Group):
                     if self.SelectedElement != element:
@@ -323,11 +323,11 @@
                     self.SelectedElement = None
             if element:
                 self.SelectedElement = element
-                self.SelectedElement.OnLeftDown(event, dc, self.Scaling)
+                self.SelectedElement.OnLeftDown(event, self.GetLogicalDC(), self.Scaling)
                 self.SelectedElement.Refresh()
             else:
                 self.rubberBand.Reset()
-                self.rubberBand.OnLeftDown(event, dc, self.Scaling)
+                self.rubberBand.OnLeftDown(event, self.GetLogicalDC(), self.Scaling)
         event.Skip()
 
     def OnViewerLeftUp(self, event):
@@ -366,9 +366,7 @@
         if self.GetDrawingMode() == FREEDRAWING_MODE:
             Viewer.OnViewerRightUp(self, event)
         else:
-            dc = self.GetLogicalDC()
-            pos = event.GetLogicalPosition(dc)
-            element = self.FindElement(pos)
+            element = self.FindElement(event)
             if element:
                 if self.SelectedElement and self.SelectedElement != element:
                     self.SelectedElement.SetSelected(False)
@@ -377,7 +375,7 @@
                     self.SelectedElement.SetSelectedSegment(0)
                 else:
                     self.SelectedElement.SetSelected(True)
-                    self.SelectedElement.OnRightUp(event, dc, self.Scaling)
+                    self.SelectedElement.OnRightUp(event, self.GetLogicalDC(), self.Scaling)
                     self.SelectedElement.Refresh()
                 wx.CallAfter(self.SetCurrentCursor, 0)
         event.Skip()
--- a/PLCOpenEditor.py	Thu Sep 22 10:56:52 2011 +0200
+++ b/PLCOpenEditor.py	Thu Sep 22 15:33:31 2011 +0200
@@ -4354,7 +4354,7 @@
         area_width = dw - self.Margins[1].x * Xscale - margin_left
         area_height = dh - self.Margins[1].y * Yscale - margin_top
         
-        dc.SetPen(wx.BLACK_PEN)
+        dc.SetPen(MiterPen(wx.BLACK))
         dc.SetBrush(wx.TRANSPARENT_BRUSH)    
         dc.DrawRectangle(margin_left, margin_top, area_width, area_height)
         
--- a/SFCViewer.py	Thu Sep 22 10:56:52 2011 +0200
+++ b/SFCViewer.py	Thu Sep 22 15:33:31 2011 +0200
@@ -168,10 +168,8 @@
         if self.GetDrawingMode() == FREEDRAWING_MODE:
             Viewer.OnViewerLeftDown(self, event)
         elif self.Mode == MODE_SELECTION:
-            dc = self.GetLogicalDC()
-            pos = event.GetLogicalPosition(dc)
             if event.ShiftDown() and not event.ControlDown() and self.SelectedElement is not None:
-                element = self.FindElement(pos, True)
+                element = self.FindElement(event, True)
                 if element and not self.IsWire(element):
                     if isinstance(self.SelectedElement, Graphic_Group):
                         self.SelectedElement.SelectElement(element)
@@ -188,7 +186,7 @@
                         self.SelectedElement = elements[0]
                     self.SelectedElement.SetSelected(True)
             else:
-                element = self.FindElement(pos)
+                element = self.FindElement(event)
                 if self.SelectedElement and self.SelectedElement != element:
                     if self.IsWire(self.SelectedElement):
                         self.SelectedElement.SetSelectedSegment(None)
@@ -197,11 +195,11 @@
                     self.SelectedElement = None
                 if element:
                     self.SelectedElement = element
-                    self.SelectedElement.OnLeftDown(event, dc, self.Scaling)
+                    self.SelectedElement.OnLeftDown(event, self.GetLogicalDC(), self.Scaling)
                     self.SelectedElement.Refresh()
                 else:
                     self.rubberBand.Reset()
-                    self.rubberBand.OnLeftDown(event, dc, self.Scaling)
+                    self.rubberBand.OnLeftDown(event, self.GetLogicalDC(), self.Scaling)
         elif self.Mode == MODE_COMMENT:
             self.rubberBand.Reset()
             self.rubberBand.OnLeftDown(event, self.GetLogicalDC(), self.Scaling)
@@ -243,9 +241,7 @@
         if self.GetDrawingMode() == FREEDRAWING_MODE:
             Viewer.OnViewerRightUp(self, event)
         else:
-            dc = self.GetLogicalDC()
-            pos = event.GetLogicalPosition(dc)
-            element = self.FindElement(pos)
+            element = self.FindElement(event)
             if element:
                 if self.SelectedElement and self.SelectedElement != element:
                     self.SelectedElement.SetSelected(False)
@@ -254,7 +250,7 @@
                     self.SelectedElement.SetSelectedSegment(0)
                 else:
                     self.SelectedElement.SetSelected(True)
-                    self.SelectedElement.OnRightUp(event, dc, self.Scaling)
+                    self.SelectedElement.OnRightUp(event, self.GetLogicalDC(), self.Scaling)
                     self.SelectedElement.Refresh()
                 wx.CallAfter(self.SetCurrentCursor, 0)
         event.Skip()
--- a/Viewer.py	Thu Sep 22 10:56:52 2011 +0200
+++ b/Viewer.py	Thu Sep 22 15:33:31 2011 +0200
@@ -65,14 +65,14 @@
               'mono' : 'Courier New',
               'helv' : 'Arial',
               'other': 'Comic Sans MS',
-              'size' : 20,
+              'size' : 10,
              }
 else:
     faces = { 'times': 'Times',
               'mono' : 'Courier',
               'helv' : 'Helvetica',
               'other': 'new century schoolbook',
-              'size' : 20,
+              'size' : 12,
              }
 
 ZOOM_FACTORS = [math.sqrt(2) ** x for x in xrange(-6, 7)]
@@ -757,7 +757,7 @@
                 dc = wx.MemoryDC(bitmap)
                 dc.SetBackground(wx.Brush(self.GetBackgroundColour()))
                 dc.Clear()
-                dc.SetPen(wx.Pen(wx.Colour(180, 180, 180)))
+                dc.SetPen(MiterPen(wx.Colour(180, 180, 180)))
                 dc.DrawPoint(0, 0)
                 self.GridBrush = wx.BrushFromBitmap(bitmap)
             else:
@@ -768,7 +768,7 @@
         page_size = properties["pageSize"]
         if page_size != (0, 0):
             self.PageSize = map(int, page_size)
-            self.PagePen = wx.Pen(wx.Colour(180, 180, 180))
+            self.PagePen = MiterPen(wx.Colour(180, 180, 180))
         else:
             self.PageSize = None
             self.PagePen = wx.TRANSPARENT_PEN
@@ -1016,24 +1016,30 @@
 #                          Search Element functions
 #-------------------------------------------------------------------------------
 
-    def FindBlock(self, pos):
+    def FindBlock(self, event):
+        dc = self.GetLogicalDC()
+        pos = event.GetLogicalPosition(dc)
         for block in self.Blocks.itervalues():
-            if block.HitTest(pos) or block.TestHandle(pos) != (0, 0):
+            if block.HitTest(pos) or block.TestHandle(event) != (0, 0):
                 return block
         return None
     
-    def FindWire(self, pos):
+    def FindWire(self, event):
+        dc = self.GetLogicalDC()
+        pos = event.GetLogicalPosition(dc)
         for wire in self.Wires:
-            if wire.HitTest(pos) or wire.TestHandle(pos) != (0, 0):
+            if wire.HitTest(pos) or wire.TestHandle(event) != (0, 0):
                 return wire
         return None
     
-    def FindElement(self, pos, exclude_group = False):
+    def FindElement(self, event, exclude_group = False):
+        dc = self.GetLogicalDC()
+        pos = event.GetLogicalPosition(dc)
         if self.SelectedElement and not (exclude_group and isinstance(self.SelectedElement, Graphic_Group)):
-            if self.SelectedElement.HitTest(pos) or self.SelectedElement.TestHandle(pos) != (0, 0):
+            if self.SelectedElement.HitTest(pos) or self.SelectedElement.TestHandle(event) != (0, 0):
                 return self.SelectedElement
         for element in self.GetElements():
-            if element.HitTest(pos) or element.TestHandle(pos) != (0, 0):
+            if element.HitTest(pos) or element.TestHandle(event) != (0, 0):
                 return element
         return None
     
@@ -1318,19 +1324,19 @@
                         self.SelectedElement = elements[0]
                     self.SelectedElement.SetSelected(True)
             else:
-                element = self.FindElement(pos)
-                if not self.Debug and (element is None or element.TestHandle(pos) == (0, 0)):
+                element = self.FindElement(event)
+                if not self.Debug and (element is None or element.TestHandle(event) == (0, 0)):
                     connector = self.FindBlockConnector(pos)
                 else:
                     connector = None
                 if not self.Debug and self.DrawingWire:
                     self.DrawingWire = False
                     if self.SelectedElement is not None:
-                        if element is None or element.TestHandle(pos) == (0, 0):
+                        if element is None or element.TestHandle(event) == (0, 0):
                             connector = self.FindBlockConnector(pos, self.SelectedElement.GetConnectionDirection())
                         if connector is not None:
                             event.Dragging = lambda : True
-                            self.SelectedElement.OnMotion(event, self.GetLogicalDC(), self.Scaling)
+                            self.SelectedElement.OnMotion(event, dc, self.Scaling)
                         if self.SelectedElement.EndConnected is not None:
                             self.SelectedElement.ResetPoints()
                             self.SelectedElement.GeneratePoints()
@@ -1346,7 +1352,7 @@
                             self.RefreshRect(self.GetScrolledRect(rect), False)
                 elif not self.Debug and connector is not None:
                     self.DrawingWire = True
-                    scaled_pos = GetScaledEventPosition(event, self.GetLogicalDC(), self.Scaling)
+                    scaled_pos = GetScaledEventPosition(event, dc, self.Scaling)
                     if (connector.GetDirection() == EAST):
                         wire = Wire(self, [wx.Point(pos.x, pos.y), EAST], [wx.Point(scaled_pos.x, scaled_pos.y), WEST])
                     else:
@@ -1473,28 +1479,25 @@
     
     def OnViewerRightDown(self, event):
         if self.Mode == MODE_SELECTION:
-            dc = self.GetLogicalDC()
-            pos = event.GetLogicalPosition(dc)
-            element = self.FindElement(pos)
+            element = self.FindElement(event)
             if self.SelectedElement is not None and self.SelectedElement != element:
                 self.SelectedElement.SetSelected(False)
                 self.SelectedElement = None
             if element:
                 self.SelectedElement = element
                 if self.Debug:
-                    Graphic_Element.OnRightDown(self.SelectedElement, event, dc, self.Scaling)
+                    Graphic_Element.OnRightDown(self.SelectedElement, event, self.GetLogicalDC(), self.Scaling)
                 else:
-                    self.SelectedElement.OnRightDown(event, dc, self.Scaling)
+                    self.SelectedElement.OnRightDown(event, self.GetLogicalDC(), self.Scaling)
                 self.SelectedElement.Refresh()
         event.Skip()
     
     def OnViewerRightUp(self, event):
-        dc = self.GetLogicalDC()
         if self.SelectedElement is not None:
             if self.Debug:
-                Graphic_Element.OnRightUp(self.SelectedElement, event, dc, self.Scaling)
+                Graphic_Element.OnRightUp(self.SelectedElement, event, self.GetLogicalDC(), self.Scaling)
             else:
-                self.SelectedElement.OnRightUp(event, dc, self.Scaling)
+                self.SelectedElement.OnRightUp(event, self.GetLogicalDC(), self.Scaling)
             wx.CallAfter(self.SetCurrentCursor, 0)
         elif not self.Debug:
             self.PopupDefaultMenu(False)
@@ -1552,7 +1555,7 @@
                     tooltip_pos = self.ClientToScreen(event.GetPosition())
                     tooltip_pos.x += 10
                     tooltip_pos.y += 10
-                highlighted = self.FindElement(pos) 
+                highlighted = self.FindElement(event) 
                 if self.HighlightedElement is not None and self.HighlightedElement != highlighted:
                     if self.Debug and isinstance(self.HighlightedElement, Wire):
                         self.HighlightedElement.ClearToolTip()
--- a/graphics/FBD_Objects.py	Thu Sep 22 10:56:52 2011 +0200
+++ b/graphics/FBD_Objects.py	Thu Sep 22 15:33:31 2011 +0200
@@ -49,7 +49,7 @@
         self.Inputs = []
         self.Outputs = []
         self.Colour = wx.BLACK
-        self.Pen = wx.BLACK_PEN
+        self.Pen = MiterPen(wx.BLACK)
         self.SetType(type, extension, inputs, connectors, executionControl)
         self.Errors = {}
     
@@ -240,7 +240,7 @@
             if self.ExecutionControl:
                 inputs.insert(0, ("EN","BOOL","none"))
                 outputs.insert(0, ("ENO","BOOL","none"))
-            self.Pen = wx.Pen(self.Colour)
+            self.Pen = MiterPen(self.Colour)
             self.Clean()
             # Extract the inputs properties and create the corresponding connector
             self.Inputs = []
@@ -651,7 +651,7 @@
     # Draws variable
     def Draw(self, dc):
         Graphic_Element.Draw(self, dc)
-        dc.SetPen(wx.BLACK_PEN)
+        dc.SetPen(MiterPen(wx.BLACK))
         dc.SetBrush(wx.WHITE_BRUSH)
         
         if getattr(dc, "printing", False):
@@ -854,7 +854,7 @@
     # Draws connection
     def Draw(self, dc):
         Graphic_Element.Draw(self, dc)
-        dc.SetPen(wx.BLACK_PEN)
+        dc.SetPen(MiterPen(wx.BLACK))
         dc.SetBrush(wx.WHITE_BRUSH)
         
         if getattr(dc, "printing", False):
--- a/graphics/GraphicCommons.py	Thu Sep 22 10:56:52 2011 +0200
+++ b/graphics/GraphicCommons.py	Thu Sep 22 15:33:31 2011 +0200
@@ -226,6 +226,12 @@
                    "DT": generate_datetime,
                    "TOD": generate_timeofday}
 
+def MiterPen(colour, width=1, style=wx.SOLID):
+    pen = wx.Pen(colour, width, style)
+    pen.SetJoin(wx.JOIN_MITER)
+    pen.SetCap(wx.CAP_PROJECTING)
+    return pen
+
 #-------------------------------------------------------------------------------
 #                            Debug Data Consumer Class
 #-------------------------------------------------------------------------------
@@ -439,40 +445,49 @@
     def Redraw(self, dc = None):
         if not dc:
             dc = self.drawingSurface.GetLogicalDC()
+        scalex, scaley = dc.GetUserScale()
+        dc.SetUserScale(1, 1)
         dc.SetPen(wx.Pen(wx.WHITE, 1, wx.DOT))
         dc.SetBrush(wx.TRANSPARENT_BRUSH)
         dc.SetLogicalFunction(wx.XOR)
         if self.lastBox:
             # Erase last box
-            dc.DrawRectangle(self.lastBox.x, self.lastBox.y, self.lastBox.width,
-                self.lastBox.height)
+            dc.DrawRectangle(self.lastBox.x * scalex, self.lastBox.y * scaley, 
+                             self.lastBox.width * scalex, self.lastBox.height * scaley)
         if self.currentBox:
             # Draw current box
-            dc.DrawRectangle(self.currentBox.x, self.currentBox.y, self.currentBox.width,
-                self.currentBox.height)
+            dc.DrawRectangle(self.currentBox.x * scalex, self.currentBox.y * scaley, 
+                             self.currentBox.width * scalex, self.currentBox.height * scaley)
+        dc.SetUserScale(scalex, scaley)
     
     # Erase last box
     def Erase(self, dc = None):
         if not dc:
             dc = self.drawingSurface.GetLogicalDC()
+        scalex, scaley = dc.GetUserScale()
+        dc.SetUserScale(1, 1)
         dc.SetPen(wx.Pen(wx.WHITE, 1, wx.DOT))
         dc.SetBrush(wx.TRANSPARENT_BRUSH)
         dc.SetLogicalFunction(wx.XOR)
         if self.lastBox:
-            dc.DrawRectangle(self.lastBox.x, self.lastBox.y, self.lastBox.width,
-                self.lastBox.height)
-    
+            dc.DrawRectangle(self.lastBox.x * scalex, self.lastBox.y * scaley, 
+                             self.lastBox.width * scalex, self.lastBox.height * scalex)
+        dc.SetUserScale(scalex, scaley)
+
     # Draw current box
     def Draw(self, dc = None):
         if not dc:
             dc = self.drawingSurface.GetLogicalDC()
+        scalex, scaley = dc.GetUserScale()
+        dc.SetUserScale(1, 1)
         dc.SetPen(wx.Pen(wx.WHITE, 1, wx.DOT))
         dc.SetBrush(wx.TRANSPARENT_BRUSH)
         dc.SetLogicalFunction(wx.XOR)
         if self.currentBox:
             # Draw current box
-            dc.DrawRectangle(self.currentBox.x, self.currentBox.y, self.currentBox.width,
-                self.currentBox.height)
+            dc.DrawRectangle(self.currentBox.x * scalex, self.currentBox.y * scaley, 
+                             self.currentBox.width * scalex, self.currentBox.height * scaley)
+        dc.SetUserScale(scalex, scaley)
 
 #-------------------------------------------------------------------------------
 #                               Viewer ToolTip
@@ -506,7 +521,7 @@
     def OnPaint(self, event):
         dc = wx.AutoBufferedPaintDC(self)
         dc.Clear()
-        dc.SetPen(wx.BLACK_PEN)
+        dc.SetPen(MiterPen(wx.BLACK))
         dc.SetBrush(wx.Brush(wx.Colour(255, 238, 170)))
         dc.BeginDrawing()
         w, h = dc.GetTextExtent(self.Tip)
@@ -664,11 +679,13 @@
     
     # Returns the RedrawRect
     def GetRedrawRect(self, movex = 0, movey = 0):
+        dc = self.Parent.GetLogicalDC()
+        scalex, scaley = dc.GetUserScale()
         rect = wx.Rect()
-        rect.x = self.BoundingBox.x - HANDLE_SIZE - 2 - abs(movex)
-        rect.y = self.BoundingBox.y - HANDLE_SIZE - 2 - abs(movey)
-        rect.width = self.BoundingBox.width + 2 * (HANDLE_SIZE + abs(movex)) + 4
-        rect.height = self.BoundingBox.height + 2 * (HANDLE_SIZE + abs(movey)) + 4
+        rect.x = self.BoundingBox.x - int(HANDLE_SIZE / scalex) - 3 - abs(movex)
+        rect.y = self.BoundingBox.y - int(HANDLE_SIZE / scaley) - 3 - abs(movey)
+        rect.width = self.BoundingBox.width + 2 * (int(HANDLE_SIZE / scalex) + abs(movex) + 1) + 4
+        rect.height = self.BoundingBox.height + 2 * (int(HANDLE_SIZE / scaley) + abs(movey) + 1) + 4
         return rect
     
     def Refresh(self, rect = None):
@@ -689,28 +706,40 @@
         self.Refresh()
     
     # Test if the point is on a handle of this element
-    def TestHandle(self, pt):
-        extern_rect = wx.Rect(self.BoundingBox.x - HANDLE_SIZE - 2, self.BoundingBox.y - HANDLE_SIZE - 2, 
-            self.BoundingBox.width + 2 * HANDLE_SIZE + 4, self.BoundingBox.height + 2 * HANDLE_SIZE + 4)
-        intern_rect = wx.Rect(self.BoundingBox.x - 2, self.BoundingBox.y - 2, 
-            self.BoundingBox.width + 4, self.BoundingBox.height + 4)
+    def TestHandle(self, event):
+        dc = self.Parent.GetLogicalDC()
+        scalex, scaley = dc.GetUserScale()
+        pos = event.GetPosition()
+        pt = wx.Point(*self.Parent.CalcUnscrolledPosition(pos.x, pos.y))
+        
+        left = (self.BoundingBox.x - 2) * scalex - HANDLE_SIZE
+        center = (self.BoundingBox.x + self.BoundingBox.width / 2) * scalex - HANDLE_SIZE / 2
+        right = (self.BoundingBox.x + self.BoundingBox.width + 2) * scalex
+        
+        top = (self.BoundingBox.y - 2) * scaley - HANDLE_SIZE
+        middle = (self.BoundingBox.y + self.BoundingBox.height / 2) * scaley - HANDLE_SIZE / 2
+        bottom = (self.BoundingBox.y + self.BoundingBox.height + 2) * scaley
+        
+        extern_rect = wx.Rect(left, top, right + HANDLE_SIZE - left, bottom + HANDLE_SIZE - top)
+        intern_rect = wx.Rect(left + HANDLE_SIZE, top + HANDLE_SIZE, right - left - HANDLE_SIZE, bottom - top - HANDLE_SIZE)
+        
         # Verify that this element is selected
         if self.Selected and extern_rect.InsideXY(pt.x, pt.y) and not intern_rect.InsideXY(pt.x, pt.y):
             # Find if point is on a handle horizontally
-            if self.BoundingBox.x - HANDLE_SIZE - 2 <= pt.x < self.BoundingBox.x - 2:
+            if left <= pt.x < left + HANDLE_SIZE:
                 handle_x = 1
-            elif self.BoundingBox.x + (self.BoundingBox.width - HANDLE_SIZE) / 2 <= pt.x < self.BoundingBox.x + (self.BoundingBox.width + HANDLE_SIZE) / 2:
+            elif center <= pt.x < center + HANDLE_SIZE:
                 handle_x = 2
-            elif self.BoundingBox.x + self.BoundingBox.width + 2 <= pt.x < self.BoundingBox.x + self.BoundingBox.width + HANDLE_SIZE + 2:
+            elif right <= pt.x < right + HANDLE_SIZE:
                 handle_x = 3
             else:
                 handle_x = 0
             # Find if point is on a handle vertically
-            if self.BoundingBox.y - HANDLE_SIZE - 2 <= pt.y < self.BoundingBox.y - 2:
+            if top <= pt.y < top + HANDLE_SIZE:
                 handle_y = 1
-            elif self.BoundingBox.y + (self.BoundingBox.height - HANDLE_SIZE) / 2 <= pt.y < self.BoundingBox.y + (self.BoundingBox.height + HANDLE_SIZE) / 2:
+            elif middle <= pt.y < middle + HANDLE_SIZE:
                 handle_y = 2
-            elif self.BoundingBox.y + self.BoundingBox.height - 2 <= pt.y < self.BoundingBox.y + self.BoundingBox.height + HANDLE_SIZE + 2:
+            elif bottom <= pt.y < bottom + HANDLE_SIZE:
                 handle_y = 3
             else:
                 handle_y = 0
@@ -723,7 +752,7 @@
     def OnLeftDown(self, event, dc, scaling):
         pos = event.GetLogicalPosition(dc)
         # Test if an handle have been clicked
-        handle = self.TestHandle(pos)
+        handle = self.TestHandle(event)
         # Find which type of handle have been clicked,
         # Save a resize event and change the cursor
         cursor = HANDLE_CURSORS.get(handle, 1)
@@ -792,7 +821,7 @@
         # If cursor just pass over the element, changes the cursor if it is on a handle
         else:
             pos = event.GetLogicalPosition(dc)
-            handle = self.TestHandle(pos)
+            handle = self.TestHandle(event)
             # Find which type of handle have been clicked,
             # Save a resize event and change the cursor
             cursor = HANDLE_CURSORS.get(handle, 0)
@@ -914,11 +943,17 @@
     
     # Draws the highlightment of this element if it is highlighted (can be overwritten)
     def DrawHighlightment(self, dc):
-        dc.SetPen(wx.Pen(HIGHLIGHTCOLOR))
+        scalex, scaley = dc.GetUserScale()
+        dc.SetUserScale(1, 1)
+        dc.SetPen(MiterPen(HIGHLIGHTCOLOR))
         dc.SetBrush(wx.Brush(HIGHLIGHTCOLOR))
         dc.SetLogicalFunction(wx.AND)
-        dc.DrawRectangle(self.Pos.x - 2, self.Pos.y - 2, self.Size.width + 5, self.Size.height + 5)
+        dc.DrawRectangle(int(round((self.Pos.x - 1) * scalex)) - 2, 
+                         int(round((self.Pos.y - 1) * scaley)) - 2, 
+                         int(round((self.Size.width + 3) * scalex)) + 5, 
+                         int(round((self.Size.height + 3) * scaley)) + 5)
         dc.SetLogicalFunction(wx.COPY)
+        dc.SetUserScale(scalex, scaley)
     
     # Draws the handles of this element if it is selected
     def Draw(self, dc):
@@ -926,21 +961,25 @@
             if self.Highlighted:
                 self.DrawHighlightment(dc)
             if self.Selected:
-                dc.SetPen(wx.BLACK_PEN)
+                scalex, scaley = dc.GetUserScale()
+                dc.SetUserScale(1, 1)
+                dc.SetPen(MiterPen(wx.BLACK))
                 dc.SetBrush(wx.BLACK_BRUSH)
-                dc.DrawRectangle(self.BoundingBox.x - HANDLE_SIZE - 2, self.BoundingBox.y - HANDLE_SIZE - 2, HANDLE_SIZE, HANDLE_SIZE)
-                dc.DrawRectangle(self.BoundingBox.x + (self.BoundingBox.width - HANDLE_SIZE) / 2,
-                    self.BoundingBox.y - HANDLE_SIZE - 2, HANDLE_SIZE, HANDLE_SIZE)
-                dc.DrawRectangle(self.BoundingBox.x + self.BoundingBox.width + 2, 
-                    self.BoundingBox.y - HANDLE_SIZE - 2, HANDLE_SIZE, HANDLE_SIZE)
-                dc.DrawRectangle(self.BoundingBox.x + self.BoundingBox.width + 2, 
-                    self.BoundingBox.y + (self.BoundingBox.height - HANDLE_SIZE) / 2, HANDLE_SIZE, HANDLE_SIZE)
-                dc.DrawRectangle(self.BoundingBox.x + self.BoundingBox.width + 2, 
-                    self.BoundingBox.y + self.BoundingBox.height + 2, HANDLE_SIZE, HANDLE_SIZE)
-                dc.DrawRectangle(self.BoundingBox.x + (self.BoundingBox.width - HANDLE_SIZE) / 2, 
-                    self.BoundingBox.y + self.BoundingBox.height + 2, HANDLE_SIZE, HANDLE_SIZE)
-                dc.DrawRectangle(self.BoundingBox.x - HANDLE_SIZE - 2, self.BoundingBox.y + self.BoundingBox.height + 2, HANDLE_SIZE, HANDLE_SIZE)
-                dc.DrawRectangle(self.BoundingBox.x - HANDLE_SIZE - 2, self.BoundingBox.y + (self.BoundingBox.height - HANDLE_SIZE) / 2, HANDLE_SIZE, HANDLE_SIZE)
+                
+                left = (self.BoundingBox.x - 2) * scalex - HANDLE_SIZE
+                center = (self.BoundingBox.x + self.BoundingBox.width / 2) * scalex - HANDLE_SIZE / 2
+                right = (self.BoundingBox.x + self.BoundingBox.width + 2) * scalex
+                
+                top = (self.BoundingBox.y - 2) * scaley - HANDLE_SIZE
+                middle = (self.BoundingBox.y + self.BoundingBox.height / 2) * scaley - HANDLE_SIZE / 2
+                bottom = (self.BoundingBox.y + self.BoundingBox.height + 2) * scaley
+                
+                for x, y in [(left, top), (center, top), (right, top),
+                             (left, middle), (right, middle),
+                             (left, bottom), (center, bottom), (right, bottom)]:
+                    dc.DrawRectangle(x, y, HANDLE_SIZE, HANDLE_SIZE)
+                
+                dc.SetUserScale(scalex, scaley)
 
 
 #-------------------------------------------------------------------------------
@@ -1545,26 +1584,28 @@
     
     # Draws the highlightment of this element if it is highlighted
     def DrawHighlightment(self, dc):
-        dc.SetPen(wx.Pen(HIGHLIGHTCOLOR))
+        scalex, scaley = dc.GetUserScale()
+        dc.SetUserScale(1, 1)
+        pen = MiterPen(HIGHLIGHTCOLOR, 2 * scalex + 5)
+        pen.SetCap(wx.CAP_BUTT)
+        dc.SetPen(pen)
         dc.SetBrush(wx.Brush(HIGHLIGHTCOLOR))
         dc.SetLogicalFunction(wx.AND)
         parent_pos = self.ParentBlock.GetPosition()
         posx = parent_pos[0] + self.Pos.x
         posy = parent_pos[1] + self.Pos.y
-        width = CONNECTOR_SIZE
-        height = CONNECTOR_SIZE
+        xstart = parent_pos[0] + self.Pos.x 
+        ystart = parent_pos[1] + self.Pos.y
         if self.Direction[0] < 0:
-            posx += CONNECTOR_SIZE * self.Direction[0]
-        elif self.Direction[0] == 0:
-            posx -= 2
-            width = 5
+            xstart += 1
         if self.Direction[1] < 0:
-            posy += CONNECTOR_SIZE * self.Direction[1]
-        elif self.Direction[1] == 0:
-            posy -= 2
-            height = 5
-        dc.DrawRectangle(posx, posy, width, height)
+            ystart += 1
+        xend = xstart + CONNECTOR_SIZE * self.Direction[0]
+        yend = ystart + CONNECTOR_SIZE * self.Direction[1]
+        dc.DrawLine(round((xstart + self.Direction[0]) * scalex), round((ystart + self.Direction[1]) * scaley), 
+                    round(xend * scalex), round(yend * scaley))
         dc.SetLogicalFunction(wx.COPY)
+        dc.SetUserScale(scalex, scaley)
     
     def AddError(self, infos, start, end):
         if len(infos) == 0:
@@ -1576,25 +1617,25 @@
     # Draws the connector
     def Draw(self, dc):
         if self.Selected:
-            dc.SetPen(wx.Pen(wx.BLUE, 3))
+            dc.SetPen(MiterPen(wx.BLUE, 3))
             dc.SetBrush(wx.WHITE_BRUSH)
         elif len(self.Errors) > 0:
-            dc.SetPen(wx.RED_PEN)
+            dc.SetPen(MiterPen(wx.RED))
             dc.SetBrush(wx.Brush(wx.Colour(255, 255, 0)))
         else:
             if not self.Valid:
-                dc.SetPen(wx.RED_PEN)
+                dc.SetPen(MiterPen(wx.RED))
             elif isinstance(self.Value, BooleanType) and self.Value:
                 if self.Forced:
-                    dc.SetPen(wx.CYAN_PEN)
+                    dc.SetPen(MiterPen(wx.CYAN))
                 else:
-                    dc.SetPen(wx.GREEN_PEN)
+                    dc.SetPen(MiterPen(wx.GREEN))
             elif self.Value == "undefined":
-                dc.SetPen(wx.Pen(wx.NamedColour("orange")))
+                dc.SetPen(MiterPen(wx.NamedColour("orange")))
             elif self.Forced:
-                dc.SetPen(wx.Pen(wx.BLUE))
+                dc.SetPen(MiterPen(wx.BLUE))
             else:
-                dc.SetPen(wx.BLACK_PEN)
+                dc.SetPen(MiterPen(wx.BLACK))
             dc.SetBrush(wx.WHITE_BRUSH)
         parent_pos = self.ParentBlock.GetPosition()
         
@@ -1609,7 +1650,7 @@
             ycenter = parent_pos[1] + self.Pos.y + (CONNECTOR_SIZE * self.Direction[1]) / 2
             dc.DrawCircle(xcenter, ycenter, CONNECTOR_SIZE / 2)
         else:
-            xstart = parent_pos[0] + self.Pos.x
+            xstart = parent_pos[0] + self.Pos.x 
             ystart = parent_pos[1] + self.Pos.y
             if self.Edge == "rising":
                 # If connector has a rising edge, draw a right arrow
@@ -1619,6 +1660,10 @@
                 # If connector has a falling edge, draw a left arrow
                 dc.DrawLine(xstart, ystart, xstart + 4, ystart - 4)
                 dc.DrawLine(xstart, ystart, xstart + 4, ystart + 4)
+            if self.Direction[0] < 0:
+                xstart += 1
+            if self.Direction[1] < 0:
+                ystart += 1
             if self.Selected:
                 xend = xstart + (CONNECTOR_SIZE - 2) * self.Direction[0]
                 yend = ystart + (CONNECTOR_SIZE - 2) * self.Direction[1]
@@ -2699,21 +2744,31 @@
     
     # Draws the highlightment of this element if it is highlighted
     def DrawHighlightment(self, dc):
-        dc.SetPen(wx.Pen(HIGHLIGHTCOLOR))
+        scalex, scaley = dc.GetUserScale()
+        dc.SetUserScale(1, 1)
+        dc.SetPen(MiterPen(HIGHLIGHTCOLOR, (2 * scalex + 5)))
         dc.SetBrush(wx.Brush(HIGHLIGHTCOLOR))
         dc.SetLogicalFunction(wx.AND)
         # Draw the start and end points if they are not connected or the mouse is over them
         if len(self.Points) > 0 and (not self.StartConnected or self.OverStart):
-            dc.DrawCircle(self.Points[0].x, self.Points[0].y, POINT_RADIUS + 2)
+            dc.DrawCircle(round(self.Points[0].x * scalex), 
+                          round(self.Points[0].y * scaley), 
+                          (POINT_RADIUS + 1) * scalex + 2)
         if len(self.Points) > 1 and (not self.EndConnected or self.OverEnd):
-            dc.DrawCircle(self.Points[-1].x, self.Points[-1].y, POINT_RADIUS + 2)
-        for i in xrange(len(self.Points) - 1):
-            posx = min(self.Points[i].x, self.Points[i + 1].x) - 2
-            posy = min(self.Points[i].y, self.Points[i + 1].y) - 2
-            width = abs(self.Points[i + 1].x - self.Points[i].x) + 5
-            height = abs(self.Points[i + 1].y - self.Points[i].y) + 5
-            dc.DrawRectangle(posx, posy, width, height)
+            dc.DrawCircle(self.Points[-1].x * scalex, self.Points[-1].y * scaley, (POINT_RADIUS + 1) * scalex + 2)
+        # Draw the wire lines and the last point (it seems that DrawLines stop before the last point)
+        if len(self.Points) > 1:
+            points = [wx.Point(round((self.Points[0].x - self.Segments[0][0]) * scalex), 
+                               round((self.Points[0].y - self.Segments[0][1]) * scaley))]
+            points.extend([wx.Point(round(point.x * scalex), round(point.y * scaley)) for point in self.Points[1:-1]])
+            points.append(wx.Point(round((self.Points[-1].x + self.Segments[-1][0]) * scalex), 
+                                   round((self.Points[-1].y + self.Segments[-1][1]) * scaley)))
+        else:
+            points = []
+        dc.DrawLines(points)
         dc.SetLogicalFunction(wx.COPY)
+        dc.SetUserScale(scalex, scaley)
+        
         if self.StartConnected is not None:
             self.StartConnected.DrawHighlightment(dc)
             self.StartConnected.Draw(dc)
@@ -2725,23 +2780,23 @@
     def Draw(self, dc):
         Graphic_Element.Draw(self, dc)
         if not self.Valid:
-            dc.SetPen(wx.RED_PEN)
+            dc.SetPen(MiterPen(wx.RED))
             dc.SetBrush(wx.RED_BRUSH)
         elif isinstance(self.Value, BooleanType) and self.Value:
             if self.Forced:
-                dc.SetPen(wx.CYAN_PEN)
+                dc.SetPen(MiterPen(wx.CYAN))
                 dc.SetBrush(wx.CYAN_BRUSH)
             else:
-                dc.SetPen(wx.GREEN_PEN)
+                dc.SetPen(MiterPen(wx.GREEN))
                 dc.SetBrush(wx.GREEN_BRUSH)
         elif self.Value == "undefined":
-            dc.SetPen(wx.Pen(wx.NamedColour("orange")))
+            dc.SetPen(MiterPen(wx.NamedColour("orange")))
             dc.SetBrush(wx.Brush(wx.NamedColour("orange")))
         elif self.Forced:
-            dc.SetPen(wx.Pen(wx.BLUE))
+            dc.SetPen(MiterPen(wx.BLUE))
             dc.SetBrush(wx.BLUE_BRUSH)
         else:
-            dc.SetPen(wx.BLACK_PEN)
+            dc.SetPen(MiterPen(wx.BLACK))
             dc.SetBrush(wx.BLACK_BRUSH)
         # Draw the start and end points if they are not connected or the mouse is over them
         if len(self.Points) > 0 and (not self.StartConnected or self.OverStart):
@@ -2749,11 +2804,16 @@
         if len(self.Points) > 1 and (not self.EndConnected or self.OverEnd):
             dc.DrawCircle(self.Points[-1].x, self.Points[-1].y, POINT_RADIUS)
         # Draw the wire lines and the last point (it seems that DrawLines stop before the last point)
-        dc.DrawLines(self.Points)
-        dc.DrawPoint(self.Points[-1].x, self.Points[-1].y)
+        if len(self.Points) > 1:
+            points = [wx.Point(self.Points[0].x - self.Segments[0][0], self.Points[0].y - self.Segments[0][1])]
+            points.extend([point for point in self.Points[1:-1]])
+            points.append(wx.Point(self.Points[-1].x + self.Segments[-1][0], self.Points[-1].y + self.Segments[-1][1]))
+        else:
+            points = []
+        dc.DrawLines(points)
         # Draw the segment selected in red
         if not getattr(dc, "printing", False) and self.SelectedSegment is not None:
-            dc.SetPen(wx.Pen(wx.BLUE, 3))
+            dc.SetPen(MiterPen(wx.BLUE, 3))
             if self.SelectedSegment == len(self.Segments) - 1:
                 end = 0
             else:
@@ -2900,21 +2960,31 @@
     
     # Draws the highlightment of this element if it is highlighted
     def DrawHighlightment(self, dc):
-        dc.SetPen(wx.Pen(HIGHLIGHTCOLOR))
+        scalex, scaley = dc.GetUserScale()
+        dc.SetUserScale(1, 1)
+        dc.SetPen(MiterPen(HIGHLIGHTCOLOR))
         dc.SetBrush(wx.Brush(HIGHLIGHTCOLOR))
         dc.SetLogicalFunction(wx.AND)
-        polygon = [wx.Point(self.Pos.x - 2, self.Pos.y - 2), 
-                   wx.Point(self.Pos.x + self.Size[0] - 8, self.Pos.y - 2),
-                   wx.Point(self.Pos.x + self.Size[0] + 2, self.Pos.y + 8),
-                   wx.Point(self.Pos.x + self.Size[0] + 2, self.Pos.y + self.Size[1] + 2),
-                   wx.Point(self.Pos.x - 2, self.Pos.y + self.Size[1] + 2)]
+        
+        left = (self.Pos.x - 1) * scalex - 2
+        right = (self.Pos.x + self.Size[0] + 1) * scalex + 2
+        top = (self.Pos.y - 1) * scaley - 2
+        bottom = (self.Pos.y + self.Size[1] + 1) * scaley + 2
+        angle_top = (self.Pos.x + self.Size[0] - 9) * scalex + 2
+        angle_right = (self.Pos.y + 9) * scaley - 2
+        
+        polygon = [wx.Point(left, top), wx.Point(angle_top, top),
+                   wx.Point(right, angle_right), wx.Point(right, bottom),
+                   wx.Point(left, bottom)]
         dc.DrawPolygon(polygon)
+        
         dc.SetLogicalFunction(wx.COPY)
+        dc.SetUserScale(scalex, scaley)
         
     # Draws the comment and its content
     def Draw(self, dc):
         Graphic_Element.Draw(self, dc)
-        dc.SetPen(wx.BLACK_PEN)
+        dc.SetPen(MiterPen(wx.BLACK))
         dc.SetBrush(wx.WHITE_BRUSH)
         # Draws the comment shape
         polygon = [wx.Point(self.Pos.x, self.Pos.y), 
--- a/graphics/LD_Objects.py	Thu Sep 22 10:56:52 2011 +0200
+++ b/graphics/LD_Objects.py	Thu Sep 22 15:33:31 2011 +0200
@@ -324,7 +324,7 @@
     # Draws power rail
     def Draw(self, dc):
         Graphic_Element.Draw(self, dc)
-        dc.SetPen(wx.BLACK_PEN)
+        dc.SetPen(MiterPen(wx.BLACK))
         dc.SetBrush(wx.BLACK_BRUSH)
         # Draw a rectangle with the power rail size
         if self.Type == LEFTRAIL:
@@ -578,13 +578,22 @@
     
     # Draws the highlightment of this element if it is highlighted
     def DrawHighlightment(self, dc):
-        dc.SetPen(wx.Pen(HIGHLIGHTCOLOR))
+        scalex, scaley = dc.GetUserScale()
+        dc.SetUserScale(1, 1)
+        dc.SetPen(MiterPen(HIGHLIGHTCOLOR))
         dc.SetBrush(wx.Brush(HIGHLIGHTCOLOR))
         dc.SetLogicalFunction(wx.AND)
         # Draw two rectangles for representing the contact
-        dc.DrawRectangle(self.Pos.x - 2, self.Pos.y - 2, 6, self.Size[1] + 5)
-        dc.DrawRectangle(self.Pos.x + self.Size[0] - 3, self.Pos.y - 2, 6, self.Size[1] + 5)
+        left_left = (self.Pos.x - 1) * scalex - 2
+        right_left = (self.Pos.x + self.Size[0] - 2) * scalex - 2
+        top = (self.Pos.y - 1) * scaley - 2
+        width = 4 * scalex + 5
+        height = (self.Size[1] + 3) * scaley + 5
+        
+        dc.DrawRectangle(left_left, top, width, height)
+        dc.DrawRectangle(right_left, top, width, height)
         dc.SetLogicalFunction(wx.COPY)
+        dc.SetUserScale(scalex, scaley)
     
     def AddError(self, infos, start, end):
         self.Errors[infos[0]] = (start[1], end[1])
@@ -598,15 +607,15 @@
                self.Type == CONTACT_RISING and self.Value and not self.PreviousValue or \
                self.Type == CONTACT_RISING and not self.Value and self.PreviousValue:
                 if self.Forced:
-                    dc.SetPen(wx.CYAN_PEN)
+                    dc.SetPen(MiterPen(wx.CYAN))
                 else:
-                    dc.SetPen(wx.GREEN_PEN)
+                    dc.SetPen(MiterPen(wx.GREEN))
             elif self.Forced:
-                dc.SetPen(wx.Pen(wx.BLUE))
+                dc.SetPen(MiterPen(wx.BLUE))
             else:
-                dc.SetPen(wx.BLACK_PEN)
-        else:
-            dc.SetPen(wx.BLACK_PEN)
+                dc.SetPen(MiterPen(wx.BLACK))
+        else:
+            dc.SetPen(MiterPen(wx.BLACK))
         dc.SetBrush(wx.BLACK_BRUSH)
         
         # Compiling contact type modifier symbol
@@ -863,13 +872,24 @@
     
     # Draws the highlightment of this element if it is highlighted
     def DrawHighlightment(self, dc):
-        dc.SetPen(wx.Pen(HIGHLIGHTCOLOR, 6, wx.SOLID))
+        scalex, scaley = dc.GetUserScale()
+        dc.SetUserScale(1, 1)
+        dc.SetPen(MiterPen(HIGHLIGHTCOLOR, (3 * scalex + 5), wx.SOLID))
         dc.SetBrush(wx.TRANSPARENT_BRUSH)
         dc.SetLogicalFunction(wx.AND)
         # Draw a two circle arcs for representing the coil
-        dc.DrawEllipticArc(self.Pos.x, self.Pos.y - int(self.Size[1] * (sqrt(2) - 1.) / 2.) + 1, self.Size[0], int(self.Size[1] * sqrt(2)) - 1, 135, 225)
-        dc.DrawEllipticArc(self.Pos.x, self.Pos.y - int(self.Size[1] * (sqrt(2) - 1.) / 2.) + 1, self.Size[0], int(self.Size[1] * sqrt(2)) - 1, -45, 45)
+        dc.DrawEllipticArc(round(self.Pos.x * scalex), 
+                           round((self.Pos.y - int(self.Size[1] * (sqrt(2) - 1.) / 2.) + 1) * scaley), 
+                           round(self.Size[0] * scalex), 
+                           round((int(self.Size[1] * sqrt(2)) - 1) * scaley),
+                           135, 225)
+        dc.DrawEllipticArc(round(self.Pos.x * scalex), 
+                           round((self.Pos.y - int(self.Size[1] * (sqrt(2) - 1.) / 2.) + 1) * scaley), 
+                           round(self.Size[0] * scalex), 
+                           round((int(self.Size[1] * sqrt(2)) - 1) * scaley),
+                           -45, 45)
         dc.SetLogicalFunction(wx.COPY)
+        dc.SetUserScale(scalex, scaley)
     
     def AddError(self, infos, start, end):
         self.Errors[infos[0]] = (start[1], end[1])
@@ -878,9 +898,9 @@
     def Draw(self, dc):
         Graphic_Element.Draw(self, dc)
         if self.Value is not None and self.Value:
-            dc.SetPen(wx.Pen(wx.GREEN, 2, wx.SOLID))
-        else:
-            dc.SetPen(wx.Pen(wx.BLACK, 2, wx.SOLID))
+            dc.SetPen(MiterPen(wx.GREEN, 2, wx.SOLID))
+        else:
+            dc.SetPen(MiterPen(wx.BLACK, 2, wx.SOLID))
         dc.SetBrush(wx.TRANSPARENT_BRUSH)
         
         # Compiling coil type modifier symbol 
@@ -914,9 +934,9 @@
             # Draw a point to avoid hole in left arc
             if not getattr(dc, "printing", False):
                 if self.Value is not None and self.Value:
-                    dc.SetPen(wx.GREEN_PEN)
+                    dc.SetPen(MiterPen(wx.GREEN))
                 else:
-                    dc.SetPen(wx.BLACK_PEN)
+                    dc.SetPen(MiterPen(wx.BLACK))
                 dc.DrawPoint(self.Pos.x + 1, self.Pos.y + self.Size[1] / 2 + 1)
             name_size = self.NameSize
             if typetext != "":
--- a/graphics/SFC_Objects.py	Thu Sep 22 10:56:52 2011 +0200
+++ b/graphics/SFC_Objects.py	Thu Sep 22 15:33:31 2011 +0200
@@ -522,13 +522,13 @@
         Graphic_Element.Draw(self, dc)
         if self.Value:
             if self.Forced:
-                dc.SetPen(wx.CYAN_PEN)
+                dc.SetPen(MiterPen(wx.CYAN))
             else:
-                dc.SetPen(wx.GREEN_PEN)
+                dc.SetPen(MiterPen(wx.GREEN))
         elif self.Forced:
-            dc.SetPen(wx.Pen(wx.BLUE))
-        else:
-            dc.SetPen(wx.BLACK_PEN)
+            dc.SetPen(MiterPen(wx.BLUE))
+        else:
+            dc.SetPen(MiterPen(wx.BLACK))
         dc.SetBrush(wx.WHITE_BRUSH)
         
         if getattr(dc, "printing", False):
@@ -938,16 +938,16 @@
         Graphic_Element.Draw(self, dc)
         if self.Value:
             if self.Forced:
-                dc.SetPen(wx.CYAN_PEN)
+                dc.SetPen(MiterPen(wx.CYAN))
                 dc.SetBrush(wx.CYAN_BRUSH)
             else:
-                dc.SetPen(wx.GREEN_PEN)
+                dc.SetPen(MiterPen(wx.GREEN))
                 dc.SetBrush(wx.GREEN_BRUSH)
         elif self.Forced:
-            dc.SetPen(wx.Pen(wx.BLUE))
+            dc.SetPen(MiterPen(wx.BLUE))
             dc.SetBrush(wx.BLUE_BRUSH)
         else:
-            dc.SetPen(wx.BLACK_PEN)
+            dc.SetPen(MiterPen(wx.BLACK))
             dc.SetBrush(wx.BLACK_BRUSH)
         
         if getattr(dc, "printing", False):
@@ -1416,26 +1416,32 @@
     
     # Draws the highlightment of this element if it is highlighted
     def DrawHighlightment(self, dc):
-        dc.SetPen(wx.Pen(HIGHLIGHTCOLOR))
+        scalex, scaley = dc.GetUserScale()
+        dc.SetUserScale(1, 1)
+        dc.SetPen(MiterPen(HIGHLIGHTCOLOR))
         dc.SetBrush(wx.Brush(HIGHLIGHTCOLOR))
         dc.SetLogicalFunction(wx.AND)
         # Draw two rectangles for representing the contact
-        posx = self.Pos.x - 2
-        width = self.Size[0] + 5
+        posx = self.Pos.x
+        width = self.Size[0]
         if self.Type in [SIMULTANEOUS_DIVERGENCE, SIMULTANEOUS_CONVERGENCE]:
             posx -= SFC_SIMULTANEOUS_SEQUENCE_EXTRA
             width += SFC_SIMULTANEOUS_SEQUENCE_EXTRA * 2
-        dc.DrawRectangle(posx, self.Pos.y - 2, width, self.Size[1] + 5)
+        dc.DrawRectangle(int(round((posx - 1) * scalex)) - 2, 
+                         int(round((self.Pos.y - 1) * scaley)) - 2, 
+                         int(round((width + 3) * scalex)) + 5, 
+                         int(round((self.Size.height + 3) * scaley)) + 5)
         dc.SetLogicalFunction(wx.COPY)
+        dc.SetUserScale(scalex, scaley)
         
     # Draws divergence
     def Draw(self, dc):
         Graphic_Element.Draw(self, dc)
         if self.Value:
-            dc.SetPen(wx.GREEN_PEN)
+            dc.SetPen(MiterPen(wx.GREEN))
             dc.SetBrush(wx.GREEN_BRUSH)
         else:
-            dc.SetPen(wx.BLACK_PEN)
+            dc.SetPen(MiterPen(wx.BLACK))
             dc.SetBrush(wx.BLACK_BRUSH)
         # Draw plain rectangle for representing the divergence
         if self.Type in [SELECTION_DIVERGENCE, SELECTION_CONVERGENCE]:
@@ -1659,23 +1665,29 @@
     
     # Draws the highlightment of this element if it is highlighted
     def DrawHighlightment(self, dc):
-        dc.SetPen(wx.Pen(HIGHLIGHTCOLOR))
+        scalex, scaley = dc.GetUserScale()
+        dc.SetUserScale(1, 1)
+        dc.SetPen(MiterPen(HIGHLIGHTCOLOR))
         dc.SetBrush(wx.Brush(HIGHLIGHTCOLOR))
         dc.SetLogicalFunction(wx.AND)
-        points = [wx.Point(self.Pos.x - 3, self.Pos.y - 2),
-                  wx.Point(self.Pos.x + self.Size[0] + 4, self.Pos.y - 2),
-                  wx.Point(self.Pos.x + self.Size[0] / 2, self.Pos.y + self.Size[1] + 4)]
+        points = [wx.Point(int(round((self.Pos.x - 2) * scalex)) - 3, 
+                           int(round((self.Pos.y - 2) * scaley)) - 2),
+                  wx.Point(int(round((self.Pos.x + self.Size[0] + 2) * scalex)) + 4, 
+                           int(round((self.Pos.y - 2) * scaley)) - 2),
+                  wx.Point(int(round((self.Pos.x + self.Size[0] / 2) * scalex)), 
+                           int(round((self.Pos.y + self.Size[1] + 3) * scaley)) + 4)]
         dc.DrawPolygon(points)
         dc.SetLogicalFunction(wx.COPY)
+        dc.SetUserScale(scalex, scaley)
     
     # Draws divergence
     def Draw(self, dc):
         Graphic_Element.Draw(self, dc)
         if self.Value:
-            dc.SetPen(wx.GREEN_PEN)
+            dc.SetPen(MiterPen(wx.GREEN))
             dc.SetBrush(wx.GREEN_BRUSH)
         else:
-            dc.SetPen(wx.BLACK_PEN)
+            dc.SetPen(MiterPen(wx.BLACK))
             dc.SetBrush(wx.BLACK_BRUSH)
         
         if getattr(dc, "printing", False):
@@ -1914,9 +1926,9 @@
     def Draw(self, dc):
         Graphic_Element.Draw(self, dc)
         if self.Value:
-            dc.SetPen(wx.GREEN_PEN)
-        else:
-            dc.SetPen(wx.BLACK_PEN)
+            dc.SetPen(MiterPen(wx.GREEN))
+        else:
+            dc.SetPen(MiterPen(wx.BLACK))
         dc.SetBrush(wx.WHITE_BRUSH)
         colsize = [self.ColSize[0], self.Size[0] - self.ColSize[0] - self.ColSize[2], self.ColSize[2]]
         # Draw plain rectangle for representing the action block