]> git.saurik.com Git - wxWidgets.git/blobdiff - samples/dragimag/dragimag.h
fix sizing of extra control
[wxWidgets.git] / samples / dragimag / dragimag.h
index bba436184e012217b8ed73961884ab877130fc0e..e70fc5faf56e416ad1523c7f11b5c155a1711e4f 100644 (file)
@@ -46,6 +46,7 @@ class MyApp: public wxApp
 public:
     MyApp();
     virtual bool OnInit();
+    virtual int OnExit();
 
 //// Operations
 
@@ -122,12 +123,12 @@ class DragShape: public wxObject
 {
 public:
     DragShape(const wxBitmap& bitmap);
-    ~DragShape();
+    ~DragShape(){};
 
 //// Operations
 
     bool HitTest(const wxPoint& pt) const;
-    bool Draw(wxDC& dc, int op = wxCOPY);
+    bool Draw(wxDC& dc, bool highlight = false);
 
 //// Accessors
 
@@ -152,5 +153,39 @@ protected:
     bool        m_show;
 };
 
+// MyDragImage
+// A derived class is required since we're overriding UpdateBackingFromWindow,
+// for compatibility with Mac OS X (Core Graphics) which does not support blitting
+// from a window.
+
+class MyDragImage: public wxDragImage
+{
+public:
+    MyDragImage(MyCanvas* canvas): m_canvas(canvas) {}
+
+    MyDragImage(MyCanvas* canvas, const wxBitmap& image, const wxCursor& cursor = wxNullCursor):
+        wxDragImage(image, cursor), m_canvas(canvas)
+    {
+    }
+
+    MyDragImage(MyCanvas* canvas, const wxIcon& image, const wxCursor& cursor = wxNullCursor):
+        wxDragImage(image, cursor), m_canvas(canvas)
+    {
+    }
+
+    MyDragImage(MyCanvas* canvas, const wxString& str, const wxCursor& cursor = wxNullCursor):
+        wxDragImage(str, cursor), m_canvas(canvas)
+    {
+    }
+
+    // On some platforms, notably Mac OS X with Core Graphics, we can't blit from
+    // a window, so we need to draw the background explicitly.
+    virtual bool UpdateBackingFromWindow(wxDC& windowDC, wxMemoryDC& destDC, const wxRect& sourceRect,
+                    const wxRect& destRect) const;
+
+protected:
+    MyCanvas*   m_canvas;
+};
+
 #endif
     // _WX_DRAGIMAGSAMPLE_