Add wxDataViewEvent::InitData() helper
Reuse it from both the generic and macOS versions to avoid doing the same thing in both of them.
This commit is contained in:
@@ -936,6 +936,9 @@ public:
|
|||||||
// insertion of items, this is the proposed child index for the insertion.
|
// insertion of items, this is the proposed child index for the insertion.
|
||||||
void SetProposedDropIndex(int index) { m_proposedDropIndex = index; }
|
void SetProposedDropIndex(int index) { m_proposedDropIndex = index; }
|
||||||
int GetProposedDropIndex() const { return m_proposedDropIndex;}
|
int GetProposedDropIndex() const { return m_proposedDropIndex;}
|
||||||
|
|
||||||
|
// Internal, only used by wxWidgets itself.
|
||||||
|
void InitData(wxDataObjectComposite* obj, wxDataFormat format);
|
||||||
#endif // wxUSE_DRAG_AND_DROP
|
#endif // wxUSE_DRAG_AND_DROP
|
||||||
|
|
||||||
virtual wxEvent *Clone() const wxOVERRIDE { return new wxDataViewEvent(*this); }
|
virtual wxEvent *Clone() const wxOVERRIDE { return new wxDataViewEvent(*this); }
|
||||||
|
|||||||
@@ -1805,6 +1805,18 @@ void wxDataViewEvent::Init(wxDataViewCtrlBase* dvc,
|
|||||||
SetEventObject(dvc);
|
SetEventObject(dvc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if wxUSE_DRAG_AND_DROP
|
||||||
|
|
||||||
|
void wxDataViewEvent::InitData(wxDataObjectComposite* obj, wxDataFormat format)
|
||||||
|
{
|
||||||
|
SetDataFormat(format);
|
||||||
|
|
||||||
|
SetDataObject(obj->GetObject(format));
|
||||||
|
SetDataSize(obj->GetDataSize(format));
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // wxUSE_DRAG_AND_DROP
|
||||||
|
|
||||||
#if wxUSE_SPINCTRL
|
#if wxUSE_SPINCTRL
|
||||||
|
|
||||||
// -------------------------------------
|
// -------------------------------------
|
||||||
|
|||||||
@@ -2391,9 +2391,7 @@ wxDragResult wxDataViewMainWindow::OnData(wxDataFormat format, wxCoord x, wxCoor
|
|||||||
|
|
||||||
wxDataViewEvent event(wxEVT_DATAVIEW_ITEM_DROP, m_owner, dropItemInfo.m_item);
|
wxDataViewEvent event(wxEVT_DATAVIEW_ITEM_DROP, m_owner, dropItemInfo.m_item);
|
||||||
event.SetProposedDropIndex(dropItemInfo.m_proposedDropIndex);
|
event.SetProposedDropIndex(dropItemInfo.m_proposedDropIndex);
|
||||||
event.SetDataFormat( format );
|
event.InitData(obj, format);
|
||||||
event.SetDataSize(obj->GetDataSize(format));
|
|
||||||
event.SetDataObject(obj->GetObject(format));
|
|
||||||
event.SetDropEffect( def );
|
event.SetDropEffect( def );
|
||||||
if ( !m_owner->HandleWindowEvent( event ) || !event.IsAllowed() )
|
if ( !m_owner->HandleWindowEvent( event ) || !event.IsAllowed() )
|
||||||
return wxDragNone;
|
return wxDragNone;
|
||||||
|
|||||||
@@ -729,20 +729,22 @@ outlineView:(NSOutlineView*)outlineView
|
|||||||
// Create event
|
// Create event
|
||||||
wxDataViewEvent event(eventType, dvc, wxDataViewItemFromItem(item));
|
wxDataViewEvent event(eventType, dvc, wxDataViewItemFromItem(item));
|
||||||
|
|
||||||
// Retrieve data info if user released mouse buttton (drop occured)
|
// Retrieve the data itself if user released mouse button (drop occurred)
|
||||||
if (eventType == wxEVT_DATAVIEW_ITEM_DROP)
|
if (eventType == wxEVT_DATAVIEW_ITEM_DROP)
|
||||||
{
|
{
|
||||||
if (!dt->GetData())
|
if (!dt->GetData())
|
||||||
return NSDragOperationNone;
|
return NSDragOperationNone;
|
||||||
|
|
||||||
wxDataObjectComposite *obj = static_cast<wxDataObjectComposite*>(dt->GetDataObject());
|
wxDataObjectComposite *obj = static_cast<wxDataObjectComposite*>(dt->GetDataObject());
|
||||||
event.SetDataSize(obj->GetDataSize(format));
|
event.InitData(obj, format);
|
||||||
event.SetDataObject(obj->GetObject(format));
|
}
|
||||||
|
else // Otherwise set just the data format
|
||||||
|
{
|
||||||
|
event.SetDataFormat(format);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Setup other event properties
|
// Setup other event properties
|
||||||
event.SetProposedDropIndex(index);
|
event.SetProposedDropIndex(index);
|
||||||
event.SetDataFormat(format);
|
|
||||||
if (index == -1)
|
if (index == -1)
|
||||||
{
|
{
|
||||||
event.SetDropEffect(wxDragCopy);
|
event.SetDropEffect(wxDragCopy);
|
||||||
|
|||||||
Reference in New Issue
Block a user