Use wxVector instead of wxList for wxDataViewCtrl columns storage
As wxDataViewColumnList was never public, it should be fine to not define it any more and use a vector instead. This makes the code more clear and also marginally more efficient.
This commit is contained in:
@@ -12,7 +12,6 @@
|
|||||||
|
|
||||||
#include "wx/defs.h"
|
#include "wx/defs.h"
|
||||||
#include "wx/object.h"
|
#include "wx/object.h"
|
||||||
#include "wx/list.h"
|
|
||||||
#include "wx/control.h"
|
#include "wx/control.h"
|
||||||
#include "wx/scrolwin.h"
|
#include "wx/scrolwin.h"
|
||||||
#include "wx/icon.h"
|
#include "wx/icon.h"
|
||||||
@@ -179,9 +178,6 @@ private:
|
|||||||
// wxDataViewCtrl
|
// wxDataViewCtrl
|
||||||
// ---------------------------------------------------------
|
// ---------------------------------------------------------
|
||||||
|
|
||||||
WX_DECLARE_LIST_WITH_DECL(wxDataViewColumn, wxDataViewColumnList,
|
|
||||||
class WXDLLIMPEXP_CORE);
|
|
||||||
|
|
||||||
class WXDLLIMPEXP_CORE wxDataViewCtrl : public wxDataViewCtrlBase,
|
class WXDLLIMPEXP_CORE wxDataViewCtrl : public wxDataViewCtrlBase,
|
||||||
public wxScrollHelper
|
public wxScrollHelper
|
||||||
{
|
{
|
||||||
@@ -366,7 +362,9 @@ private:
|
|||||||
void InvalidateColBestWidth(int idx);
|
void InvalidateColBestWidth(int idx);
|
||||||
void UpdateColWidths();
|
void UpdateColWidths();
|
||||||
|
|
||||||
wxDataViewColumnList m_cols;
|
void DoClearColumns();
|
||||||
|
|
||||||
|
wxVector<wxDataViewColumn*> m_cols;
|
||||||
// cached column best widths information, values are for
|
// cached column best widths information, values are for
|
||||||
// respective columns from m_cols and the arrays have same size
|
// respective columns from m_cols and the arrays have same size
|
||||||
struct CachedColWidthInfo
|
struct CachedColWidthInfo
|
||||||
|
@@ -5054,8 +5054,6 @@ void wxDataViewMainWindow::UpdateColumnSizes()
|
|||||||
// wxDataViewCtrl
|
// wxDataViewCtrl
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
WX_DEFINE_LIST(wxDataViewColumnList)
|
|
||||||
|
|
||||||
wxIMPLEMENT_DYNAMIC_CLASS(wxDataViewCtrl, wxDataViewCtrlBase);
|
wxIMPLEMENT_DYNAMIC_CLASS(wxDataViewCtrl, wxDataViewCtrlBase);
|
||||||
wxBEGIN_EVENT_TABLE(wxDataViewCtrl, wxDataViewCtrlBase)
|
wxBEGIN_EVENT_TABLE(wxDataViewCtrl, wxDataViewCtrlBase)
|
||||||
EVT_SIZE(wxDataViewCtrl::OnSize)
|
EVT_SIZE(wxDataViewCtrl::OnSize)
|
||||||
@@ -5066,8 +5064,7 @@ wxDataViewCtrl::~wxDataViewCtrl()
|
|||||||
if (m_notifier)
|
if (m_notifier)
|
||||||
GetModel()->RemoveNotifier( m_notifier );
|
GetModel()->RemoveNotifier( m_notifier );
|
||||||
|
|
||||||
m_cols.Clear();
|
DoClearColumns();
|
||||||
m_colsBestWidths.clear();
|
|
||||||
|
|
||||||
#if wxUSE_ACCESSIBILITY
|
#if wxUSE_ACCESSIBILITY
|
||||||
SetAccessible(NULL);
|
SetAccessible(NULL);
|
||||||
@@ -5077,7 +5074,6 @@ wxDataViewCtrl::~wxDataViewCtrl()
|
|||||||
|
|
||||||
void wxDataViewCtrl::Init()
|
void wxDataViewCtrl::Init()
|
||||||
{
|
{
|
||||||
m_cols.DeleteContents(true);
|
|
||||||
m_notifier = NULL;
|
m_notifier = NULL;
|
||||||
|
|
||||||
m_headerArea = NULL;
|
m_headerArea = NULL;
|
||||||
@@ -5329,7 +5325,7 @@ bool wxDataViewCtrl::AppendColumn( wxDataViewColumn *col )
|
|||||||
if (!wxDataViewCtrlBase::AppendColumn(col))
|
if (!wxDataViewCtrlBase::AppendColumn(col))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
m_cols.Append( col );
|
m_cols.push_back( col );
|
||||||
m_colsBestWidths.push_back(CachedColWidthInfo());
|
m_colsBestWidths.push_back(CachedColWidthInfo());
|
||||||
OnColumnsCountChanged();
|
OnColumnsCountChanged();
|
||||||
return true;
|
return true;
|
||||||
@@ -5340,7 +5336,7 @@ bool wxDataViewCtrl::PrependColumn( wxDataViewColumn *col )
|
|||||||
if (!wxDataViewCtrlBase::PrependColumn(col))
|
if (!wxDataViewCtrlBase::PrependColumn(col))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
m_cols.Insert( col );
|
m_cols.insert(m_cols.begin(), col);
|
||||||
m_colsBestWidths.insert(m_colsBestWidths.begin(), CachedColWidthInfo());
|
m_colsBestWidths.insert(m_colsBestWidths.begin(), CachedColWidthInfo());
|
||||||
OnColumnsCountChanged();
|
OnColumnsCountChanged();
|
||||||
return true;
|
return true;
|
||||||
@@ -5351,7 +5347,7 @@ bool wxDataViewCtrl::InsertColumn( unsigned int pos, wxDataViewColumn *col )
|
|||||||
if (!wxDataViewCtrlBase::InsertColumn(pos,col))
|
if (!wxDataViewCtrlBase::InsertColumn(pos,col))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
m_cols.Insert( pos, col );
|
m_cols.insert(m_cols.begin() + pos, col);
|
||||||
m_colsBestWidths.insert(m_colsBestWidths.begin() + pos, CachedColWidthInfo());
|
m_colsBestWidths.insert(m_colsBestWidths.begin() + pos, CachedColWidthInfo());
|
||||||
OnColumnsCountChanged();
|
OnColumnsCountChanged();
|
||||||
return true;
|
return true;
|
||||||
@@ -5400,7 +5396,7 @@ void wxDataViewCtrl::DoSetIndent()
|
|||||||
|
|
||||||
unsigned int wxDataViewCtrl::GetColumnCount() const
|
unsigned int wxDataViewCtrl::GetColumnCount() const
|
||||||
{
|
{
|
||||||
return m_cols.GetCount();
|
return m_cols.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxDataViewCtrl::SetRowHeight( int lineHeight )
|
bool wxDataViewCtrl::SetRowHeight( int lineHeight )
|
||||||
@@ -5552,12 +5548,12 @@ void wxDataViewCtrl::ColumnMoved(wxDataViewColumn *col, unsigned int new_pos)
|
|||||||
|
|
||||||
bool wxDataViewCtrl::DeleteColumn( wxDataViewColumn *column )
|
bool wxDataViewCtrl::DeleteColumn( wxDataViewColumn *column )
|
||||||
{
|
{
|
||||||
wxDataViewColumnList::compatibility_iterator ret = m_cols.Find( column );
|
const int idx = GetColumnIndex(column);
|
||||||
if (!ret)
|
if ( idx == wxNOT_FOUND )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
m_colsBestWidths.erase(m_colsBestWidths.begin() + GetColumnIndex(column));
|
m_colsBestWidths.erase(m_colsBestWidths.begin() + idx);
|
||||||
m_cols.Erase(ret);
|
m_cols.erase(m_cols.begin() + idx);
|
||||||
|
|
||||||
if ( m_clientArea->GetCurrentColumn() == column )
|
if ( m_clientArea->GetCurrentColumn() == column )
|
||||||
m_clientArea->ClearCurrentColumn();
|
m_clientArea->ClearCurrentColumn();
|
||||||
@@ -5567,10 +5563,20 @@ bool wxDataViewCtrl::DeleteColumn( wxDataViewColumn *column )
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void wxDataViewCtrl::DoClearColumns()
|
||||||
|
{
|
||||||
|
typedef wxVector<wxDataViewColumn*>::const_iterator citer;
|
||||||
|
for ( citer it = m_cols.begin(); it != m_cols.end(); ++it )
|
||||||
|
delete *it;
|
||||||
|
}
|
||||||
|
|
||||||
bool wxDataViewCtrl::ClearColumns()
|
bool wxDataViewCtrl::ClearColumns()
|
||||||
{
|
{
|
||||||
SetExpanderColumn(NULL);
|
SetExpanderColumn(NULL);
|
||||||
m_cols.Clear();
|
|
||||||
|
DoClearColumns();
|
||||||
|
|
||||||
|
m_cols.clear();
|
||||||
m_sortingColumnIdxs.clear();
|
m_sortingColumnIdxs.clear();
|
||||||
m_colsBestWidths.clear();
|
m_colsBestWidths.clear();
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user