Removing flickering on Windows
authorlbessard
Fri, 25 Jan 2008 17:30:49 +0100
changeset 155 b695f7459ef6
parent 154 203c4acdaf27
child 156 2a2e974302fe
Removing flickering on Windows
LDViewer.py
SFCViewer.py
Viewer.py
graphics/GraphicCommons.py
--- a/LDViewer.py	Wed Jan 23 18:26:49 2008 +0100
+++ b/LDViewer.py	Fri Jan 25 17:30:49 2008 +0100
@@ -435,7 +435,7 @@
                         self.SelectedElement.Delete()
                 self.RefreshBuffer()
                 self.RefreshScrollBars()
-                self.Refresh()
+                self.Refresh(False)
             elif keycode == wx.WXK_LEFT:
                 if event.ControlDown() and event.ShiftDown():
                     self.Scroll(0, ypos)
@@ -540,7 +540,7 @@
             self.Rungs.append(rung)
             self.RefreshBuffer()
             self.RefreshScrollBars()
-            self.Refresh()
+            self.Refresh(False)
 
     def AddLadderContact(self):
         wires = []
@@ -633,7 +633,7 @@
                 self.RefreshRungs(new_bbox.height - old_bbox.height, rungindex + 1)
                 self.RefreshBuffer()
                 self.RefreshScrollBars()
-                self.Refresh()
+                self.Refresh(False)
         else:
             message = wx.MessageDialog(self, "You must select the wire where a contact should be added!", "Error", wx.OK|wx.ICON_ERROR)
             message.ShowModal()
@@ -854,7 +854,7 @@
                 self.RefreshRungs(new_bbox.height - old_bbox.height, rungindex + 1)
                 self.RefreshBuffer()
                 self.RefreshScrollBars()
-                self.Refresh()
+                self.Refresh(False)
             else:
                 message = wx.MessageDialog(self, "The group of block must be coherent!", "Error", wx.OK|wx.ICON_ERROR)
                 message.ShowModal()
--- a/SFCViewer.py	Wed Jan 23 18:26:49 2008 +0100
+++ b/SFCViewer.py	Fri Jan 25 17:30:49 2008 +0100
@@ -281,7 +281,7 @@
             Viewer.OnViewerLeftDClick(self, event)
         elif self.Mode == MODE_SELECTION and self.SelectedElement:
             self.SelectedElement.OnLeftDClick(event, self.GetLogicalDC(), self.Scaling)
-            self.Refresh()
+            self.Refresh(False)
         event.Skip()
     
     def OnViewerMotion(self, event):
@@ -320,7 +320,7 @@
             self.SelectedElement = None
             self.RefreshBuffer()
             self.RefreshScrollBars()
-            self.Refresh()
+            self.Refresh(False)
         elif keycode == wx.WXK_LEFT:
             if event.ControlDown() and event.ShiftDown():
                 self.Scroll(0, ypos)
@@ -331,7 +331,7 @@
                 self.SelectedElement.RefreshModel()
                 self.RefreshBuffer()
                 self.RefreshScrollBars()
-                self.RefreshRect(self.GetScrolledRect(self.SelectedElement.GetRedrawRect(-scaling[0], 0)))
+                self.RefreshRect(self.GetScrolledRect(self.SelectedElement.GetRedrawRect(-scaling[0], 0)), False)
         elif keycode == wx.WXK_RIGHT:
             if event.ControlDown() and event.ShiftDown():
                 self.Scroll(xmax, ypos)
@@ -342,7 +342,7 @@
                 self.SelectedElement.RefreshModel()
                 self.RefreshBuffer()
                 self.RefreshScrollBars()
-                self.RefreshRect(self.GetScrolledRect(self.SelectedElement.GetRedrawRect(scaling[0], 0)))
+                self.RefreshRect(self.GetScrolledRect(self.SelectedElement.GetRedrawRect(scaling[0], 0)), False)
         elif keycode == wx.WXK_UP:
             if event.ControlDown() and event.ShiftDown():
                 self.Scroll(xpos, 0)
@@ -353,7 +353,7 @@
                 self.SelectedElement.RefreshModel()
                 self.RefreshBuffer()
                 self.RefreshScrollBars()
