Patch from Bo for new API, various fixes, live update for column header
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@48516 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -1662,10 +1662,6 @@ void wxGenericDataViewHeaderWindow::OnMouse( wxMouseEvent &event )
|
|||||||
m_owner->CalcUnscrolledPosition(w, 0, &w, NULL);
|
m_owner->CalcUnscrolledPosition(w, 0, &w, NULL);
|
||||||
w -= 6;
|
w -= 6;
|
||||||
|
|
||||||
// erase the line if it was drawn
|
|
||||||
if (m_currentX < w)
|
|
||||||
DrawCurrent();
|
|
||||||
|
|
||||||
if (event.ButtonUp())
|
if (event.ButtonUp())
|
||||||
{
|
{
|
||||||
m_isDragging = false;
|
m_isDragging = false;
|
||||||
@@ -1673,18 +1669,14 @@ void wxGenericDataViewHeaderWindow::OnMouse( wxMouseEvent &event )
|
|||||||
ReleaseMouse();
|
ReleaseMouse();
|
||||||
|
|
||||||
m_dirty = true;
|
m_dirty = true;
|
||||||
|
|
||||||
GetColumn(m_column)->SetWidth(m_currentX - m_minX);
|
|
||||||
|
|
||||||
Refresh();
|
|
||||||
GetOwner()->Refresh();
|
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
m_currentX = wxMax(m_minX + 7, x);
|
m_currentX = wxMax(m_minX + 7, x);
|
||||||
|
|
||||||
// draw in the new location
|
if (m_currentX < w)
|
||||||
if (m_currentX < w) DrawCurrent();
|
{
|
||||||
|
GetColumn(m_column)->SetWidth(m_currentX - m_minX);
|
||||||
|
Refresh();
|
||||||
|
GetOwner()->Refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -1740,7 +1732,6 @@ void wxGenericDataViewHeaderWindow::OnMouse( wxMouseEvent &event )
|
|||||||
m_isDragging = true;
|
m_isDragging = true;
|
||||||
CaptureMouse();
|
CaptureMouse();
|
||||||
m_currentX = x;
|
m_currentX = x;
|
||||||
DrawCurrent();
|
|
||||||
}
|
}
|
||||||
else // click on a column
|
else // click on a column
|
||||||
{
|
{
|
||||||
@@ -1787,8 +1778,12 @@ void wxGenericDataViewHeaderWindow::OnMouse( wxMouseEvent &event )
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//I must say that this function is deprecated, but I think it is useful to keep it for a time
|
||||||
void wxGenericDataViewHeaderWindow::DrawCurrent()
|
void wxGenericDataViewHeaderWindow::DrawCurrent()
|
||||||
{
|
{
|
||||||
|
#if 1
|
||||||
|
GetColumn(m_column)->SetWidth(m_currentX - m_minX);
|
||||||
|
#else
|
||||||
int x1 = m_currentX;
|
int x1 = m_currentX;
|
||||||
int y1 = 0;
|
int y1 = 0;
|
||||||
ClientToScreen (&x1, &y1);
|
ClientToScreen (&x1, &y1);
|
||||||
@@ -1807,6 +1802,7 @@ void wxGenericDataViewHeaderWindow::DrawCurrent()
|
|||||||
dc.SetBrush(*wxTRANSPARENT_BRUSH);
|
dc.SetBrush(*wxTRANSPARENT_BRUSH);
|
||||||
AdjustDC(dc);
|
AdjustDC(dc);
|
||||||
dc.DrawLine(x1, y1, x2, y2 );
|
dc.DrawLine(x1, y1, x2, y2 );
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxGenericDataViewHeaderWindow::AdjustDC(wxDC& dc)
|
void wxGenericDataViewHeaderWindow::AdjustDC(wxDC& dc)
|
||||||
@@ -3009,7 +3005,7 @@ wxDataViewTreeNode * wxDataViewMainWindow::FindNode( const wxDataViewItem & item
|
|||||||
//Find the item along the parent-chain.
|
//Find the item along the parent-chain.
|
||||||
//This algorithm is designed to speed up the node-finding method
|
//This algorithm is designed to speed up the node-finding method
|
||||||
wxDataViewTreeNode * node = m_root;
|
wxDataViewTreeNode * node = m_root;
|
||||||
for( ItemList::Node * n = list.GetFirst(); n; n = n->GetNext() )
|
for( ItemList::const_iterator iter = list.begin(); iter !=list.end() ; iter++ )
|
||||||
{
|
{
|
||||||
if( node->HasChildren() )
|
if( node->HasChildren() )
|
||||||
{
|
{
|
||||||
@@ -3023,7 +3019,7 @@ wxDataViewTreeNode * wxDataViewMainWindow::FindNode( const wxDataViewItem & item
|
|||||||
int i = 0;
|
int i = 0;
|
||||||
for (; i < nodes.GetCount(); i ++)
|
for (; i < nodes.GetCount(); i ++)
|
||||||
{
|
{
|
||||||
if (nodes[i]->GetItem() == *(n->GetData()))
|
if (nodes[i]->GetItem() == (**iter))
|
||||||
{
|
{
|
||||||
node = nodes[i];
|
node = nodes[i];
|
||||||
break;
|
break;
|
||||||
@@ -3090,8 +3086,8 @@ int wxDataViewMainWindow::RecalculateCount()
|
|||||||
class ItemToRowJob : public DoJob
|
class ItemToRowJob : public DoJob
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ItemToRowJob(const wxDataViewItem & item, ItemList::Node * node )
|
ItemToRowJob(const wxDataViewItem & item, ItemList::const_iterator iter )
|
||||||
{ this->item = item ; ret = -1 ; nd = node ; }
|
{ this->item = item ; ret = -1 ; m_iter = iter ; }
|
||||||
virtual ~ItemToRowJob(){};
|
virtual ~ItemToRowJob(){};
|
||||||
|
|
||||||
//Maybe binary search will help to speed up this process
|
//Maybe binary search will help to speed up this process
|
||||||
@@ -3103,9 +3099,9 @@ public:
|
|||||||
return DoJob::OK;
|
return DoJob::OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( nd && node->GetItem() == *(nd->GetData()))
|
if( node->GetItem() == **m_iter )
|
||||||
{
|
{
|
||||||
nd = nd->GetNext();
|
m_iter++ ;
|
||||||
return DoJob::CONT;
|
return DoJob::CONT;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -3126,7 +3122,7 @@ public:
|
|||||||
//the row number is begin from zero
|
//the row number is begin from zero
|
||||||
int GetResult(){ return ret -1 ; }
|
int GetResult(){ return ret -1 ; }
|
||||||
private:
|
private:
|
||||||
ItemList::Node * nd;
|
ItemList::const_iterator m_iter;
|
||||||
wxDataViewItem item;
|
wxDataViewItem item;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
@@ -3155,7 +3151,7 @@ int wxDataViewMainWindow::GetRowByItem(const wxDataViewItem & item)
|
|||||||
pItem = new wxDataViewItem( );
|
pItem = new wxDataViewItem( );
|
||||||
list.Insert( pItem );
|
list.Insert( pItem );
|
||||||
|
|
||||||
ItemToRowJob job( item, list.GetFirst() );
|
ItemToRowJob job( item, list.begin() );
|
||||||
Walker(m_root , job );
|
Walker(m_root , job );
|
||||||
return job.GetResult();
|
return job.GetResult();
|
||||||
}
|
}
|
||||||
@@ -3165,23 +3161,23 @@ void BuildTreeHelper( wxDataViewModel * model, wxDataViewItem & item, wxDataVie
|
|||||||
if( !model->IsContainer( item ) )
|
if( !model->IsContainer( item ) )
|
||||||
return ;
|
return ;
|
||||||
|
|
||||||
wxDataViewItem i = model->GetFirstChild( item );
|
wxDataViewItemArray children;
|
||||||
int num = 0;
|
unsigned int num = model->GetChildren( item, children);
|
||||||
while( i.IsOk() )
|
int index = 0;
|
||||||
|
while( index < num )
|
||||||
{
|
{
|
||||||
num ++;
|
if( model->IsContainer( children[index] ) )
|
||||||
if( model->IsContainer( i ) )
|
|
||||||
{
|
{
|
||||||
wxDataViewTreeNode * n = new wxDataViewTreeNode( node );
|
wxDataViewTreeNode * n = new wxDataViewTreeNode( node );
|
||||||
n->SetItem(i);
|
n->SetItem(children[index]);
|
||||||
n->SetHasChildren( true ) ;
|
n->SetHasChildren( true ) ;
|
||||||
node->AddNode( n );
|
node->AddNode( n );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
node->AddLeaf( i.GetID() );
|
node->AddLeaf( children[index].GetID() );
|
||||||
}
|
}
|
||||||
i = model->GetNextSibling( i );
|
index ++;
|
||||||
}
|
}
|
||||||
node->SetSubTreeCount( num );
|
node->SetSubTreeCount( num );
|
||||||
wxDataViewTreeNode * n = node->GetParent();
|
wxDataViewTreeNode * n = node->GetParent();
|
||||||
@@ -3463,6 +3459,8 @@ void wxDataViewMainWindow::OnMouse( wxMouseEvent &event )
|
|||||||
|
|
||||||
//Process the event of user clicking the expander
|
//Process the event of user clicking the expander
|
||||||
bool expander = false;
|
bool expander = false;
|
||||||
|
if (GetOwner()->GetExpanderColumn() == col)
|
||||||
|
{
|
||||||
wxDataViewTreeNode * node = GetTreeNodeByRow(current);
|
wxDataViewTreeNode * node = GetTreeNodeByRow(current);
|
||||||
if( node!=NULL && node->HasChildren() )
|
if( node!=NULL && node->HasChildren() )
|
||||||
{
|
{
|
||||||
@@ -3478,7 +3476,7 @@ void wxDataViewMainWindow::OnMouse( wxMouseEvent &event )
|
|||||||
OnExpanding( current );
|
OnExpanding( current );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
//If the user click the expander, we do not do editing even if the column with expander are editable
|
//If the user click the expander, we do not do editing even if the column with expander are editable
|
||||||
if (m_lastOnSame && !expander )
|
if (m_lastOnSame && !expander )
|
||||||
{
|
{
|
||||||
@@ -3778,7 +3776,7 @@ wxDataViewColumn* wxDataViewCtrl::GetColumn( unsigned int pos ) const
|
|||||||
|
|
||||||
bool wxDataViewCtrl::DeleteColumn( wxDataViewColumn *column )
|
bool wxDataViewCtrl::DeleteColumn( wxDataViewColumn *column )
|
||||||
{
|
{
|
||||||
wxDataViewColumnList::Node * ret = m_cols.Find( column );
|
wxDataViewColumnList::compatibility_iterator ret = m_cols.Find( column );
|
||||||
if (ret == NULL)
|
if (ret == NULL)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user