Skeleton for generic Drag code
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@58247 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -449,6 +449,9 @@ public:
|
|||||||
virtual bool IsExpanded( const wxDataViewItem & item ) const;
|
virtual bool IsExpanded( const wxDataViewItem & item ) const;
|
||||||
|
|
||||||
virtual void SetFocus();
|
virtual void SetFocus();
|
||||||
|
|
||||||
|
virtual bool EnableDragSource( const wxDataFormat &format );
|
||||||
|
virtual bool EnableDropTarget( const wxDataFormat &format );
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual int GetSelections( wxArrayInt & sel ) const;
|
virtual int GetSelections( wxArrayInt & sel ) const;
|
||||||
|
@@ -484,6 +484,20 @@ public:
|
|||||||
void Expand( unsigned int row ) { OnExpanding( row ); }
|
void Expand( unsigned int row ) { OnExpanding( row ); }
|
||||||
void Collapse( unsigned int row ) { OnCollapsing( row ); }
|
void Collapse( unsigned int row ) { OnCollapsing( row ); }
|
||||||
bool IsExpanded( unsigned int row ) const;
|
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:
|
private:
|
||||||
wxDataViewTreeNode * GetTreeNodeByRow( unsigned int row ) const;
|
wxDataViewTreeNode * GetTreeNodeByRow( unsigned int row ) const;
|
||||||
//We did not need this temporarily
|
//We did not need this temporarily
|
||||||
@@ -513,6 +527,12 @@ private:
|
|||||||
|
|
||||||
int m_dragCount;
|
int m_dragCount;
|
||||||
wxPoint m_dragStart;
|
wxPoint m_dragStart;
|
||||||
|
|
||||||
|
bool m_dragEnabled;
|
||||||
|
wxDataFormat m_dragFormat;
|
||||||
|
|
||||||
|
bool m_dropEnabled;
|
||||||
|
wxDataFormat m_dropFormat;
|
||||||
|
|
||||||
// for double click logic
|
// for double click logic
|
||||||
unsigned int m_lineLastClicked,
|
unsigned int m_lineLastClicked,
|
||||||
@@ -1177,6 +1197,9 @@ wxDataViewMainWindow::wxDataViewMainWindow( wxDataViewCtrl *parent, wxWindowID i
|
|||||||
m_lineBeforeLastClicked = (unsigned int) -1;
|
m_lineBeforeLastClicked = (unsigned int) -1;
|
||||||
m_lineSelectSingleOnUp = (unsigned int) -1;
|
m_lineSelectSingleOnUp = (unsigned int) -1;
|
||||||
|
|
||||||
|
m_dragEnabled = false;
|
||||||
|
m_dropEnabled = false;
|
||||||
|
|
||||||
m_hasFocus = false;
|
m_hasFocus = false;
|
||||||
|
|
||||||
SetBackgroundColour( *wxWHITE );
|
SetBackgroundColour( *wxWHITE );
|
||||||
@@ -2977,7 +3000,27 @@ void wxDataViewMainWindow::OnMouse( wxMouseEvent &event )
|
|||||||
|
|
||||||
if (event.LeftIsDown())
|
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
|
// 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;
|
||||||
|
|
||||||
|
wxPrintf( "success\n" );
|
||||||
|
// m_dragDataObject = obj;
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -3363,6 +3406,16 @@ bool wxDataViewCtrl::AssociateModel( wxDataViewModel *model )
|
|||||||
return true;
|
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 )
|
bool wxDataViewCtrl::AppendColumn( wxDataViewColumn *col )
|
||||||
{
|
{
|
||||||
if (!wxDataViewCtrlBase::AppendColumn(col))
|
if (!wxDataViewCtrlBase::AppendColumn(col))
|
||||||
|
Reference in New Issue
Block a user