Make CreateDataObject() return wxDataObjectComposite
This function must return a composite data object and not just any wxDataObject because its callers cast the returned object to this class, so make it a bit more type-safe.
This commit is contained in:
@@ -809,7 +809,8 @@ protected:
|
|||||||
// Helper function which can be used by DoEnableDropTarget() implementations
|
// Helper function which can be used by DoEnableDropTarget() implementations
|
||||||
// in the derived classes: return a composite data object supporting the
|
// in the derived classes: return a composite data object supporting the
|
||||||
// given formats or null if the vector is empty.
|
// given formats or null if the vector is empty.
|
||||||
static wxDataObject* CreateDataObject(const wxVector<wxDataFormat>& formats);
|
static wxDataObjectComposite*
|
||||||
|
CreateDataObject(const wxVector<wxDataFormat>& formats);
|
||||||
|
|
||||||
virtual bool DoEnableDropTarget(const wxVector<wxDataFormat>& WXUNUSED(formats))
|
virtual bool DoEnableDropTarget(const wxVector<wxDataFormat>& WXUNUSED(formats))
|
||||||
{ return false; }
|
{ return false; }
|
||||||
|
|||||||
@@ -1691,7 +1691,8 @@ void wxDataViewCtrlBase::StartEditor(const wxDataViewItem& item, unsigned int co
|
|||||||
#if wxUSE_DRAG_AND_DROP
|
#if wxUSE_DRAG_AND_DROP
|
||||||
|
|
||||||
/* static */
|
/* static */
|
||||||
wxDataObject* wxDataViewCtrlBase::CreateDataObject(const wxVector<wxDataFormat>& formats)
|
wxDataObjectComposite*
|
||||||
|
wxDataViewCtrlBase::CreateDataObject(const wxVector<wxDataFormat>& formats)
|
||||||
{
|
{
|
||||||
if (formats.empty())
|
if (formats.empty())
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1701,12 +1701,15 @@ public:
|
|||||||
class wxDataViewDropTarget: public wxDropTarget
|
class wxDataViewDropTarget: public wxDropTarget
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
wxDataViewDropTarget( wxDataObject *obj, wxDataViewMainWindow *win ) :
|
wxDataViewDropTarget( wxDataObjectComposite *obj, wxDataViewMainWindow *win ) :
|
||||||
wxDropTarget( obj )
|
wxDropTarget( obj ),
|
||||||
|
m_obj(obj)
|
||||||
{
|
{
|
||||||
m_win = win;
|
m_win = win;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
wxDataObjectComposite* GetCompositeDataObject() const { return m_obj; }
|
||||||
|
|
||||||
virtual wxDragResult OnDragOver( wxCoord x, wxCoord y, wxDragResult def ) wxOVERRIDE
|
virtual wxDragResult OnDragOver( wxCoord x, wxCoord y, wxDragResult def ) wxOVERRIDE
|
||||||
{
|
{
|
||||||
wxDataFormat format = GetMatchingPair();
|
wxDataFormat format = GetMatchingPair();
|
||||||
@@ -1736,6 +1739,9 @@ public:
|
|||||||
virtual void OnLeave() wxOVERRIDE
|
virtual void OnLeave() wxOVERRIDE
|
||||||
{ m_win->OnLeave(); }
|
{ m_win->OnLeave(); }
|
||||||
|
|
||||||
|
private:
|
||||||
|
wxDataObjectComposite* const m_obj;
|
||||||
|
|
||||||
wxDataViewMainWindow *m_win;
|
wxDataViewMainWindow *m_win;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -2379,7 +2385,9 @@ wxDragResult wxDataViewMainWindow::OnData(wxDataFormat format, wxCoord x, wxCoor
|
|||||||
{
|
{
|
||||||
DropItemInfo dropItemInfo = GetDropItemInfo(x, y);
|
DropItemInfo dropItemInfo = GetDropItemInfo(x, y);
|
||||||
|
|
||||||
wxDataObjectComposite *obj = static_cast<wxDataObjectComposite*>(GetDropTarget()->GetDataObject());
|
wxDataViewDropTarget* const
|
||||||
|
target = static_cast<wxDataViewDropTarget*>(GetDropTarget());
|
||||||
|
wxDataObjectComposite* const obj = target->GetCompositeDataObject();
|
||||||
|
|
||||||
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);
|
||||||
@@ -5804,7 +5812,7 @@ bool wxDataViewCtrl::EnableDragSource( const wxDataFormat &format )
|
|||||||
bool wxDataViewCtrl::DoEnableDropTarget( const wxVector<wxDataFormat> &formats )
|
bool wxDataViewCtrl::DoEnableDropTarget( const wxVector<wxDataFormat> &formats )
|
||||||
{
|
{
|
||||||
wxDataViewDropTarget* dt = NULL;
|
wxDataViewDropTarget* dt = NULL;
|
||||||
if (wxDataObject* dataObject = CreateDataObject(formats))
|
if (wxDataObjectComposite* dataObject = CreateDataObject(formats))
|
||||||
{
|
{
|
||||||
dt = new wxDataViewDropTarget(dataObject, m_clientArea);
|
dt = new wxDataViewDropTarget(dataObject, m_clientArea);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user