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:
@@ -535,10 +535,6 @@ private:
|
|||||||
// wxDataViewCtrlBase
|
// wxDataViewCtrlBase
|
||||||
// ---------------------------------------------------------
|
// ---------------------------------------------------------
|
||||||
|
|
||||||
#if wxUSE_DRAG_AND_DROP
|
|
||||||
WX_DEFINE_ARRAY(wxDataFormat,wxDataFormatArray);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define wxDV_SINGLE 0x0000 // for convenience
|
#define wxDV_SINGLE 0x0000 // for convenience
|
||||||
#define wxDV_MULTIPLE 0x0001 // can select multiple items
|
#define wxDV_MULTIPLE 0x0001 // can select multiple items
|
||||||
|
|
||||||
@@ -765,18 +761,18 @@ public:
|
|||||||
virtual bool EnableDragSource(const wxDataFormat& WXUNUSED(format))
|
virtual bool EnableDragSource(const wxDataFormat& WXUNUSED(format))
|
||||||
{ return false; }
|
{ return false; }
|
||||||
|
|
||||||
bool EnableDropTarget(const wxDataFormatArray& formats)
|
bool EnableDropTargets(const wxVector<wxDataFormat>& formats)
|
||||||
{ return DoEnableDropTarget(formats); }
|
{ return DoEnableDropTarget(formats); }
|
||||||
|
|
||||||
bool EnableDropTarget(const wxDataFormat& format)
|
bool EnableDropTarget(const wxDataFormat& format)
|
||||||
{
|
{
|
||||||
wxDataFormatArray formats;
|
wxVector<wxDataFormat> formats;
|
||||||
if (format.GetType() != wxDF_INVALID)
|
if (format.GetType() != wxDF_INVALID)
|
||||||
{
|
{
|
||||||
formats.Add(format);
|
formats.push_back(format);
|
||||||
}
|
}
|
||||||
|
|
||||||
return EnableDropTarget(formats);
|
return DoEnableDropTarget(formats);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // wxUSE_DRAG_AND_DROP
|
#endif // wxUSE_DRAG_AND_DROP
|
||||||
@@ -810,9 +806,9 @@ protected:
|
|||||||
virtual void DoSetIndent() = 0;
|
virtual void DoSetIndent() = 0;
|
||||||
|
|
||||||
#if wxUSE_DRAG_AND_DROP
|
#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; }
|
{ return false; }
|
||||||
|
|
||||||
#endif // wxUSE_DRAG_AND_DROP
|
#endif // wxUSE_DRAG_AND_DROP
|
||||||
|
|||||||
@@ -284,7 +284,7 @@ public:
|
|||||||
|
|
||||||
#if wxUSE_DRAG_AND_DROP
|
#if wxUSE_DRAG_AND_DROP
|
||||||
virtual bool EnableDragSource( const wxDataFormat &format ) wxOVERRIDE;
|
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
|
#endif // wxUSE_DRAG_AND_DROP
|
||||||
|
|
||||||
virtual wxBorder GetDefaultBorder() const wxOVERRIDE;
|
virtual wxBorder GetDefaultBorder() const wxOVERRIDE;
|
||||||
|
|||||||
@@ -166,7 +166,7 @@ public:
|
|||||||
virtual bool IsExpanded( const wxDataViewItem & item ) const wxOVERRIDE;
|
virtual bool IsExpanded( const wxDataViewItem & item ) const wxOVERRIDE;
|
||||||
|
|
||||||
virtual bool EnableDragSource( const wxDataFormat &format ) 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;
|
virtual wxDataViewColumn *GetCurrentColumn() const wxOVERRIDE;
|
||||||
|
|
||||||
|
|||||||
@@ -209,7 +209,7 @@ public:
|
|||||||
virtual void EditItem(const wxDataViewItem& item, const wxDataViewColumn *column) wxOVERRIDE;
|
virtual void EditItem(const wxDataViewItem& item, const wxDataViewColumn *column) wxOVERRIDE;
|
||||||
|
|
||||||
#if wxUSE_DRAG_AND_DROP
|
#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
|
#endif // wxUSE_DRAG_AND_DROP
|
||||||
|
|
||||||
// returns the n-th pointer to a column;
|
// returns the n-th pointer to a column;
|
||||||
|
|||||||
@@ -119,7 +119,7 @@ public:
|
|||||||
virtual bool IsExpanded( const wxDataViewItem & item ) const;
|
virtual bool IsExpanded( const wxDataViewItem & item ) const;
|
||||||
|
|
||||||
virtual bool EnableDragSource( const wxDataFormat &format );
|
virtual bool EnableDragSource( const wxDataFormat &format );
|
||||||
virtual bool DoEnableDropTarget( const wxDataFormatArray& formats ) wxOVERRIDE;
|
virtual bool DoEnableDropTarget( const wxVector<wxDataFormat>& formats );
|
||||||
|
|
||||||
static wxVisualAttributes
|
static wxVisualAttributes
|
||||||
GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL);
|
GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL);
|
||||||
|
|||||||
@@ -1390,7 +1390,7 @@ public:
|
|||||||
virtual bool EnableDragSource( const wxDataFormat &format );
|
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
|
Currently this is fully implemented in the generic and native macOS
|
||||||
versions. In wxGTK only the first element of the array is used.
|
versions. In wxGTK only the first element of the array is used.
|
||||||
@@ -1399,12 +1399,12 @@ public:
|
|||||||
|
|
||||||
@since 3.1.6
|
@since 3.1.6
|
||||||
*/
|
*/
|
||||||
bool EnableDropTarget(const wxDataFormatArray& formats);
|
bool EnableDropTargets(const wxVector<wxDataFormat>& formats);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Enable drop operations using the given @a format.
|
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.
|
@note Since 3.1.6 wxDF_INVALID can be passed to disable drag and drop support.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -1690,17 +1690,17 @@ void wxDataViewCtrlBase::StartEditor(const wxDataViewItem& item, unsigned int co
|
|||||||
|
|
||||||
#if wxUSE_DRAG_AND_DROP
|
#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;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxDataObjectComposite *dataObject(new wxDataObjectComposite);
|
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_TEXT:
|
||||||
case wxDF_OEMTEXT:
|
case wxDF_OEMTEXT:
|
||||||
@@ -1733,7 +1733,7 @@ wxDataObject* wxDataViewCtrlBase::CreateDataObject(const wxDataFormatArray& form
|
|||||||
case wxDF_ENHMETAFILE:
|
case wxDF_ENHMETAFILE:
|
||||||
case wxDF_LOCALE:
|
case wxDF_LOCALE:
|
||||||
case wxDF_PRIVATE:
|
case wxDF_PRIVATE:
|
||||||
dataObject->Add(new wxCustomDataObject(formats.Item(i)));
|
dataObject->Add(new wxCustomDataObject(formats[i]));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case wxDF_INVALID:
|
case wxDF_INVALID:
|
||||||
|
|||||||
@@ -5801,7 +5801,7 @@ bool wxDataViewCtrl::EnableDragSource( const wxDataFormat &format )
|
|||||||
return m_clientArea->EnableDragSource( format );
|
return m_clientArea->EnableDragSource( format );
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxDataViewCtrl::DoEnableDropTarget( const wxDataFormatArray &formats )
|
bool wxDataViewCtrl::DoEnableDropTarget( const wxVector<wxDataFormat> &formats )
|
||||||
{
|
{
|
||||||
wxDataViewDropTarget* dt = NULL;
|
wxDataViewDropTarget* dt = NULL;
|
||||||
if (wxDataObject* dataObject = CreateDataObject(formats))
|
if (wxDataObject* dataObject = CreateDataObject(formats))
|
||||||
|
|||||||
@@ -211,7 +211,7 @@ public:
|
|||||||
// dnd iface
|
// dnd iface
|
||||||
|
|
||||||
bool EnableDragSource( const wxDataFormat &format );
|
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 row_draggable( GtkTreeDragSource *drag_source, GtkTreePath *path );
|
||||||
gboolean drag_data_delete( 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;
|
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()));
|
gtk_tree_view_unset_rows_drag_dest(GTK_TREE_VIEW(m_owner->GtkGetTreeView()));
|
||||||
|
|
||||||
return true;
|
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_dropTargetTargetEntryTarget = wxCharBuffer( atom_str );
|
||||||
|
|
||||||
m_dropTargetTargetEntry.target = m_dropTargetTargetEntryTarget.data();
|
m_dropTargetTargetEntry.target = m_dropTargetTargetEntryTarget.data();
|
||||||
@@ -4929,7 +4930,7 @@ bool wxDataViewCtrl::EnableDragSource( const wxDataFormat &format )
|
|||||||
return m_internal->EnableDragSource( 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" );
|
wxCHECK_MSG( m_internal, false, "model must be associated before calling EnableDragTarget" );
|
||||||
return m_internal->EnableDropTarget( formats );
|
return m_internal->EnableDropTarget( formats );
|
||||||
|
|||||||
@@ -689,7 +689,7 @@ void wxDataViewCtrl::EditItem(const wxDataViewItem& item, const wxDataViewColumn
|
|||||||
|
|
||||||
#if wxUSE_DRAG_AND_DROP
|
#if wxUSE_DRAG_AND_DROP
|
||||||
|
|
||||||
bool wxDataViewCtrl::DoEnableDropTarget(const wxDataFormatArray &formats)
|
bool wxDataViewCtrl::DoEnableDropTarget(const wxVector<wxDataFormat> &formats)
|
||||||
{
|
{
|
||||||
wxDropTarget* dt = NULL;
|
wxDropTarget* dt = NULL;
|
||||||
if (wxDataObject* dataObject = CreateDataObject(formats))
|
if (wxDataObject* dataObject = CreateDataObject(formats))
|
||||||
|
|||||||
@@ -285,7 +285,7 @@ bool wxDataViewCtrl::EnableDragSource( const wxDataFormat &format )
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxDataViewCtrl::DoEnableDropTarget( const wxDataFormatArray &formats )
|
bool wxDataViewCtrl::DoEnableDropTarget( const wxVector<wxDataFormat> &formats )
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user