Accept multiple data formats via drag-and-drop in wxDataViewCtrl
Allow specifying multiple formats to be accepted when dragging data to wxDataViewCtrl in the generic and Cocoa implementations. Add wxDataViewCtrlBase::EnableDropTarget() overload taking an array of wxDataFormats to support this at the API level. Add new DoEnableDropTarget() used by both EnableDropTarget() overloads and implement it in the generic and Cocoa ports. GTK implementation still uses only a single format, as before. Also refactor the Cocoa implementation: all operations using dragged data are now handled by wxDropTarget and unnecessary DataViewPboardType as removed. Update the dataview sample to show the new functionality.
This commit is contained in:
@@ -211,7 +211,7 @@ public:
|
||||
// dnd iface
|
||||
|
||||
bool EnableDragSource( const wxDataFormat &format );
|
||||
bool EnableDropTarget( const wxDataFormat &format );
|
||||
bool EnableDropTarget( const wxDataFormatArray &formats );
|
||||
|
||||
gboolean row_draggable( GtkTreeDragSource *drag_source, GtkTreePath *path );
|
||||
gboolean drag_data_delete( GtkTreeDragSource *drag_source, GtkTreePath* path );
|
||||
@@ -3794,9 +3794,16 @@ bool wxDataViewCtrlInternal::EnableDragSource( const wxDataFormat &format )
|
||||
return true;
|
||||
}
|
||||
|
||||
bool wxDataViewCtrlInternal::EnableDropTarget( const wxDataFormat &format )
|
||||
bool wxDataViewCtrlInternal::EnableDropTarget( const wxDataFormatArray& formats )
|
||||
{
|
||||
wxGtkString atom_str( gdk_atom_name( format ) );
|
||||
if (formats.GetCount() == 0)
|
||||
{
|
||||
gtk_tree_view_unset_rows_drag_dest(GTK_TREE_VIEW(m_owner->GtkGetTreeView()));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
wxGtkString atom_str( gdk_atom_name( formats.Item(0) ) );
|
||||
m_dropTargetTargetEntryTarget = wxCharBuffer( atom_str );
|
||||
|
||||
m_dropTargetTargetEntry.target = m_dropTargetTargetEntryTarget.data();
|
||||
@@ -4922,10 +4929,10 @@ bool wxDataViewCtrl::EnableDragSource( const wxDataFormat &format )
|
||||
return m_internal->EnableDragSource( format );
|
||||
}
|
||||
|
||||
bool wxDataViewCtrl::EnableDropTarget( const wxDataFormat &format )
|
||||
bool wxDataViewCtrl::DoEnableDropTarget( const wxDataFormatArray& formats )
|
||||
{
|
||||
wxCHECK_MSG( m_internal, false, "model must be associated before calling EnableDragTarget" );
|
||||
return m_internal->EnableDropTarget( format );
|
||||
return m_internal->EnableDropTarget( formats );
|
||||
}
|
||||
|
||||
bool wxDataViewCtrl::AppendColumn( wxDataViewColumn *col )
|
||||
|
||||
Reference in New Issue
Block a user