graphics/RubberBand.py
branchwxPython4
changeset 3306 841fb2ee1213
parent 3303 0ffb41625592
child 3746 41be039fbb8c
--- a/graphics/RubberBand.py	Sun Sep 05 05:03:36 2021 +0200
+++ b/graphics/RubberBand.py	Sun Sep 05 05:43:17 2021 +0200
@@ -195,3 +195,25 @@
         """
         # Erase last bbox and draw current bbox
         self.DrawBoundingBoxes([self.CurrentBBox], dc)
+
+
+def PatchRubberBandForGTK3():
+    """
+    GTK3 implementation of DC doesn't support SetLogicalFuntion(XOR)
+    Then Rubberband can't be erased by just redrawing it on the same place
+    So this is a complete refresh instead, eating a lot of CPU.
+    """
+    def Redraw(self, dc=None):
+        self.Viewer.Refresh()
+        self.Draw()
+
+    RubberBand.Redraw = Redraw
+
+    def Erase(self, dc=None):
+        self.Viewer.Refresh()
+
+    RubberBand.Erase = Erase
+
+
+if "gtk3" in wx.PlatformInfo:
+    PatchRubberBandForGTK3()