]> git.saurik.com Git - wxWidgets.git/blobdiff - wxPython/demo/CustomDragAndDrop.py
To use "#pragma warning" a #ifdef __VISUALC__ guard should be used, not a #ifdef...
[wxWidgets.git] / wxPython / demo / CustomDragAndDrop.py
index fcb094728724782ccd01e427bb921dc4f73abf45..34570e1cf896722b3b15901c499985384dddbdcc 100644 (file)
@@ -46,7 +46,7 @@ class DoodlePad(wx.Window):
         dc.SetPen(wx.Pen(wx.BLUE, 3))
         for line in self.lines:
             for coords in line:
-                dc.DrawLineXY(*coords)
+                dc.DrawLine(*coords)
         dc.EndDrawing()
 
 
@@ -63,22 +63,23 @@ class DoodlePad(wx.Window):
 
 
     def OnLeftUp(self, event):
-        self.lines.append(self.curLine)
-        self.curLine = []
-        self.ReleaseMouse()
+        if self.HasCapture():
+            self.lines.append(self.curLine)
+            self.curLine = []
+            self.ReleaseMouse()
 
     def OnRightUp(self, event):
         self.lines = []
         self.Refresh()
 
     def OnMotion(self, event):
-        if event.Dragging() and not self.mode == "Drag":
+        if self.HasCapture() and event.Dragging() and not self.mode == "Drag":
             dc = wx.ClientDC(self)
             dc.BeginDrawing()
             dc.SetPen(wx.Pen(wx.BLUE, 3))
-            coords = ((self.x, self.y), event.GetPosition())
+            coords = ((self.x, self.y), event.GetPositionTuple())
             self.curLine.append(coords)
-            dc.DrawLineXY(*coords)
+            dc.DrawLine(*coords)
             self.x, self.y = event.GetPositionTuple()
             dc.EndDrawing()
 
@@ -171,7 +172,7 @@ class DoodleDropTarget(wx.PyDropTarget):
         if self.GetData():
             # convert it back to a list of lines and give it to the viewer
             linesdata = self.data.GetData()
-            lines = wx.InputStream(cPickle.loads(linesdata))
+            lines = cPickle.loads(linesdata)
             self.dv.SetLines(lines)
             
         # what is returned signals the source what to do
@@ -207,7 +208,7 @@ class DoodleViewer(wx.Window):
 
         for line in self.lines:
             for coords in line:
-                dc.DrawLineXY(*coords)
+                dc.DrawLine(*coords)
         dc.EndDrawing()
 
 #----------------------------------------------------------------------