]> git.saurik.com Git - wxWidgets.git/commitdiff
get rid of the built-in drop target in rich text controls before setting the user...
authorVadim Zeitlin <vadim@wxwidgets.org>
Sat, 15 Sep 2007 01:09:01 +0000 (01:09 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Sat, 15 Sep 2007 01:09:01 +0000 (01:09 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@48704 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

include/wx/msw/textctrl.h
src/msw/textctrl.cpp

index 09dc91bd0dcc3dfa3a6030108492220fb65791db..a56a3ff7d67cf95f69daee965203fb10283f2b84 100644 (file)
@@ -139,6 +139,10 @@ public:
 
     // Implementation from now on
     // --------------------------
+#if wxUSE_DRAG_AND_DROP && wxUSE_RICHEDIT
+    virtual void SetDropTarget(wxDropTarget *dropTarget);
+#endif // wxUSE_DRAG_AND_DROP && wxUSE_RICHEDIT
 
     virtual void SetWindowStyleFlag(long style);
 
index 97c0559a8b0d4a428c7d17dcca8c81719bb865ed..c40ef670da9f22893cce2e2d6bbe1774cce2d24b 100644 (file)
 
 #include "wx/msw/missing.h"
 
+#if wxUSE_DRAG_AND_DROP && wxUSE_RICHEDIT
+
+// dummy value used for m_dropTarget, different from any valid pointer value
+// (which are all even under Windows) and NULL
+static wxDropTarget *
+    wxRICHTEXT_DEFAULT_DROPTARGET = wx_reinterpret_cast(wxDropTarget *, 1);
+
+#endif // wxUSE_DRAG_AND_DROP && wxUSE_RICHEDIT
+
 // ----------------------------------------------------------------------------
 // private classes
 // ----------------------------------------------------------------------------
@@ -308,6 +317,20 @@ bool wxTextCtrl::Create(wxWindow *parent,
     if ( !MSWCreateText(value, pos, size) )
         return false;
 
+#if wxUSE_DRAG_AND_DROP && wxUSE_RICHEDIT
+    if ( IsRich() )
+    {
+        // rich text controls have a default associated drop target which
+        // allows them to receive (rich) text dropped on them, which is nice,
+        // but prevents us from associating a user-defined drop target with
+        // them as we need to unregister the old one first
+        //
+        // to make it work, we set m_dropTarget to this special value initially
+        // and check for it in our SetDropTarget()
+        m_dropTarget = wxRICHTEXT_DEFAULT_DROPTARGET;
+    }
+#endif // wxUSE_DRAG_AND_DROP && wxUSE_RICHEDIT
+
     return true;
 }
 
@@ -2405,6 +2428,22 @@ bool wxTextCtrl::MSWOnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result)
     return wxTextCtrlBase::MSWOnNotify(idCtrl, lParam, result);
 }
 
+#if wxUSE_DRAG_AND_DROP
+
+void wxTextCtrl::SetDropTarget(wxDropTarget *dropTarget)
+{
+    if ( m_dropTarget == wxRICHTEXT_DEFAULT_DROPTARGET )
+    {
+        // get rid of the built-in drop target
+        ::RevokeDragDrop(GetHwnd());
+        m_dropTarget = NULL;
+    }
+
+    wxTextCtrlBase::SetDropTarget(dropTarget);
+}
+
+#endif // wxUSE_DRAG_AND_DROP
+
 // ----------------------------------------------------------------------------
 // colour setting for the rich edit controls
 // ----------------------------------------------------------------------------