Move column organizing code to ports, away from common code

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@48391 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Robert Roebling
2007-08-26 10:05:16 +00:00
parent b1a3a96499
commit 91a6c65558
5 changed files with 75 additions and 41 deletions

View File

@@ -182,7 +182,7 @@ Collapses the item.
\membersection{wxDataViewCtrl::DeleteColumn}\label{wxdataviewctrldeletecolumn} \membersection{wxDataViewCtrl::DeleteColumn}\label{wxdataviewctrldeletecolumn}
\func{virtual bool}{DeleteColumn}{\param{unsigned int }{pos}} \func{virtual bool}{DeleteColumn}{\param{const wxDataViewColumn* }{column}}
Deletes given column. Deletes given column.
@@ -196,7 +196,9 @@ Expands the item.
\constfunc{virtual wxDataViewColumn*}{GetColumn}{\param{unsigned int }{pos}} \constfunc{virtual wxDataViewColumn*}{GetColumn}{\param{unsigned int }{pos}}
Returns pointer to the column. Returns pointer to the column. {\it pos} refers to the
position in the control which may change after reordering
columns by the user.
\membersection{wxDataViewCtrl::GetModel}\label{wxdataviewctrlgetmodel} \membersection{wxDataViewCtrl::GetModel}\label{wxdataviewctrlgetmodel}

View File

@@ -459,12 +459,12 @@ public:
virtual bool AppendColumn( wxDataViewColumn *col ); virtual bool AppendColumn( wxDataViewColumn *col );
virtual unsigned int GetColumnCount() const; virtual unsigned int GetColumnCount() const = 0;
virtual wxDataViewColumn* GetColumn( unsigned int pos ) const = 0;
virtual bool DeleteColumn( unsigned int pos );
virtual bool ClearColumns(); virtual bool DeleteColumn( wxDataViewColumn *column ) = 0;
virtual wxDataViewColumn* GetColumn( unsigned int pos ) const; virtual bool ClearColumns() = 0;
void SetExpanderColumn( wxDataViewColumn *col ) void SetExpanderColumn( wxDataViewColumn *col )
{ m_expander_column = col ; DoSetExpanderColumn(); } { m_expander_column = col ; DoSetExpanderColumn(); }
wxDataViewColumn *GetExpanderColumn() const wxDataViewColumn *GetExpanderColumn() const
@@ -499,7 +499,6 @@ protected:
private: private:
wxDataViewModel *m_model; wxDataViewModel *m_model;
wxList m_cols;
wxDataViewColumn *m_expander_column; wxDataViewColumn *m_expander_column;
int m_indent ; int m_indent ;

View File

@@ -275,6 +275,8 @@ protected:
DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewColumn) DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewColumn)
}; };
WX_DECLARE_LIST(wxDataViewColumn, wxDataViewColumnList );
// --------------------------------------------------------- // ---------------------------------------------------------
// wxDataViewCtrl // wxDataViewCtrl
// --------------------------------------------------------- // ---------------------------------------------------------
@@ -305,7 +307,12 @@ public:
const wxValidator& validator = wxDefaultValidator ); const wxValidator& validator = wxDefaultValidator );
virtual bool AssociateModel( wxDataViewModel *model ); virtual bool AssociateModel( wxDataViewModel *model );
virtual bool AppendColumn( wxDataViewColumn *col ); virtual bool AppendColumn( wxDataViewColumn *col );
virtual unsigned int GetColumnCount() const;
virtual wxDataViewColumn* GetColumn( unsigned int pos ) const;
virtual bool DeleteColumn( wxDataViewColumn *column );
virtual bool ClearColumns();
virtual wxDataViewItem GetSelection() const; virtual wxDataViewItem GetSelection() const;
virtual int GetSelections( wxDataViewItemArray & sel ) const; virtual int GetSelections( wxDataViewItemArray & sel ) const;
@@ -346,6 +353,7 @@ private:
GtkWidget *m_treeview; GtkWidget *m_treeview;
wxDataViewModelNotifier *m_notifier; wxDataViewModelNotifier *m_notifier;
wxDataViewCtrlInternal *m_internal; wxDataViewCtrlInternal *m_internal;
wxDataViewColumnList m_cols;
virtual void OnInternalIdle(); virtual void OnInternalIdle();

View File

