use type safe list instead of wxList for m_columns
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@10843 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -314,12 +314,16 @@ private:
|
|||||||
// wxListMainWindow (internal)
|
// wxListMainWindow (internal)
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
WX_DECLARE_LIST(wxListHeaderData, wxListHeaderDataList);
|
||||||
|
#include "wx/listimpl.cpp"
|
||||||
|
WX_DEFINE_LIST(wxListHeaderDataList);
|
||||||
|
|
||||||
class WXDLLEXPORT wxListMainWindow: public wxScrolledWindow
|
class WXDLLEXPORT wxListMainWindow: public wxScrolledWindow
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
long m_mode;
|
long m_mode;
|
||||||
wxListLineDataArray m_lines;
|
wxListLineDataArray m_lines;
|
||||||
wxList m_columns;
|
wxListHeaderDataList m_columns;
|
||||||
wxListLineData *m_current;
|
wxListLineData *m_current;
|
||||||
wxListLineData *m_currentEdit;
|
wxListLineData *m_currentEdit;
|
||||||
int m_visibleLines;
|
int m_visibleLines;
|
||||||
@@ -2501,12 +2505,12 @@ int wxListMainWindow::GetItemSpacing( bool isSmall )
|
|||||||
void wxListMainWindow::SetColumn( int col, wxListItem &item )
|
void wxListMainWindow::SetColumn( int col, wxListItem &item )
|
||||||
{
|
{
|
||||||
m_dirty = TRUE;
|
m_dirty = TRUE;
|
||||||
wxNode *node = m_columns.Nth( col );
|
wxListHeaderDataList::Node *node = m_columns.Item( col );
|
||||||
if (node)
|
if (node)
|
||||||
{
|
{
|
||||||
if (item.m_width == wxLIST_AUTOSIZE_USEHEADER)
|
if (item.m_width == wxLIST_AUTOSIZE_USEHEADER)
|
||||||
item.m_width = GetTextLength( item.m_text )+7;
|
item.m_width = GetTextLength( item.m_text )+7;
|
||||||
wxListHeaderData *column = (wxListHeaderData*)node->Data();
|
wxListHeaderData *column = node->GetData();
|
||||||
column->SetItem( item );
|
column->SetItem( item );
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2522,8 +2526,6 @@ void wxListMainWindow::SetColumnWidth( int col, int width )
|
|||||||
|
|
||||||
m_dirty = TRUE;
|
m_dirty = TRUE;
|
||||||
|
|
||||||
wxNode *node = (wxNode*) NULL;
|
|
||||||
|
|
||||||
if (width == wxLIST_AUTOSIZE_USEHEADER)
|
if (width == wxLIST_AUTOSIZE_USEHEADER)
|
||||||
{
|
{
|
||||||
// TODO do use the header
|
// TODO do use the header
|
||||||
@@ -2562,10 +2564,10 @@ void wxListMainWindow::SetColumnWidth( int col, int width )
|
|||||||
width = max+10;
|
width = max+10;
|
||||||
}
|
}
|
||||||
|
|
||||||
node = m_columns.Nth( col );
|
wxListHeaderDataList::Node *node = m_columns.Item( col );
|
||||||
if (node)
|
if (node)
|
||||||
{
|
{
|
||||||
wxListHeaderData *column = (wxListHeaderData*)node->Data();
|
wxListHeaderData *column = node->GetData();
|
||||||
column->SetWidth( width );
|
column->SetWidth( width );
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2588,10 +2590,10 @@ void wxListMainWindow::SetColumnWidth( int col, int width )
|
|||||||
|
|
||||||
void wxListMainWindow::GetColumn( int col, wxListItem &item )
|
void wxListMainWindow::GetColumn( int col, wxListItem &item )
|
||||||
{
|
{
|
||||||
wxNode *node = m_columns.Nth( col );
|
wxListHeaderDataList::Node *node = m_columns.Item( col );
|
||||||
if (node)
|
if (node)
|
||||||
{
|
{
|
||||||
wxListHeaderData *column = (wxListHeaderData*)node->Data();
|
wxListHeaderData *column = node->GetData();
|
||||||
column->GetItem( item );
|
column->GetItem( item );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -2606,21 +2608,16 @@ void wxListMainWindow::GetColumn( int col, wxListItem &item )
|
|||||||
|
|
||||||
int wxListMainWindow::GetColumnWidth( int col )
|
int wxListMainWindow::GetColumnWidth( int col )
|
||||||
{
|
{
|
||||||
wxNode *node = m_columns.Nth( col );
|
wxListHeaderDataList::Node *node = m_columns.Item( col );
|
||||||
if (node)
|
wxCHECK_MSG( node, 0, _T("invalid column index") );
|
||||||
{
|
|
||||||
wxListHeaderData *column = (wxListHeaderData*)node->Data();
|
wxListHeaderData *column = node->GetData();
|
||||||
return column->GetWidth();
|
return column->GetWidth();
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int wxListMainWindow::GetColumnCount()
|
int wxListMainWindow::GetColumnCount()
|
||||||
{
|
{
|
||||||
return m_columns.Number();
|
return m_columns.GetCount();
|
||||||
}
|
}
|
||||||
|
|
||||||
int wxListMainWindow::GetCountPerPage()
|
int wxListMainWindow::GetCountPerPage()
|
||||||
@@ -2997,12 +2994,12 @@ void wxListMainWindow::DeleteItem( long index )
|
|||||||
|
|
||||||
void wxListMainWindow::DeleteColumn( int col )
|
void wxListMainWindow::DeleteColumn( int col )
|
||||||
{
|
{
|
||||||
wxCHECK_RET( col < (int)m_columns.GetCount(),
|
wxListHeaderDataList::Node *node = m_columns.Item( col );
|
||||||
wxT("attempting to delete inexistent column in wxListView") );
|
|
||||||
|
wxCHECK_RET( node, wxT("invalid column index in DeleteColumn()") );
|
||||||
|
|
||||||
m_dirty = TRUE;
|
m_dirty = TRUE;
|
||||||
wxNode *node = m_columns.Nth( col );
|
m_columns.DeleteNode( node );
|
||||||
if (node) m_columns.DeleteNode( node );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxListMainWindow::DeleteAllItems()
|
void wxListMainWindow::DeleteAllItems()
|
||||||
@@ -3137,9 +3134,8 @@ void wxListMainWindow::InsertColumn( long col, wxListItem &item )
|
|||||||
wxListHeaderData *column = new wxListHeaderData( item );
|
wxListHeaderData *column = new wxListHeaderData( item );
|
||||||
if ((col >= 0) && (col < (int)m_columns.GetCount()))
|
if ((col >= 0) && (col < (int)m_columns.GetCount()))
|
||||||
{
|
{
|
||||||
wxNode *node = m_columns.Nth( (size_t)col );
|
wxListHeaderDataList::Node *node = m_columns.Item( col );
|
||||||
if (node)
|
m_columns.Insert( node, column );
|
||||||
m_columns.Insert( node, column );
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -3676,7 +3672,8 @@ bool wxListCtrl::DeleteAllItems()
|
|||||||
|
|
||||||
bool wxListCtrl::DeleteAllColumns()
|
bool wxListCtrl::DeleteAllColumns()
|
||||||
{
|
{
|
||||||
for ( size_t n = 0; n < m_mainWin->m_columns.GetCount(); n++ )
|
size_t count = m_mainWin->m_columns.GetCount();
|
||||||
|
for ( size_t n = 0; n < count; n++ )
|
||||||
DeleteColumn(n);
|
DeleteColumn(n);
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
Reference in New Issue
Block a user