#include "wx/listimpl.cpp"
#include "wx/imaglist.h"
#include "wx/headerctrl.h"
+#include "wx/dnd.h"
//-----------------------------------------------------------------------------
// classes
void Expand( unsigned int row ) { OnExpanding( row ); }
void Collapse( unsigned int row ) { OnCollapsing( row ); }
bool IsExpanded( unsigned int row ) const;
+
+ bool EnableDragSource( const wxDataFormat &format )
+ {
+ m_dragFormat = format;
+ m_dragEnabled = format != wxDF_INVALID;
+ return true;
+ }
+ bool EnableDropTarget( const wxDataFormat &format )
+ {
+ m_dropFormat = format;
+ m_dropEnabled = format != wxDF_INVALID;
+ return true;
+ }
+
private:
wxDataViewTreeNode * GetTreeNodeByRow( unsigned int row ) const;
//We did not need this temporarily
int m_dragCount;
wxPoint m_dragStart;
+
+ bool m_dragEnabled;
+ wxDataFormat m_dragFormat;
+
+ bool m_dropEnabled;
+ wxDataFormat m_dropFormat;
// for double click logic
unsigned int m_lineLastClicked,
m_lineBeforeLastClicked = (unsigned int) -1;
m_lineSelectSingleOnUp = (unsigned int) -1;
+ m_dragEnabled = false;
+ m_dropEnabled = false;
+
m_hasFocus = false;
SetBackgroundColour( *wxWHITE );
return false;
if (!node->HasChildren())
+ {
+ delete node;
return false;
+ }
return node->IsOpen();
}
wxDataViewModel * model = GetOwner()->GetModel();
if( model == NULL )
return NULL;
+
+ if (!item.IsOk())
+ return m_root;
//Compose the a parent-chain of the finding item
ItemList list;
wxDataViewItemArray children;
unsigned int num = model->GetChildren( item, children);
+
unsigned int index = 0;
while( index < num )
{
if (event.LeftIsDown())
{
+ m_owner->CalcUnscrolledPosition( m_dragStart.x, m_dragStart.y, &m_dragStart.x, &m_dragStart.y );
+ unsigned int drag_item_row = GetLineAt( m_dragStart.y );
+ wxDataViewItem item = GetItemByRow( drag_item_row );
+
// Notify cell about drag
+ wxDataViewEvent event( wxEVT_COMMAND_DATAVIEW_ITEM_BEGIN_DRAG, m_owner->GetId() );
+ event.SetEventObject( m_owner );
+ event.SetItem( item );
+ event.SetModel( model );
+ if (!m_owner->HandleWindowEvent( event ))
+ return;
+
+ if (!event.IsAllowed())
+ return;
+
+ wxDataObject *obj = event.GetDataObject();
+ if (!obj)
+ return;
+
+ wxDropSource drag( m_owner );
+ drag.SetData( *obj );
+ // wxImage image( 80, 20 );
+ // wxBitmap bitmap( image );
+ wxDragResult res = drag.DoDragDrop();
+ delete obj;
}
return;
}
// select single line
SelectAllRows( false );
SelectRow( m_lineSelectSingleOnUp, true );
+ SendSelectionChangedEvent( GetItemByRow(m_lineSelectSingleOnUp) );
}
//Process the event of user clicking the expander
return true;
}
+bool wxDataViewCtrl::EnableDragSource( const wxDataFormat &format )
+{
+ return m_clientArea->EnableDragSource( format );
+}
+
+bool wxDataViewCtrl::EnableDropTarget( const wxDataFormat &format )
+{
+ return m_clientArea->EnableDropTarget( format );
+}
+
bool wxDataViewCtrl::AppendColumn( wxDataViewColumn *col )
{
if (!wxDataViewCtrlBase::AppendColumn(col))
void wxDataViewCtrl::SetSelections( const wxDataViewItemArray & sel )
{
wxDataViewSelection selection(wxDataViewSelectionCmp);
+
+ wxDataViewItem last_parent;
+
int len = sel.GetCount();
for( int i = 0; i < len; i ++ )
{
- int row = m_clientArea->GetRowByItem( sel[i] );
+ wxDataViewItem item = sel[i];
+ wxDataViewItem parent = GetModel()->GetParent( item );
+ if (parent)
+ {
+ if (parent != last_parent)
+ ExpandAncestors(item);
+ }
+
+ last_parent = parent;
+ int row = m_clientArea->GetRowByItem( item );
if( row >= 0 )
selection.Add( static_cast<unsigned int>(row) );
}
+
m_clientArea->SetSelections( selection );
}
void wxDataViewCtrl::Select( const wxDataViewItem & item )
{
+ ExpandAncestors( item );
+
int row = m_clientArea->GetRowByItem( item );
if( row >= 0 )
{
void wxDataViewCtrl::EnsureVisible( const wxDataViewItem & item, const wxDataViewColumn * column )
{
+ ExpandAncestors( item );
+
+ m_clientArea->RecalculateDisplay();
+
int row = m_clientArea->GetRowByItem(item);
if( row >= 0 )
{