@@ -539,18 +539,12 @@ IMPLEMENT_ABSTRACT_CLASS(wxDataViewCtrlBase, wxControl)
wxDataViewCtrlBase::wxDataViewCtrlBase() wxDataViewCtrlBase::wxDataViewCtrlBase()
{ {
m_model = NULL; m_model = NULL;
m_cols.DeleteContents( true );
m_expander_column = 0; m_expander_column = 0;
m_indent = 8; m_indent = 8;
} }
wxDataViewCtrlBase::~wxDataViewCtrlBase() wxDataViewCtrlBase::~wxDataViewCtrlBase()
{ {
// IMPORTANT: before calling DecRef() on our model (since it may
// result in a free() call), erase all columns (since
// they hold a pointer to our model)
m_cols.Clear();
if (m_model) if (m_model)
{ {
m_model->DecRef(); m_model->DecRef();
@@ -694,34 +688,10 @@ wxDataViewCtrlBase::AppendBitmapColumn( const wxBitmap &label, unsigned int mode
bool bool
wxDataViewCtrlBase::AppendColumn( wxDataViewColumn *col ) wxDataViewCtrlBase::AppendColumn( wxDataViewColumn *col )
{ {
m_cols.Append( (wxObject*) col );
col->SetOwner( (wxDataViewCtrl*) this ); col->SetOwner( (wxDataViewCtrl*) this );
return true; return true;
} }
unsigned int wxDataViewCtrlBase::GetColumnCount() const
{
return m_cols.GetCount();
}
bool wxDataViewCtrlBase::DeleteColumn( unsigned int WXUNUSED(pos) )
{
return false;
}
bool wxDataViewCtrlBase::ClearColumns()
{
return false;
}
wxDataViewColumn* wxDataViewCtrlBase::GetColumn( unsigned int pos ) const
{
if( pos >= m_cols.GetCount() )
return NULL;
return (wxDataViewColumn*) m_cols[ pos ];
}
// --------------------------------------------------------- // ---------------------------------------------------------
// wxDataViewEvent // wxDataViewEvent
// --------------------------------------------------------- // ---------------------------------------------------------

View File

@@ -1977,6 +1977,9 @@ static void wxGtkTreeCellDataFunc( GtkTreeViewColumn *column,
IMPLEMENT_CLASS(wxDataViewColumn, wxDataViewColumnBase) IMPLEMENT_CLASS(wxDataViewColumn, wxDataViewColumnBase)
#include <wx/listimpl.cpp>
WX_DEFINE_LIST(wxDataViewColumnList);
wxDataViewColumn::wxDataViewColumn( const wxString &title, wxDataViewRenderer *cell, wxDataViewColumn::wxDataViewColumn( const wxString &title, wxDataViewRenderer *cell,
unsigned int model_column, int width, unsigned int model_column, int width,
wxAlignment align, int flags ) : wxAlignment align, int flags ) :
@@ -2986,13 +2989,65 @@ bool wxDataViewCtrl::AppendColumn( wxDataViewColumn *col )
if (!wxDataViewCtrlBase::AppendColumn(col)) if (!wxDataViewCtrlBase::AppendColumn(col))
return false; return false;
GtkTreeViewColumn *column = (GtkTreeViewColumn *)col->GetGtkHandle(); m_cols.Append( col );
gtk_tree_view_append_column( GTK_TREE_VIEW(m_treeview), column ); gtk_tree_view_append_column( GTK_TREE_VIEW(m_treeview),
GTK_TREE_VIEW_COLUMN(col->GetGtkHandle()) );
return true; return true;
} }
unsigned int wxDataViewCtrl::GetColumnCount() const
{
return m_cols.GetCount();
}
wxDataViewColumn* wxDataViewCtrl::GetColumn( unsigned int pos ) const
{
GtkTreeViewColumn *gtk_col = gtk_tree_view_get_column( GTK_TREE_VIEW(m_treeview), pos );
if (!gtk_col)
return NULL;
wxDataViewColumnList::const_iterator iter;
for (iter = m_cols.begin(); iter != m_cols.end(); iter++)
{
wxDataViewColumn *col = *iter;
if (GTK_TREE_VIEW_COLUMN(col->GetGtkHandle()) == gtk_col)
{
return col;
}
}
return NULL;
}
bool wxDataViewCtrl::DeleteColumn( wxDataViewColumn *column )
{
gtk_tree_view_remove_column( GTK_TREE_VIEW(m_treeview),
GTK_TREE_VIEW_COLUMN(column->GetGtkHandle()) );
m_cols.remove( column );
delete column;
return true;
}
bool wxDataViewCtrl::ClearColumns()
{
wxDataViewColumnList::iterator iter;
for (iter = m_cols.begin(); iter != m_cols.end(); iter++)
{
wxDataViewColumn *col = *iter;
gtk_tree_view_remove_column( GTK_TREE_VIEW(m_treeview),
GTK_TREE_VIEW_COLUMN(col->GetGtkHandle()) );
}
m_cols.clear();
return true;
}
void wxDataViewCtrl::Expand( const wxDataViewItem & item ) void wxDataViewCtrl::Expand( const wxDataViewItem & item )
{ {
GtkTreeIter iter; GtkTreeIter iter;