Viewer.py
changeset 165 e464a4e4e06d
parent 162 e746ff4aa8be
child 169 393193e7590a
--- a/Viewer.py	Wed Jan 30 09:52:57 2008 +0100
+++ b/Viewer.py	Wed Jan 30 18:48:05 2008 +0100
@@ -315,14 +315,15 @@
         self.SetDropTarget(ViewerDropTarget(self))
         
         dc = wx.ClientDC(self)
-        self.Font = wx.Font(faces["size"], wx.DEFAULT, wx.NORMAL, wx.NORMAL, faceName = faces["mono"])
-        dc.SetFont(self.Font)
+        font = wx.Font(faces["size"], wx.DEFAULT, wx.NORMAL, wx.NORMAL, faceName = faces["mono"])
+        dc.SetFont(font)
         width, height = dc.GetTextExtent("ABCDEFGHIJKLMNOPQRSTUVWXYZ")
         while width > 260:
             faces["size"] -= 1
-            self.Font = wx.Font(faces["size"], wx.DEFAULT, wx.NORMAL, wx.NORMAL, faceName = faces["mono"])
-            dc.SetFont(self.Font)
+            font = wx.Font(faces["size"], wx.DEFAULT, wx.NORMAL, wx.NORMAL, faceName = faces["mono"])
+            dc.SetFont(font)
             width, height = dc.GetTextExtent("ABCDEFGHIJKLMNOPQRSTUVWXYZ")
+        self.SetFont(font)
         
         # Link Viewer event to corresponding methods
         self.Bind(wx.EVT_PAINT, self.OnPaint)
@@ -367,7 +368,7 @@
             dc = wx.BufferedPaintDC(self)
         else:
             dc = wx.ClientDC(self)
-        dc.SetFont(self.Font)
+        dc.SetFont(self.GetFont())
         if wx.VERSION >= (2, 6, 0):
             self.DoPrepareDC(dc)
         else:
@@ -1105,7 +1106,7 @@
                         wire = Wire(self, [wx.Point(pos.x, pos.y), WEST], [wx.Point(pos.x, pos.y), EAST])
                     wire.oldPos = pos
                     wire.Handle = (HANDLE_POINT, 0)
-                    wire.ProcessDragging(0, 0, self.Scaling)
+                    wire.ProcessDragging(0, 0, False, self.Scaling)
                     wire.Handle = (HANDLE_POINT, 1)
                     self.AddWire(wire)
                     if self.SelectedElement:
@@ -1381,6 +1382,7 @@
 
     def AddNewBlock(self, bbox):
         dialog = BlockPropertiesDialog(self.ParentWindow)
+        dialog.SetPreviewFont(self.GetFont())
         dialog.SetBlockList(self.Controler.GetBlockTypes(self.TagName))
         dialog.SetPouNames(self.Controler.GetProjectPouNames())
         dialog.SetPouElementNames(self.Controler.GetEditedElementVariables(self.TagName))
@@ -1405,6 +1407,7 @@
     
     def AddNewVariable(self, bbox):
         dialog = VariablePropertiesDialog(self.ParentWindow)
+        dialog.SetPreviewFont(self.GetFont())
         dialog.SetMinVariableSize((bbox.width, bbox.height))
         varlist = []
         vars = self.Controler.GetEditedElementInterfaceVars(self.TagName)
@@ -1432,6 +1435,7 @@
 
     def AddNewConnection(self, bbox):
         dialog = ConnectionPropertiesDialog(self.ParentWindow)
+        dialog.SetPreviewFont(self.GetFont())
         dialog.SetMinConnectionSize((bbox.width, bbox.height))
         if dialog.ShowModal() == wx.ID_OK:
             id = self.GetNewId()
@@ -1469,6 +1473,7 @@
 
     def AddNewContact(self, bbox):
         dialog = LDElementDialog(self.ParentWindow, "contact")
+        dialog.SetPreviewFont(self.GetFont())
         varlist = []
         vars = self.Controler.GetEditedElementInterfaceVars(self.TagName)
         if vars:
@@ -1494,6 +1499,7 @@
 
     def AddNewCoil(self, bbox):
         dialog = LDElementDialog(self.ParentWindow, "coil")
+        dialog.SetPreviewFont(self.GetFont())
         varlist = []
         vars = self.Controler.GetEditedElementInterfaceVars(self.TagName)
         if vars:
@@ -1522,6 +1528,7 @@
 
     def AddNewPowerRail(self, bbox):
         dialog = LDPowerRailDialog(self.ParentWindow)
+        dialog.SetPreviewFont(self.GetFont())
         dialog.SetMinSize((bbox.width, bbox.height))
         if dialog.ShowModal() == wx.ID_OK:
             id = self.GetNewId()
