]> git.saurik.com Git - wxWidgets.git/blobdiff - wxPython/demo/wxDragImage.py
Reorganized listctrl demo a bit so I can test a bug report
[wxWidgets.git] / wxPython / demo / wxDragImage.py
index d4124ae7fd8a519bb92be9c84b18b3a8475c4ff9..7ab24df8b9107650e9da5cde04498bdadebef7b6 100644 (file)
@@ -64,18 +64,19 @@ class DragCanvas(wxScrolledWindow):
 
         # Make a shape from some text
         text = "Some Text"
+        bg_colour = wxColour(57, 115, 57)  # matches the bg image
         font = wxFont(15, wxROMAN, wxNORMAL, wxBOLD)
         textExtent = self.GetFullTextExtent(text, font)
         bmp = wxEmptyBitmap(textExtent[0], textExtent[1])
         dc = wxMemoryDC()
         dc.SelectObject(bmp)
+        dc.SetBackground(wxBrush(bg_colour, wxSOLID))
         dc.Clear()
         dc.SetTextForeground(wxRED)
         dc.SetFont(font)
         dc.DrawText(text, 0, 0)
         dc.SelectObject(wxNullBitmap)
-        del dc
-        mask = wxMaskColour(bmp, wxWHITE)
+        mask = wxMaskColour(bmp, bg_colour)
         bmp.SetMask(mask)
         shape = DragShape(bmp)
         shape.pos = wxPoint(5, 100)
@@ -99,8 +100,12 @@ class DragCanvas(wxScrolledWindow):
         EVT_LEFT_DOWN(self, self.OnLeftDown)
         EVT_LEFT_UP(self, self.OnLeftUp)
         EVT_MOTION(self, self.OnMotion)
+        EVT_LEAVE_WINDOW(self, self.OnLeaveWindow)
 
 
+    def OnLeaveWindow(self, evt):
+        pass
+
 
     def TileBackground(self, dc):
         # tile the background bitmap
@@ -138,12 +143,12 @@ class DragCanvas(wxScrolledWindow):
         dc.DestroyClippingRegion()
 
 
-
-
     def OnEraseBackground(self, evt):
         dc = evt.GetDC()
         if not dc:
             dc = wxClientDC(self)
+            rect = self.GetUpdateRegion().GetBox()
+            dc.SetClippingRegion(rect.x, rect.y, rect.width, rect.height)
         self.TileBackground(dc)
 
 
@@ -257,7 +262,10 @@ class DragCanvas(wxScrolledWindow):
 #----------------------------------------------------------------------
 
 def runTest(frame, nb, log):
-    win = DragCanvas(nb, -1)
+    win = wxPanel(nb, -1)
+    canvas = DragCanvas(win, -1)
+    def onSize(evt, panel=win, canvas=canvas): canvas.SetSize(panel.GetSize())
+    EVT_SIZE(win, onSize)
     return win
 
 #----------------------------------------------------------------------