Merge branch 'dvc-multi-format-dnd'

Accept multiple data formats via drag-and-drop in wxDataViewCtrl.

See #2478, #2616.
This commit is contained in:
Vadim Zeitlin
2022-01-15 23:39:03 +01:00
16 changed files with 290 additions and 373 deletions

View File

@@ -760,8 +760,21 @@ public:
#if wxUSE_DRAG_AND_DROP
virtual bool EnableDragSource(const wxDataFormat& WXUNUSED(format))
{ return false; }
virtual bool EnableDropTarget(const wxDataFormat& WXUNUSED(format))
{ return false; }
bool EnableDropTargets(const wxVector<wxDataFormat>& formats)
{ return DoEnableDropTarget(formats); }
bool EnableDropTarget(const wxDataFormat& format)
{
wxVector<wxDataFormat> formats;
if (format.GetType() != wxDF_INVALID)
{
formats.push_back(format);
}
return DoEnableDropTarget(formats);
}
#endif // wxUSE_DRAG_AND_DROP
// define control visual attributes
@@ -792,6 +805,17 @@ protected:
virtual void DoSetExpanderColumn() = 0 ;
virtual void DoSetIndent() = 0;
#if wxUSE_DRAG_AND_DROP
// Helper function which can be used by DoEnableDropTarget() implementations
// in the derived classes: return a composite data object supporting the
// given formats or null if the vector is empty.
static wxDataObjectComposite*
CreateDataObject(const wxVector<wxDataFormat>& formats);
virtual bool DoEnableDropTarget(const wxVector<wxDataFormat>& WXUNUSED(formats))
{ return false; }
#endif // wxUSE_DRAG_AND_DROP
// Just expand this item assuming it is already shown, i.e. its parent has
// been already expanded using ExpandAncestors().
//
@@ -912,6 +936,9 @@ public:
// insertion of items, this is the proposed child index for the insertion.
void SetProposedDropIndex(int index) { m_proposedDropIndex = index; }
int GetProposedDropIndex() const { return m_proposedDropIndex;}
// Internal, only used by wxWidgets itself.
void InitData(wxDataObjectComposite* obj, wxDataFormat format);
#endif // wxUSE_DRAG_AND_DROP
virtual wxEvent *Clone() const wxOVERRIDE { return new wxDataViewEvent(*this); }
@@ -945,6 +972,7 @@ protected:
#if wxUSE_DRAG_AND_DROP
wxDataObject *m_dataObject;
wxMemoryBuffer m_dataBuf;
wxDataFormat m_dataFormat;
void* m_dataBuffer;
size_t m_dataSize;