Exemplo n.º 1
0
 def followMarquee (self, event):
     """Follows the mouse during a marquee selection."""
     if event.LeftIsDown():
         # dragRect is what is drawn onscreen
         # it is in unscrolled coordinates
         
         self.oldDirtyRect = self.dragRect
         self.dragCurrent = event.GetPosition()
         self.dragRect = rectmath.pointsToRect(self.dragOrigin, self.dragCurrent)
                      
         # select all enclosed widgets
         
         logicalOrigin = self.toLogical(self.CalcUnscrolledPosition(self.dragRect.x, self.dragRect.y), scaleOnly = True)
         logicalSize = self.toLogical((self.dragRect.width, self.dragRect.height), scaleOnly = True)
         logicalRect = wx.Rect(logicalOrigin[0], logicalOrigin[1], logicalSize[0], logicalSize[1])
         print "logicalRect is ", logicalRect
                     
         for widget in self.widgets:
             print "checking against ", widget.getLogicalRect()
             widget.setSelected(widget.intersects(logicalRect), False)
         
         self.oldDirtyRect.Inflate(2, 2)   # don't know exactly why, but sometimes we're off by 1
         self.Refresh(True, self.oldDirtyRect)
     else:
         self.draggingMarquee = False
                     
         # clear event handlers
         
         self.Bind(wx.EVT_MOUSE_EVENTS, None)
         self.ReleaseMouse()            
         self.Refresh()
Exemplo n.º 2
0
 def startMarquee (self, event):
     """Starts a marquee selection."""
     if not self.draggingMarquee:
         self.draggingMarquee = True
         self.dragOrigin = event.GetPosition()
         self.dragCurrent = event.GetPosition()
         self.dragRect = rectmath.pointsToRect(self.dragOrigin, self.dragOrigin)
         
         # deselect everything
         
         map(lambda w: w.setSelected(False, False), self.widgets)
         
         # grab mouse focus
         
         self.Bind(wx.EVT_MOUSE_EVENTS, self.followMarquee)
         self.CaptureMouse()
         self.Refresh()