+ wxDataViewModel * model = GetOwner()->GetModel();
+ if( model == NULL )
+ return NULL;
+
+ //Compose the a parent-chain of the finding item
+ ItemList list;
+ list.DeleteContents( true );
+ wxDataViewItem it( item );
+ while( it.IsOk() )
+ {
+ wxDataViewItem * pItem = new wxDataViewItem( it );
+ list.Insert( pItem );
+ it = model->GetParent( it );
+ }
+
+ //Find the item along the parent-chain.
+ //This algorithm is designed to speed up the node-finding method
+ wxDataViewTreeNode * node = m_root;
+ for( ItemList::const_iterator iter = list.begin(); iter !=list.end() ; iter++ )
+ {
+ if( node->HasChildren() )
+ {
+ if( node->GetChildrenNumber() == 0 )
+ {
+ SortPrepare();
+ BuildTreeHelper(model, node->GetItem(), node);
+ }
+
+ wxDataViewTreeNodes nodes = node->GetNodes();
+ int i = 0;
+ for (; i < nodes.GetCount(); i ++)
+ {
+ if (nodes[i]->GetItem() == (**iter))
+ {
+ node = nodes[i];
+ break;
+ }
+ }
+ if (i == nodes.GetCount())
+ return NULL;
+ }
+ else
+ return NULL;
+ }
+ return node;
+}
+
+void wxDataViewMainWindow::HitTest( const wxPoint & point, wxDataViewItem & item, wxDataViewColumn* &column )
+{
+ wxDataViewColumn *col = NULL;
+ unsigned int cols = GetOwner()->GetColumnCount();
+ unsigned int colnum = 0;
+ unsigned int x_start = 0;
+ int x, y;
+ m_owner->CalcUnscrolledPosition( point.x, point.y, &x, &y );
+ for (x_start = 0; colnum < cols; colnum++)
+ {
+ col = GetOwner()->GetColumn(colnum);
+ if (col->IsHidden())
+ continue; // skip it!
+
+ unsigned int w = col->GetWidth();
+ if (x_start+w >= (unsigned int)x)
+ break;
+
+ x_start += w;
+ }
+
+ column = col;
+ item = GetItemByRow( y/m_lineHeight );
+}
+
+wxRect wxDataViewMainWindow::GetItemRect( const wxDataViewItem & item, const wxDataViewColumn* column )
+{
+ int row = GetRowByItem(item);
+ int y = row*m_lineHeight;
+ int h = m_lineHeight;
+ int x = 0;
+ wxDataViewColumn *col = NULL;
+ for( int i = 0, cols = GetOwner()->GetColumnCount(); i < cols; i ++ )
+ {
+ col = GetOwner()->GetColumn( i );
+ x += col->GetWidth();
+ if( GetOwner()->GetColumn(i+1) == column )
+ break;
+ }
+ int w = col->GetWidth();
+ m_owner->CalcScrolledPosition( x, y, &x, &y );
+ return wxRect(x, y, w, h);
+}
+
+int wxDataViewMainWindow::RecalculateCount()
+{
+ return m_root->GetSubTreeCount();