compilation after last commit: semicolon after wxDELETE() is now required; also removed some other extra semicolons and other minor cleanup

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@54941 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2008-08-03 00:10:06 +00:00
parent 604fba2d34
commit 59e601677a

View File

@@ -333,7 +333,7 @@ public:
unsigned int GetNodeNumber() const { return m_nodes.GetCount(); } unsigned int GetNodeNumber() const { return m_nodes.GetCount(); }
int GetIndentLevel() const int GetIndentLevel() const
{ {
int ret = 0 ; int ret = 0;
const wxDataViewTreeNode * node = this; const wxDataViewTreeNode * node = this;
while( node->GetParent()->GetParent() != NULL ) while( node->GetParent()->GetParent() != NULL )
{ {
@@ -345,14 +345,14 @@ public:
bool IsOpen() const bool IsOpen() const
{ {
return m_open ; return m_open;
} }
void ToggleOpen() void ToggleOpen()
{ {
int len = m_nodes.GetCount(); int len = m_nodes.GetCount();
int sum = 0; int sum = 0;
for ( int i = 0 ;i < len ; i ++) for ( int i = 0;i < len; i ++)
sum += m_nodes[i]->GetSubTreeCount(); sum += m_nodes[i]->GetSubTreeCount();
sum += m_leaves.GetCount(); sum += m_leaves.GetCount();
@@ -375,7 +375,7 @@ public:
void ChangeSubTreeCount( int num ) void ChangeSubTreeCount( int num )
{ {
if( !m_open ) if( !m_open )
return ; return;
m_subTreeCount += num; m_subTreeCount += num;
if( m_parent ) if( m_parent )
m_parent->ChangeSubTreeCount(num); m_parent->ChangeSubTreeCount(num);
@@ -501,7 +501,7 @@ public:
unsigned int GetFirstVisibleRow() const; unsigned int GetFirstVisibleRow() const;
//I change this method to un const because in the tree view, the displaying number of the tree are changing along with the expanding/collapsing of the tree nodes //I change this method to un const because in the tree view, the displaying number of the tree are changing along with the expanding/collapsing of the tree nodes
unsigned int GetLastVisibleRow(); unsigned int GetLastVisibleRow();
unsigned int GetRowCount() ; unsigned int GetRowCount();
wxDataViewItem GetSelection() const; wxDataViewItem GetSelection() const;
wxDataViewSelection GetSelections(){ return m_selection; } wxDataViewSelection GetSelections(){ return m_selection; }
@@ -547,7 +547,7 @@ private:
//We did not need this temporarily //We did not need this temporarily
//wxDataViewTreeNode * GetTreeNodeByItem( const wxDataViewItem & item ); //wxDataViewTreeNode * GetTreeNodeByItem( const wxDataViewItem & item );
int RecalculateCount() ; int RecalculateCount();
wxDataViewEvent SendExpanderEvent( wxEventType type, const wxDataViewItem & item ); wxDataViewEvent SendExpanderEvent( wxEventType type, const wxDataViewItem & item );
void OnExpanding( unsigned int row ); void OnExpanding( unsigned int row );
@@ -2052,7 +2052,7 @@ wxDataViewMainWindow::wxDataViewMainWindow( wxDataViewCtrl *parent, wxWindowID i
m_root->SetHasChildren(true); m_root->SetHasChildren(true);
//Make m_count = -1 will cause the class recaculate the real displaying number of rows. //Make m_count = -1 will cause the class recaculate the real displaying number of rows.
m_count = -1 ; m_count = -1;
m_underMouse = NULL; m_underMouse = NULL;
UpdateDisplay(); UpdateDisplay();
} }
@@ -2254,7 +2254,7 @@ void wxDataViewMainWindow::OnPaint( wxPaintEvent &WXUNUSED(event) )
// change the cell_rect.x to the appropriate pos // change the cell_rect.x to the appropriate pos
int expander_x = indent + EXPANDER_MARGIN; int expander_x = indent + EXPANDER_MARGIN;
int expander_y = cell_rect.y + EXPANDER_MARGIN + (GetLineHeight(item) / 2) - (expander_width/2) - EXPANDER_OFFSET; int expander_y = cell_rect.y + EXPANDER_MARGIN + (GetLineHeight(item) / 2) - (expander_width/2) - EXPANDER_OFFSET;
indent = indent + m_lineHeight ; //try to use the m_lineHeight as the expander space indent = indent + m_lineHeight; //try to use the m_lineHeight as the expander space
dc.SetPen( m_penExpander ); dc.SetPen( m_penExpander );
dc.SetBrush( wxNullBrush ); dc.SetBrush( wxNullBrush );
if( node->HasChildren() ) if( node->HasChildren() )
@@ -2277,7 +2277,7 @@ void wxDataViewMainWindow::OnPaint( wxPaintEvent &WXUNUSED(event) )
{ {
// Yes, if the node does not have any child, it must be a leaf which // Yes, if the node does not have any child, it must be a leaf which
// mean that it is a temporarily created by GetTreeNodeByRow // mean that it is a temporarily created by GetTreeNodeByRow
wxDELETE(node) wxDELETE(node);
} }
// cannot be bigger than allocated space // cannot be bigger than allocated space
@@ -2372,15 +2372,15 @@ void wxDataViewMainWindow::OnRenameTimer()
class DoJob class DoJob
{ {
public: public:
DoJob(){}; DoJob() { }
virtual ~DoJob(){}; virtual ~DoJob() { }
//The return value control how the tree-walker tranverse the tree //The return value control how the tree-walker tranverse the tree
// 0: Job done, stop tranverse and return // 0: Job done, stop tranverse and return
// 1: Ignore the current node's subtree and continue // 1: Ignore the current node's subtree and continue
// 2: Job not done, continue // 2: Job not done, continue
enum { OK = 0 , IGR = 1, CONT = 2 }; enum { OK = 0 , IGR = 1, CONT = 2 };
virtual int operator() ( wxDataViewTreeNode * node ) = 0 ; virtual int operator() ( wxDataViewTreeNode * node ) = 0;
virtual int operator() ( void * n ) = 0; virtual int operator() ( void * n ) = 0;
}; };
@@ -2392,7 +2392,7 @@ bool Walker( wxDataViewTreeNode * node, DoJob & func )
switch( func( node ) ) switch( func( node ) )
{ {
case DoJob::OK : case DoJob::OK :
return true ; return true;
case DoJob::IGR: case DoJob::IGR:
return false; return false;
case DoJob::CONT: case DoJob::CONT:
@@ -2407,7 +2407,7 @@ bool Walker( wxDataViewTreeNode * node, DoJob & func )
int len = leaves.GetCount(); int len = leaves.GetCount();
int i = 0, nodes_i = 0; int i = 0, nodes_i = 0;
for( ; i < len ; i ++ ) for(; i < len; i ++ )
{ {
void * n = leaves[i]; void * n = leaves[i];
if( nodes_i < len_nodes && n == nodes[nodes_i]->GetItem().GetID() ) if( nodes_i < len_nodes && n == nodes[nodes_i]->GetItem().GetID() )
@@ -2423,7 +2423,7 @@ bool Walker( wxDataViewTreeNode * node, DoJob & func )
switch( func( n ) ) switch( func( n ) )
{ {
case DoJob::OK : case DoJob::OK :
return true ; return true;
case DoJob::IGR: case DoJob::IGR:
continue; continue;
case DoJob::CONT: case DoJob::CONT:
@@ -2516,7 +2516,7 @@ bool wxDataViewMainWindow::ItemDeleted(const wxDataViewItem& parent,
wxDataViewTreeNode * n = NULL; wxDataViewTreeNode * n = NULL;
wxDataViewTreeNodes nodes = node->GetNodes(); wxDataViewTreeNodes nodes = node->GetNodes();
int len = nodes.GetCount(); int len = nodes.GetCount();
for( int i = 0 ; i < len; i ++) for( int i = 0; i < len; i ++)
{ {
if( nodes[i]->GetItem() == item ) if( nodes[i]->GetItem() == item )
{ {
@@ -2975,7 +2975,7 @@ int wxDataViewMainWindow::GetLineStart( unsigned int row ) const
{ {
// Yes, if the node does not have any child, it must be a leaf which // Yes, if the node does not have any child, it must be a leaf which
// mean that it is a temporarily created by GetTreeNodeByRow // mean that it is a temporarily created by GetTreeNodeByRow
wxDELETE(node) wxDELETE(node);
} }
unsigned int cols = GetOwner()->GetColumnCount(); unsigned int cols = GetOwner()->GetColumnCount();
@@ -3036,7 +3036,7 @@ int wxDataViewMainWindow::GetLineAt( unsigned int y ) const
{ {
// Yes, if the node does not have any child, it must be a leaf which // Yes, if the node does not have any child, it must be a leaf which
// mean that it is a temporarily created by GetTreeNodeByRow // mean that it is a temporarily created by GetTreeNodeByRow
wxDELETE(node) wxDELETE(node);
} }
unsigned int cols = GetOwner()->GetColumnCount(); unsigned int cols = GetOwner()->GetColumnCount();
@@ -3085,7 +3085,7 @@ int wxDataViewMainWindow::GetLineHeight( unsigned int row ) const
{ {
// Yes, if the node does not have any child, it must be a leaf which // Yes, if the node does not have any child, it must be a leaf which
// mean that it is a temporarily created by GetTreeNodeByRow // mean that it is a temporarily created by GetTreeNodeByRow
wxDELETE(node) wxDELETE(node);
} }
int height = m_lineHeight; int height = m_lineHeight;
@@ -3120,15 +3120,15 @@ int wxDataViewMainWindow::GetLineHeight( unsigned int row ) const
class RowToItemJob: public DoJob class RowToItemJob: public DoJob
{ {
public: public:
RowToItemJob( unsigned int row , int current ) { this->row = row; this->current = current ;} RowToItemJob( unsigned int row , int current ) { this->row = row; this->current = current;}
virtual ~RowToItemJob(){}; virtual ~RowToItemJob() { }
virtual int operator() ( wxDataViewTreeNode * node ) virtual int operator() ( wxDataViewTreeNode * node )
{ {
current ++; current ++;
if( current == static_cast<int>(row)) if( current == static_cast<int>(row))
{ {
ret = node->GetItem() ; ret = node->GetItem();
return DoJob::OK; return DoJob::OK;
} }
@@ -3156,7 +3156,7 @@ public:
current ++; current ++;
if( current == static_cast<int>(row)) if( current == static_cast<int>(row))
{ {
ret = wxDataViewItem( n ) ; ret = wxDataViewItem( n );
return DoJob::OK; return DoJob::OK;
} }
return DoJob::CONT; return DoJob::CONT;
@@ -3164,7 +3164,7 @@ public:
wxDataViewItem GetResult(){ return ret; } wxDataViewItem GetResult(){ return ret; }
private: private:
unsigned int row; unsigned int row;
int current ; int current;
wxDataViewItem ret; wxDataViewItem ret;
}; };
@@ -3188,18 +3188,18 @@ public:
RowToTreeNodeJob( unsigned int row , int current, wxDataViewTreeNode * node ) RowToTreeNodeJob( unsigned int row , int current, wxDataViewTreeNode * node )
{ {
this->row = row; this->row = row;
this->current = current ; this->current = current;
ret = NULL ; ret = NULL;
parent = node; parent = node;
} }
virtual ~RowToTreeNodeJob(){}; virtual ~RowToTreeNodeJob(){ }
virtual int operator() ( wxDataViewTreeNode * node ) virtual int operator() ( wxDataViewTreeNode * node )
{ {
current ++; current ++;
if( current == static_cast<int>(row)) if( current == static_cast<int>(row))
{ {
ret = node ; ret = node;
return DoJob::OK; return DoJob::OK;
} }
@@ -3217,7 +3217,7 @@ public:
{ {
int index = static_cast<int>(row) - current - 1; int index = static_cast<int>(row) - current - 1;
void * n = node->GetChildren().Item( index ); void * n = node->GetChildren().Item( index );
ret = new wxDataViewTreeNode( parent ) ; ret = new wxDataViewTreeNode( parent );
ret->SetItem( wxDataViewItem( n )); ret->SetItem( wxDataViewItem( n ));
ret->SetHasChildren(false); ret->SetHasChildren(false);
return DoJob::OK; return DoJob::OK;
@@ -3233,7 +3233,7 @@ public:
current ++; current ++;
if( current == static_cast<int>(row)) if( current == static_cast<int>(row))
{ {
ret = new wxDataViewTreeNode( parent ) ; ret = new wxDataViewTreeNode( parent );
ret->SetItem( wxDataViewItem( n )); ret->SetItem( wxDataViewItem( n ));
ret->SetHasChildren(false); ret->SetHasChildren(false);
return DoJob::OK; return DoJob::OK;
@@ -3244,9 +3244,9 @@ public:
wxDataViewTreeNode * GetResult(){ return ret; } wxDataViewTreeNode * GetResult(){ return ret; }
private: private:
unsigned int row; unsigned int row;
int current ; int current;
wxDataViewTreeNode * ret; wxDataViewTreeNode * ret;
wxDataViewTreeNode * parent ; wxDataViewTreeNode * parent;
}; };
@@ -3333,7 +3333,7 @@ void wxDataViewMainWindow::OnCollapsing(unsigned int row)
node = node->GetParent(); node = node->GetParent();
if( node != NULL ) if( node != NULL )
{ {
int parent = GetRowByItem( node->GetItem() ) ; int parent = GetRowByItem( node->GetItem() );
if( parent >= 0 ) if( parent >= 0 )
{ {
SelectRow( row, false); SelectRow( row, false);
@@ -3368,7 +3368,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::const_iterator iter = list.begin(); iter !=list.end() ; iter++ ) for( ItemList::const_iterator iter = list.begin(); iter !=list.end(); iter++ )
{ {
if( node->HasChildren() ) if( node->HasChildren() )
{ {
@@ -3467,9 +3467,12 @@ int wxDataViewMainWindow::RecalculateCount()
class ItemToRowJob : public DoJob class ItemToRowJob : public DoJob
{ {
public: public:
ItemToRowJob(const wxDataViewItem & item, ItemList::const_iterator iter ) ItemToRowJob(const wxDataViewItem& item_, ItemList::const_iterator iter)
{ this->item = item ; ret = -1 ; m_iter = iter ; } : m_iter(iter),
virtual ~ItemToRowJob(){}; item(item_)
{
ret = -1;
}
//Maybe binary search will help to speed up this process //Maybe binary search will help to speed up this process
virtual int operator() ( wxDataViewTreeNode * node) virtual int operator() ( wxDataViewTreeNode * node)
@@ -3482,7 +3485,7 @@ public:
if( node->GetItem() == **m_iter ) if( node->GetItem() == **m_iter )
{ {
m_iter++ ; m_iter++;
return DoJob::CONT; return DoJob::CONT;
} }
else else
@@ -3501,7 +3504,8 @@ public:
return DoJob::CONT; return DoJob::CONT;
} }
//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::const_iterator m_iter; ItemList::const_iterator m_iter;
wxDataViewItem item; wxDataViewItem item;
@@ -3547,7 +3551,7 @@ int wxDataViewMainWindow::GetRowByItem(const wxDataViewItem & item) const
static void BuildTreeHelper( wxDataViewModel * model, wxDataViewItem & item, wxDataViewTreeNode * node) static void BuildTreeHelper( wxDataViewModel * model, wxDataViewItem & item, wxDataViewTreeNode * node)
{ {
if( !model->IsContainer( item ) ) if( !model->IsContainer( item ) )
return ; return;
wxDataViewItemArray children; wxDataViewItemArray children;
unsigned int num = model->GetChildren( item, children); unsigned int num = model->GetChildren( item, children);
@@ -3558,7 +3562,7 @@ static void BuildTreeHelper( wxDataViewModel * model, wxDataViewItem & item, wx
{ {
wxDataViewTreeNode * n = new wxDataViewTreeNode( node ); wxDataViewTreeNode * n = new wxDataViewTreeNode( node );
n->SetItem(children[index]); n->SetItem(children[index]);
n->SetHasChildren( true ) ; n->SetHasChildren( true );
node->AddNode( n ); node->AddNode( n );
} }
else else
@@ -3580,7 +3584,7 @@ void wxDataViewMainWindow::BuildTree(wxDataViewModel * model)
if (GetOwner()->GetModel()->IsVirtualListModel()) if (GetOwner()->GetModel()->IsVirtualListModel())
{ {
m_count = -1 ; m_count = -1;
return; return;
} }
@@ -3591,7 +3595,7 @@ void wxDataViewMainWindow::BuildTree(wxDataViewModel * model)
wxDataViewItem item; wxDataViewItem item;
SortPrepare(); SortPrepare();
BuildTreeHelper( model, item, m_root); BuildTreeHelper( model, item, m_root);
m_count = -1 ; m_count = -1;
} }
static void DestroyTreeHelper( wxDataViewTreeNode * node ) static void DestroyTreeHelper( wxDataViewTreeNode * node )
@@ -3599,9 +3603,9 @@ static void DestroyTreeHelper( wxDataViewTreeNode * node )
if( node->GetNodeNumber() != 0 ) if( node->GetNodeNumber() != 0 )
{ {
int len = node->GetNodeNumber(); int len = node->GetNodeNumber();
int i = 0 ; int i = 0;
wxDataViewTreeNodes& nodes = node->GetNodes(); wxDataViewTreeNodes& nodes = node->GetNodes();
for( ; i < len; i ++ ) for(; i < len; i ++ )
{ {
DestroyTreeHelper(nodes[i]); DestroyTreeHelper(nodes[i]);
} }
@@ -4101,7 +4105,7 @@ bool wxDataViewCtrl::Create(wxWindow *parent, wxWindowID id,
Init(); Init();
#ifdef __WXMAC__ #ifdef __WXMAC__
MacSetClipChildren( true ) ; MacSetClipChildren( true );
#endif #endif
m_clientArea = new wxDataViewMainWindow( this, wxID_ANY ); m_clientArea = new wxDataViewMainWindow( this, wxID_ANY );
@@ -4319,7 +4323,7 @@ int wxDataViewCtrl::GetSelections( wxDataViewItemArray & sel ) const
void wxDataViewCtrl::SetSelections( const wxDataViewItemArray & sel ) void wxDataViewCtrl::SetSelections( const wxDataViewItemArray & sel )
{ {
wxDataViewSelection selection(wxDataViewSelectionCmp) ; wxDataViewSelection selection(wxDataViewSelectionCmp);
int len = sel.GetCount(); int len = sel.GetCount();
for( int i = 0; i < len; i ++ ) for( int i = 0; i < len; i ++ )
{ {
@@ -4375,7 +4379,7 @@ int wxDataViewCtrl::GetSelections( wxArrayInt & sel ) const
void wxDataViewCtrl::SetSelections( const wxArrayInt & sel ) void wxDataViewCtrl::SetSelections( const wxArrayInt & sel )
{ {
wxDataViewSelection selection(wxDataViewSelectionCmp) ; wxDataViewSelection selection(wxDataViewSelectionCmp);
int len = sel.GetCount(); int len = sel.GetCount();
for( int i = 0; i < len; i ++ ) for( int i = 0; i < len; i ++ )
{ {