-                self.RefreshRect(self.GetScrolledRect(self.SelectedElement.GetRedrawRect(0, -scaling[1])))
+                self.RefreshRect(self.GetScrolledRect(self.SelectedElement.GetRedrawRect(0, -scaling[1])), False)
         elif keycode == wx.WXK_DOWN:
             if event.ControlDown() and event.ShiftDown():
                 self.Scroll(xpos, ymax)
@@ -364,7 +364,7 @@
                 self.SelectedElement.RefreshModel()
                 self.RefreshBuffer()
                 self.RefreshScrollBars()
-                self.RefreshRect(self.GetScrolledRect(self.SelectedElement.GetRedrawRect(0, scaling[1])))
+                self.RefreshRect(self.GetScrolledRect(self.SelectedElement.GetRedrawRect(0, scaling[1])), False)
         else:
             event.Skip()
         
@@ -390,7 +390,7 @@
             self.RefreshStepModel(step)
             self.RefreshBuffer()
             self.RefreshScrollBars()
-            self.Refresh()
+            self.Refresh(False)
         dialog.Destroy()
 
     def AddStep(self):
@@ -444,7 +444,7 @@
                     self.SelectedElement.SetSelected(True)
                 self.RefreshBuffer()
                 self.RefreshScrollBars()
-                self.Refresh()
+                self.Refresh(False)
             dialog.Destroy()
     
     def AddStepAction(self):
@@ -473,7 +473,7 @@
                     self.RefreshActionBlockModel(actionblock)
                     self.RefreshBuffer()
                     self.RefreshScrollBars()
-                    self.Refresh()
+                    self.Refresh(False)
                 dialog.Destroy()
     
     def AddDivergence(self):
@@ -669,7 +669,7 @@
                         self.CreateStep("Step", previous)
                 self.RefreshBuffer()
                 self.RefreshScrollBars()
-                self.Refresh()
+                self.Refresh(False)
             dialog.Destroy()
     
     def AddDivergenceBranch(self, divergence):
@@ -690,7 +690,7 @@
                     step = self.CreateStep("Step", previous)
             self.RefreshBuffer()
             self.RefreshScrollBars()
-            self.Refresh()
+            self.Refresh(False)
     
     def RemoveDivergenceBranch(self, divergence):
         if isinstance(divergence, SFC_Divergence):
@@ -698,7 +698,7 @@
                 divergence.RemoveHandledBranch()
                 self.RefreshBuffer()
                 self.RefreshScrollBars()
-                self.Refresh()
+                self.Refresh(False)
     
     def AddJump(self):
         if isinstance(self.SelectedElement, SFC_Step) and not self.SelectedElement.Output:
@@ -727,7 +727,7 @@
                 self.RefreshJumpModel(jump)
                 self.RefreshBuffer()
                 self.RefreshScrollBars()
-                self.Refresh()
+                self.Refresh(False)
             dialog.Destroy()
 
     def EditStepContent(self, step):
@@ -747,7 +747,7 @@
                 step.RefreshModel()
                 self.RefreshBuffer()
                 self.RefreshScrollBars()
-                self.Refresh()
+                self.Refresh(False)
             dialog.Destroy()
 
 #-------------------------------------------------------------------------------
--- a/Viewer.py	Wed Jan 23 18:26:49 2008 +0100
+++ b/Viewer.py	Fri Jan 25 17:30:49 2008 +0100
@@ -111,7 +111,7 @@
                 self.ParentWindow.RefreshBuffer()
                 self.ParentWindow.RefreshScrollBars()
                 self.ParentWindow.ParentWindow.RefreshVariablePanel(self.ParentWindow.GetTagName())
-                self.ParentWindow.Refresh()
+                self.ParentWindow.Refresh(False)
         elif values[1] != "location":
             if values[3] == self.ParentWindow.GetTagName():
                 id = self.ParentWindow.GetNewId()
@@ -135,7 +135,7 @@
                 self.ParentWindow.RefreshVariableModel(variable)
                 self.ParentWindow.RefreshBuffer()
                 self.ParentWindow.RefreshScrollBars()
-                self.ParentWindow.Refresh()
+                self.ParentWindow.Refresh(False)
             else:
                 message = wx.MessageDialog(self.ParentWindow, "Variable don't belong to this POU!", "Error", wx.OK|wx.ICON_ERROR)
                 message.ShowModal()
@@ -458,7 +458,7 @@
             self.Scaling = None
             self.GridBrush = wx.TRANSPARENT_BRUSH
         if refresh:
