@@ -1819,35 +1819,42 @@ def remove_rubberband(self):
18191819
18201820else :
18211821 # on Mac OS retina displays DCOverlay does not work
1822+ # and dc.SetLogicalFunction does not have an effect on any display
1823+ # the workaround is to blit the full image for remove_rubberband
18221824 class RubberbandWx (backend_tools .RubberbandBase ):
18231825 def __init__ (self , * args , ** kwargs ):
18241826 backend_tools .RubberbandBase .__init__ (self , * args , ** kwargs )
18251827 self ._rect = None
18261828
1827- def remove_rubberband (self ):
1828- self .draw_rubberband (None ,None ,None ,None ,False )
1829-
1830- def draw_rubberband (self , x0 , y0 , x1 , y1 , draw_new = True ):
1831-
1829+ def draw_rubberband (self , x0 , y0 , x1 , y1 ):
18321830 dc = wx .ClientDC (self .canvas )
18331831 # this would be required if the Canvas is a ScrolledWindow,
18341832 # which is not the case for now
1835- # self.PrepareDC(_dc)
1836-
1833+ # self.PrepareDC(dc)
1834+
1835+ # delete old rubberband
1836+ if self ._rect : self .remove_rubberband (dc )
1837+
1838+ # draw new rubberband
18371839 dc .SetPen (wx .Pen (wx .BLACK , 1 , wx .SOLID ))
1838- dc .SetLogicalFunction (wx .INVERT )
18391840 dc .SetBrush (wx .TRANSPARENT_BRUSH )
1840-
1841- if self ._rect :
1842- dc .DrawRectangle (self ._rect )
1843-
1844- if draw_new :
1845- self ._rect = (x0 ,self .canvas ._height - y0 , x1 - x0 , - y1 + y0 )
1841+ self ._rect = (x0 ,self .canvas ._height - y0 , x1 - x0 , - y1 + y0 )
1842+ if wxc .is_phoenix :
18461843 dc .DrawRectangle (self ._rect )
18471844 else :
1848- self ._rect = None
1849-
1850- dc .SetLogicalFunction (wx .COPY )
1845+ dc .DrawRectangleRect (self ._rect )
1846+
1847+ def remove_rubberband (self , dc = None ):
1848+ if not self ._rect : return
1849+ if self .canvas .bitmap :
1850+ if dc is None :
1851+ dc = wx .ClientDC (self .canvas )
1852+ dc .DrawBitmap (self .canvas .bitmap , 0 , 0 )
1853+ # for testing the method on Windows, use this code instead:
1854+ #img = self.canvas.bitmap.ConvertToImage()
1855+ #bmp = img.ConvertToBitmap()
1856+ #dc.DrawBitmap(bmp, 0, 0)
1857+ self ._rect = None
18511858
18521859
18531860backend_tools .ToolSaveFigure = SaveFigureWx
0 commit comments