diff --git a/include/wx/dataview.h b/include/wx/dataview.h index 624fbc3526..9023e66e33 100644 --- a/include/wx/dataview.h +++ b/include/wx/dataview.h @@ -535,10 +535,6 @@ private: // wxDataViewCtrlBase // --------------------------------------------------------- -#if wxUSE_DRAG_AND_DROP -WX_DEFINE_ARRAY(wxDataFormat,wxDataFormatArray); -#endif - #define wxDV_SINGLE 0x0000 // for convenience #define wxDV_MULTIPLE 0x0001 // can select multiple items @@ -765,18 +761,18 @@ public: virtual bool EnableDragSource(const wxDataFormat& WXUNUSED(format)) { return false; } - bool EnableDropTarget(const wxDataFormatArray& formats) + bool EnableDropTargets(const wxVector& formats) { return DoEnableDropTarget(formats); } bool EnableDropTarget(const wxDataFormat& format) { - wxDataFormatArray formats; + wxVector formats; if (format.GetType() != wxDF_INVALID) { - formats.Add(format); + formats.push_back(format); } - return EnableDropTarget(formats); + return DoEnableDropTarget(formats); } #endif // wxUSE_DRAG_AND_DROP @@ -810,9 +806,9 @@ protected: virtual void DoSetIndent() = 0; #if wxUSE_DRAG_AND_DROP - virtual wxDataObject* CreateDataObject(const wxDataFormatArray& formats); + virtual wxDataObject* CreateDataObject(const wxVector& formats); - virtual bool DoEnableDropTarget(const wxDataFormatArray& WXUNUSED(formats)) + virtual bool DoEnableDropTarget(const wxVector& WXUNUSED(formats)) { return false; } #endif // wxUSE_DRAG_AND_DROP diff --git a/include/wx/generic/dataview.h b/include/wx/generic/dataview.h index f8636336d8..5ebdd1c56e 100644 --- a/include/wx/generic/dataview.h +++ b/include/wx/generic/dataview.h @@ -284,7 +284,7 @@ public: #if wxUSE_DRAG_AND_DROP virtual bool EnableDragSource( const wxDataFormat &format ) wxOVERRIDE; - virtual bool DoEnableDropTarget(const wxDataFormatArray& formats) wxOVERRIDE; + virtual bool DoEnableDropTarget(const wxVector& formats) wxOVERRIDE; #endif // wxUSE_DRAG_AND_DROP virtual wxBorder GetDefaultBorder() const wxOVERRIDE; diff --git a/include/wx/gtk/dataview.h b/include/wx/gtk/dataview.h index 718ae843c4..0d76d0ad96 100644 --- a/include/wx/gtk/dataview.h +++ b/include/wx/gtk/dataview.h @@ -166,7 +166,7 @@ public: virtual bool IsExpanded( const wxDataViewItem & item ) const wxOVERRIDE; virtual bool EnableDragSource( const wxDataFormat &format ) wxOVERRIDE; - virtual bool DoEnableDropTarget( const wxDataFormatArray& formats ) wxOVERRIDE; + virtual bool DoEnableDropTarget( const wxVector& formats ) wxOVERRIDE; virtual wxDataViewColumn *GetCurrentColumn() const wxOVERRIDE; diff --git a/include/wx/osx/dataview.h b/include/wx/osx/dataview.h index 6a3e2197ec..0838c9b5ae 100644 --- a/include/wx/osx/dataview.h +++ b/include/wx/osx/dataview.h @@ -209,7 +209,7 @@ public: virtual void EditItem(const wxDataViewItem& item, const wxDataViewColumn *column) wxOVERRIDE; #if wxUSE_DRAG_AND_DROP - virtual bool DoEnableDropTarget( const wxDataFormatArray& formats ) wxOVERRIDE; + virtual bool DoEnableDropTarget( const wxVector& formats ) wxOVERRIDE; #endif // wxUSE_DRAG_AND_DROP // returns the n-th pointer to a column; diff --git a/include/wx/qt/dataview.h b/include/wx/qt/dataview.h index a8b51ab7d2..6ae9022db8 100644 --- a/include/wx/qt/dataview.h +++ b/include/wx/qt/dataview.h @@ -119,7 +119,7 @@ public: virtual bool IsExpanded( const wxDataViewItem & item ) const; virtual bool EnableDragSource( const wxDataFormat &format ); - virtual bool DoEnableDropTarget( const wxDataFormatArray& formats ) wxOVERRIDE; + virtual bool DoEnableDropTarget( const wxVector& formats ); static wxVisualAttributes GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL); diff --git a/interface/wx/dataview.h b/interface/wx/dataview.h index b6edf7fdd9..468cb5ec22 100644 --- a/interface/wx/dataview.h +++ b/interface/wx/dataview.h @@ -1390,7 +1390,7 @@ public: virtual bool EnableDragSource( const wxDataFormat &format ); /** - Enable drop operations for each @a format from passed array. + Enable drop operations using any of the specified @a formats. Currently this is fully implemented in the generic and native macOS versions. In wxGTK only the first element of the array is used. @@ -1399,12 +1399,12 @@ public: @since 3.1.6 */ - bool EnableDropTarget(const wxDataFormatArray& formats); + bool EnableDropTargets(const wxVector& formats); /** Enable drop operations using the given @a format. - See the overload above for providing more than one supported format. + See EnableDropTargets() for providing more than one supported format. @note Since 3.1.6 wxDF_INVALID can be passed to disable drag and drop support. */ diff --git a/src/common/datavcmn.cpp b/src/common/datavcmn.cpp index 2dc19c1285..f1691311ff 100644 --- a/src/common/datavcmn.cpp +++ b/src/common/datavcmn.cpp @@ -1690,17 +1690,17 @@ void wxDataViewCtrlBase::StartEditor(const wxDataViewItem& item, unsigned int co #if wxUSE_DRAG_AND_DROP -wxDataObject* wxDataViewCtrlBase::CreateDataObject(const wxDataFormatArray& formats) +wxDataObject* wxDataViewCtrlBase::CreateDataObject(const wxVector& formats) { - if (formats.GetCount() == 0) + if (formats.empty()) { return NULL; } wxDataObjectComposite *dataObject(new wxDataObjectComposite); - for (size_t i = 0; i < formats.GetCount(); ++i) + for (size_t i = 0; i < formats.size(); ++i) { - switch (formats.Item(i).GetType()) + switch (formats[i].GetType()) { case wxDF_TEXT: case wxDF_OEMTEXT: @@ -1733,7 +1733,7 @@ wxDataObject* wxDataViewCtrlBase::CreateDataObject(const wxDataFormatArray& form case wxDF_ENHMETAFILE: case wxDF_LOCALE: case wxDF_PRIVATE: - dataObject->Add(new wxCustomDataObject(formats.Item(i))); + dataObject->Add(new wxCustomDataObject(formats[i])); break; case wxDF_INVALID: diff --git a/src/generic/datavgen.cpp b/src/generic/datavgen.cpp index 2568a72fba..b14f69ac94 100644 --- a/src/generic/datavgen.cpp +++ b/src/generic/datavgen.cpp @@ -5801,7 +5801,7 @@ bool wxDataViewCtrl::EnableDragSource( const wxDataFormat &format ) return m_clientArea->EnableDragSource( format ); } -bool wxDataViewCtrl::DoEnableDropTarget( const wxDataFormatArray &formats ) +bool wxDataViewCtrl::DoEnableDropTarget( const wxVector &formats ) { wxDataViewDropTarget* dt = NULL; if (wxDataObject* dataObject = CreateDataObject(formats)) diff --git a/src/gtk/dataview.cpp b/src/gtk/dataview.cpp index 48b871272d..813b4f9b7b 100644 --- a/src/gtk/dataview.cpp +++ b/src/gtk/dataview.cpp @@ -211,7 +211,7 @@ public: // dnd iface bool EnableDragSource( const wxDataFormat &format ); - bool EnableDropTarget( const wxDataFormatArray &formats ); + bool EnableDropTarget( const wxVector &formats ); gboolean row_draggable( GtkTreeDragSource *drag_source, GtkTreePath *path ); gboolean drag_data_delete( GtkTreeDragSource *drag_source, GtkTreePath* path ); @@ -3794,16 +3794,17 @@ bool wxDataViewCtrlInternal::EnableDragSource( const wxDataFormat &format ) return true; } -bool wxDataViewCtrlInternal::EnableDropTarget( const wxDataFormatArray& formats ) +bool wxDataViewCtrlInternal::EnableDropTarget( const wxVector& formats ) { - if (formats.GetCount() == 0) + if (formats.empty()) { gtk_tree_view_unset_rows_drag_dest(GTK_TREE_VIEW(m_owner->GtkGetTreeView())); return true; } - wxGtkString atom_str( gdk_atom_name( formats.Item(0) ) ); + // TODO: Use all formats, not just the first one. + wxGtkString atom_str( gdk_atom_name( formats[0] ) ); m_dropTargetTargetEntryTarget = wxCharBuffer( atom_str ); m_dropTargetTargetEntry.target = m_dropTargetTargetEntryTarget.data(); @@ -4929,7 +4930,7 @@ bool wxDataViewCtrl::EnableDragSource( const wxDataFormat &format ) return m_internal->EnableDragSource( format ); } -bool wxDataViewCtrl::DoEnableDropTarget( const wxDataFormatArray& formats ) +bool wxDataViewCtrl::DoEnableDropTarget( const wxVector& formats ) { wxCHECK_MSG( m_internal, false, "model must be associated before calling EnableDragTarget" ); return m_internal->EnableDropTarget( formats ); diff --git a/src/osx/dataview_osx.cpp b/src/osx/dataview_osx.cpp index 8f885de027..1635ac554e 100644 --- a/src/osx/dataview_osx.cpp +++ b/src/osx/dataview_osx.cpp @@ -689,7 +689,7 @@ void wxDataViewCtrl::EditItem(const wxDataViewItem& item, const wxDataViewColumn #if wxUSE_DRAG_AND_DROP -bool wxDataViewCtrl::DoEnableDropTarget(const wxDataFormatArray &formats) +bool wxDataViewCtrl::DoEnableDropTarget(const wxVector &formats) { wxDropTarget* dt = NULL; if (wxDataObject* dataObject = CreateDataObject(formats)) diff --git a/src/qt/dataview.cpp b/src/qt/dataview.cpp index fd1b4b280e..6d249d398e 100644 --- a/src/qt/dataview.cpp +++ b/src/qt/dataview.cpp @@ -285,7 +285,7 @@ bool wxDataViewCtrl::EnableDragSource( const wxDataFormat &format ) return false; } -bool wxDataViewCtrl::DoEnableDropTarget( const wxDataFormatArray &formats ) +bool wxDataViewCtrl::DoEnableDropTarget( const wxVector &formats ) { return false; }