+ def OnClickBox(self, evt):
+ box = self.boxes[evt.GetId()]
+ # Collapse/restore static box, change label
+ self.ShowGroup(box.gnum, not box.show)
+ if box.show: box.SetLabel('[+] ' + box.name)
+ else: box.SetLabel('[-] ' + box.name)
+ self.Layout()
+
+ # DaD
+ def OnLeftDownOnButton(self, evt):
+ self.posDown = evt.GetPosition()
+ self.idDown = evt.GetId()
+ self.btnDown = evt.GetEventObject()
+ evt.Skip()
+
+ def OnMotionOnButton(self, evt):
+ # Detect dragging
+ if evt.Dragging() and evt.LeftIsDown():
+ d = evt.GetPosition() - self.posDown
+ if max(abs(d[0]), abs(d[1])) >= 5:
+ if self.btnDown.HasCapture():
+ # Generate up event to release mouse
+ evt = wx.MouseEvent(wx.EVT_LEFT_UP.typeId)
+ evt.SetId(self.idDown)
+ # Set flag to prevent normal button operation this time
+ self.drag = True
+ self.btnDown.ProcessEvent(evt)
+ self.StartDrag()
+ evt.Skip()
+
+ def StartDrag(self):
+ do = MyDataObject()
+ do.SetData(str(self.idDown))
+ bm = self.btnDown.GetBitmapLabel()
+ # wxGTK requires wxIcon cursor, wxWIN and wxMAC require wxCursor
+ if wx.Platform == '__WXGTK__':
+ icon = wx.EmptyIcon()
+ icon.CopyFromBitmap(bm)
+ dragSource = wx.DropSource(self, icon)
+ else:
+ curs = wx.CursorFromImage(wx.ImageFromBitmap(bm))
+ dragSource = wx.DropSource(self, curs)
+ dragSource.SetData(do)
+ g.frame.SetStatusText('Release the mouse button over the test window')
+ dragSource.DoDragDrop()
+