@@ -1539,6 +1546,7 @@
 
     def AddNewStep(self, bbox, initial = False):
         dialog = StepContentDialog(self.ParentWindow, initial)
+        dialog.SetPreviewFont(self.GetFont())
         dialog.SetPouNames(self.Controler.GetProjectPouNames())
         dialog.SetVariables(self.Controler.GetEditedElementInterfaceVars(self.TagName))
         dialog.SetStepNames([block.GetName() for block in self.Blocks if isinstance(block, SFC_Step)])
@@ -1572,6 +1580,7 @@
 
     def AddNewTransition(self, bbox):
         dialog = TransitionContentDialog(self.ParentWindow, self.GetDrawingMode() == FREEDRAWING_MODE)
+        dialog.SetPreviewFont(self.GetFont())
         dialog.SetTransitions(self.Controler.GetEditedElementTransitions(self.TagName))
         if dialog.ShowModal() == wx.ID_OK:
             id = self.GetNewId()
@@ -1590,6 +1599,7 @@
 
     def AddNewDivergence(self, bbox):
         dialog = DivergenceCreateDialog(self.ParentWindow)
+        dialog.SetPreviewFont(self.GetFont())
         dialog.SetMinSize((bbox.width, bbox.height))
         if dialog.ShowModal() == wx.ID_OK:
             id = self.GetNewId()
@@ -1653,6 +1663,7 @@
 
     def EditBlockContent(self, block):
         dialog = BlockPropertiesDialog(self.ParentWindow)
+        dialog.SetPreviewFont(self.GetFont())
         dialog.SetBlockList(self.Controler.GetBlockTypes(self.TagName))
         dialog.SetPouNames(self.Controler.GetProjectPouNames())
         variable_names = self.Controler.GetEditedElementVariables(self.TagName)
@@ -1685,6 +1696,7 @@
 
     def EditVariableContent(self, variable):
         dialog = VariablePropertiesDialog(self.ParentWindow)
+        dialog.SetPreviewFont(self.GetFont())
         dialog.SetMinVariableSize(variable.GetSize())
         varlist = []
         vars = self.Controler.GetEditedElementInterfaceVars(self.TagName)
@@ -1721,6 +1733,7 @@
 
     def EditConnectionContent(self, connection):
         dialog = ConnectionPropertiesDialog(self.ParentWindow)
+        dialog.SetPreviewFont(self.GetFont())
         dialog.SetMinConnectionSize(connection.GetSize())
         values = {"name" : connection.GetName(), "type" : connection.GetType()}
         dialog.SetValues(values)
@@ -1744,6 +1757,7 @@
 
     def EditContactContent(self, contact):
         dialog = LDElementDialog(self.ParentWindow, "contact")
+        dialog.SetPreviewFont(self.GetFont())
         varlist = []
         vars = self.Controler.GetEditedElementInterfaceVars(self.TagName)
         if vars:
@@ -1769,6 +1783,7 @@
 
     def EditCoilContent(self, coil):
         dialog = LDElementDialog(self.ParentWindow, "coil")
+        dialog.SetPreviewFont(self.GetFont())
         varlist = []
         vars = self.Controler.GetEditedElementInterfaceVars(self.TagName)
         if vars:
@@ -1797,6 +1812,7 @@
 
     def EditPowerRailContent(self, powerrail):
         dialog = LDPowerRailDialog(self.ParentWindow, powerrail.GetType(), len(powerrail.GetConnectors()))
+        dialog.SetPreviewFont(self.GetFont())
         dialog.SetMinSize(powerrail.GetSize())
         if dialog.ShowModal() == wx.ID_OK:
             old_type = powerrail.GetType()
@@ -1817,6 +1833,7 @@
 
     def EditStepContent(self, step):
         dialog = StepContentDialog(self.ParentWindow, step.GetInitial())
+        dialog.SetPreviewFont(self.GetFont())
         dialog.SetPouNames(self.Controler.GetProjectPouNames())
         dialog.SetVariables(self.Controler.GetEditedElementInterfaceVars(self.TagName))
         dialog.SetStepNames([block.GetName() for block in self.Blocks if isinstance(block, SFC_Step) and block.GetName() != step.GetName()])
@@ -1852,6 +1869,7 @@
         
     def EditTransitionContent(self, transition):
         dialog = TransitionContentDialog(self.ParentWindow, self.GetDrawingMode() == FREEDRAWING_MODE)
+        dialog.SetPreviewFont(self.GetFont())
         dialog.SetTransitions(self.Controler.GetEditedElementTransitions(self.TagName))
         dialog.SetValues({"type":transition.GetType(),"value":transition.GetCondition(), "priority":transition.GetPriority()})
         dialog.SetElementSize(transition.GetSize())