Use vector instead of array of wxDataFormats

Also rename EnableDropTarget() to EnableDropTargets(), as calling
EnableDropTarget(wxDF_XXX) would be ambiguous due to the existence of a
non-explicit wxVector ctor taking size_t (which is a mistake on its own,
but is probably not worth changing any more).
This commit is contained in:
Vadim Zeitlin
2021-08-16 18:22:08 +02:00
parent 1499d7d45b
commit cd555f9ff5
11 changed files with 27 additions and 30 deletions

View File

@@ -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<wxDataFormat>& formats)
{ return DoEnableDropTarget(formats); }
bool EnableDropTarget(const wxDataFormat& format)
{
wxDataFormatArray formats;
wxVector<wxDataFormat> 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<wxDataFormat>& formats);
virtual bool DoEnableDropTarget(const wxDataFormatArray& WXUNUSED(formats))
virtual bool DoEnableDropTarget(const wxVector<wxDataFormat>& WXUNUSED(formats))
{ return false; }
#endif // wxUSE_DRAG_AND_DROP

View File

@@ -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<wxDataFormat>& formats) wxOVERRIDE;
#endif // wxUSE_DRAG_AND_DROP
virtual wxBorder GetDefaultBorder() const wxOVERRIDE;

View File

@@ -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<wxDataFormat>& formats ) wxOVERRIDE;
virtual wxDataViewColumn *GetCurrentColumn() const wxOVERRIDE;

View File

@@ -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<wxDataFormat>& formats ) wxOVERRIDE;
#endif // wxUSE_DRAG_AND_DROP
// returns the n-th pointer to a column;

View File

@@ -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<wxDataFormat>& formats );
static wxVisualAttributes
GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL);

View File

@@ -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<wxDataFormat>& 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.
*/

View File

@@ -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<wxDataFormat>& 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:

View File

@@ -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<wxDataFormat> &formats )
{
wxDataViewDropTarget* dt = NULL;
if (wxDataObject* dataObject = CreateDataObject(formats))

View File

@@ -211,7 +211,7 @@ public:
// dnd iface
bool EnableDragSource( const wxDataFormat &format );
bool EnableDropTarget( const wxDataFormatArray &formats );
bool EnableDropTarget( const wxVector<wxDataFormat> &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<wxDataFormat>& 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<wxDataFormat>& formats )
{
wxCHECK_MSG( m_internal, false, "model must be associated before calling EnableDragTarget" );
return m_internal->EnableDropTarget( formats );

View File

@@ -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<wxDataFormat> &formats)
{
wxDropTarget* dt = NULL;
if (wxDataObject* dataObject = CreateDataObject(formats))

View File

@@ -285,7 +285,7 @@ bool wxDataViewCtrl::EnableDragSource( const wxDataFormat &format )
return false;
}
bool wxDataViewCtrl::DoEnableDropTarget( const wxDataFormatArray &formats )
bool wxDataViewCtrl::DoEnableDropTarget( const wxVector<wxDataFormat> &formats )
{
return false;
}