-            self.Refresh()
+            self.Refresh(False)
         
         
 #-------------------------------------------------------------------------------
@@ -490,7 +490,7 @@
         for wire in to_delete:
             wire.Delete()
     
-        self.Refresh()
+        self.Refresh(False)
     
     def RefreshScrollBars(self):
         xstart, ystart = self.GetViewStart()
@@ -919,42 +919,42 @@
         if self.SelectedElement and isinstance(self.SelectedElement, Graphic_Group):
             self.SelectedElement.AlignElements(ALIGN_LEFT, None)
             self.RefreshBuffer()
-            self.Refresh()
+            self.Refresh(False)
         event.Skip()
     
     def OnAlignCenterMenu(self, event):
         if self.SelectedElement and isinstance(self.SelectedElement, Graphic_Group):
             self.SelectedElement.AlignElements(ALIGN_CENTER, None)
             self.RefreshBuffer()
-            self.Refresh()
+            self.Refresh(False)
         event.Skip()
     
     def OnAlignRightMenu(self, event):
         if self.SelectedElement and isinstance(self.SelectedElement, Graphic_Group):
             self.SelectedElement.AlignElements(ALIGN_RIGHT, None)
             self.RefreshBuffer()
-            self.Refresh()
+            self.Refresh(False)
         event.Skip()
     
     def OnAlignTopMenu(self, event):
         if self.SelectedElement and isinstance(self.SelectedElement, Graphic_Group):
             self.SelectedElement.AlignElements(None, ALIGN_TOP)
             self.RefreshBuffer()
-            self.Refresh()
+            self.Refresh(False)
         event.Skip()
     
     def OnAlignMiddleMenu(self, event):
         if self.SelectedElement and isinstance(self.SelectedElement, Graphic_Group):
             self.SelectedElement.AlignElements(None, ALIGN_MIDDLE)
             self.RefreshBuffer()
-            self.Refresh()
+            self.Refresh(False)
         event.Skip()
     
     def OnAlignBottomMenu(self, event):
         if self.SelectedElement and isinstance(self.SelectedElement, Graphic_Group):
             self.SelectedElement.AlignElements(None, ALIGN_BOTTOM)
             self.RefreshBuffer()
-            self.Refresh()
+            self.Refresh(False)
         event.Skip()
         
     def OnNoModifierMenu(self, event):
@@ -1073,7 +1073,7 @@
                         self.SelectedElement.Delete()
                         self.SelectedElement = None
                         element = None
-                        self.RefreshRect(self.GetScrolledRect(rect))
+                        self.RefreshRect(self.GetScrolledRect(rect), False)
                 elif connector:
                     self.DrawingWire = True
                     pos = GetScaledEventPosition(event, self.GetLogicalDC(), self.Scaling)
@@ -1174,7 +1174,7 @@
                     rect = self.SelectedElement.GetRedrawRect()
                     self.SelectedElement.Delete()
                     self.SelectedElement = None
-                    self.RefreshRect(self.GetScrolledRect(rect))
+                    self.RefreshRect(self.GetScrolledRect(rect), False)
             else:
                 self.SelectedElement.OnLeftUp(event, dc, self.Scaling)
                 wx.CallAfter(self.SetCursor, wx.NullCursor)
@@ -1237,11 +1237,11 @@
                     movex, movey = self.SelectedElement.OnMotion(event, dc, self.Scaling)
                     self.SelectedElement.GeneratePoints()
                     if movex != 0 or movey != 0:
-                        self.RefreshRect(self.GetScrolledRect(self.SelectedElement.GetRedrawRect(movex, movey)))
+                        self.RefreshRect(self.GetScrolledRect(self.SelectedElement.GetRedrawRect(movex, movey)), False)
             else:
                 movex, movey = self.SelectedElement.OnMotion(event, dc, self.Scaling)
                 if movex != 0 or movey != 0:
-                    self.RefreshRect(self.GetScrolledRect(self.SelectedElement.GetRedrawRect(movex, movey)))
+                    self.RefreshRect(self.GetScrolledRect(self.SelectedElement.GetRedrawRect(movex, movey)), False)
         self.UpdateScrollPos(event)
         event.Skip()
 
@@ -1291,7 +1291,7 @@
             self.RefreshBuffer()
             self.RefreshScrollBars()
             self.SetCursor(wx.NullCursor)
-            self.RefreshRect(self.GetScrolledRect(rect))
+            self.RefreshRect(self.GetScrolledRect(rect), False)
         elif keycode == wx.WXK_RETURN and self.SelectedElement:
             self.SelectedElement.OnLeftDClick(event, self.GetLogicalDC(), self.Scaling)
         elif keycode == wx.WXK_LEFT:
@@ -1304,7 +1304,7 @@
                 self.SelectedElement.RefreshModel()
                 self.RefreshBuffer()
                 self.RefreshScrollBars()
-                self.RefreshRect(self.GetScrolledRect(self.SelectedElement.GetRedrawRect(-scaling[0], 0)))
+                self.RefreshRect(self.GetScrolledRect(self.SelectedElement.GetRedrawRect(-scaling[0], 0)), False)
         elif keycode == wx.WXK_RIGHT:
             if event.ControlDown() and event.ShiftDown():
                 self.Scroll(xmax, ypos)
@@ -1315,7 +1315,7 @@
                 self.SelectedElement.RefreshModel()
                 self.RefreshBuffer()
                 self.RefreshScrollBars()
-                self.RefreshRect(self.GetScrolledRect(self.SelectedElement.GetRedrawRect(scaling[0], 0)))
+                self.RefreshRect(self.GetScrolledRect(self.SelectedElement.GetRedrawRect(scaling[0], 0)), False)
         elif keycode == wx.WXK_UP:
             if event.ControlDown() and event.ShiftDown():
                 self.Scroll(xpos, 0)
@@ -1326,7 +1326,7 @@
                 self.SelectedElement.RefreshModel()
                 self.RefreshBuffer()
                 self.RefreshScrollBars()
-                self.RefreshRect(self.GetScrolledRect(self.SelectedElement.GetRedrawRect(0, -scaling[1])))
+                self.RefreshRect(self.GetScrolledRect(self.SelectedElement.GetRedrawRect(0, -scaling[1])), False)
         elif keycode == wx.WXK_DOWN:
             if event.ControlDown() and event.ShiftDown():
                 self.Scroll(xpos, ymax)
@@ -1337,7 +1337,7 @@
                 self.SelectedElement.RefreshModel()
                 self.RefreshBuffer()
                 self.RefreshScrollBars()
-                self.RefreshRect(self.GetScrolledRect(self.SelectedElement.GetRedrawRect(0, scaling[1])))
+                self.RefreshRect(self.GetScrolledRect(self.SelectedElement.GetRedrawRect(0, scaling[1])), False)
         elif keycode == wx.WXK_SPACE and self.SelectedElement is not None and self.SelectedElement.Dragging:
             self.CopyBlock(self.SelectedElement, wx.Point(*self.SelectedElement.GetPosition()))
             self.RefreshBuffer()
@@ -2168,7 +2168,7 @@
             self.SelectedElement = None
             self.RefreshBuffer()
             self.RefreshScrollBars()
-            self.RefreshRect(self.GetScrolledRect(rect))
+            self.RefreshRect(self.GetScrolledRect(rect), False)
         
     def Copy(self):
         if self.IsBlock(self.SelectedElement):
--- a/graphics/GraphicCommons.py	Wed Jan 23 18:26:49 2008 +0100
+++ b/graphics/GraphicCommons.py	Fri Jan 25 17:30:49 2008 +0100
@@ -380,9 +380,9 @@
     
     def Refresh(self, rect = None):
         if rect is not None:
-            self.Parent.RefreshRect(self.Parent.GetScrolledRect(rect))
-        else:
-            self.Parent.RefreshRect(self.Parent.GetScrolledRect(self.GetRedrawRect()))
+            self.Parent.RefreshRect(self.Parent.GetScrolledRect(rect), False)
+        else:
+            self.Parent.RefreshRect(self.Parent.GetScrolledRect(self.GetRedrawRect()), False)
     
     # Change the variable that indicates if this element is selected
     def SetSelected(self, selected):
@@ -1876,7 +1876,7 @@
             self.GeneratePoints()
             self.RefreshModel()
             self.Parent.RefreshBuffer()
-            self.Parent.RefreshRect(self.Parent.GetScrolledRect(rect))
+            self.Parent.RefreshRect(self.Parent.GetScrolledRect(rect), False)
         
     # Method called when a Motion event has been generated
     def OnMotion(self, event, dc, scaling):