\membersection{wxDataViewCtrl::DeleteColumn}\label{wxdataviewctrldeletecolumn}
-\func{virtual bool}{DeleteColumn}{\param{unsigned int }{pos}}
+\func{virtual bool}{DeleteColumn}{\param{const wxDataViewColumn* }{column}}
Deletes given column.
\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}
virtual bool AppendColumn( wxDataViewColumn *col );
- virtual unsigned int GetColumnCount() const;
-
- virtual bool DeleteColumn( unsigned int pos );
- virtual bool ClearColumns();
- virtual wxDataViewColumn* GetColumn( unsigned int pos ) const;
-
+ virtual unsigned int GetColumnCount() const = 0;
+ virtual wxDataViewColumn* GetColumn( unsigned int pos ) const = 0;
+
+ virtual bool DeleteColumn( wxDataViewColumn *column ) = 0;
+ virtual bool ClearColumns() = 0;
+
void SetExpanderColumn( wxDataViewColumn *col )
{ m_expander_column = col ; DoSetExpanderColumn(); }
wxDataViewColumn *GetExpanderColumn() const
private:
wxDataViewModel *m_model;
- wxList m_cols;
wxDataViewColumn *m_expander_column;
int m_indent ;
DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewColumn)
};
+WX_DECLARE_LIST(wxDataViewColumn, wxDataViewColumnList );
+
// ---------------------------------------------------------
// wxDataViewCtrl
// ---------------------------------------------------------
const wxValidator& validator = wxDefaultValidator );
virtual bool AssociateModel( wxDataViewModel *model );
+
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 int GetSelections( wxDataViewItemArray & sel ) const;
GtkWidget *m_treeview;
wxDataViewModelNotifier *m_notifier;
wxDataViewCtrlInternal *m_internal;
+ wxDataViewColumnList m_cols;
virtual void OnInternalIdle();
wxDataViewCtrlBase::wxDataViewCtrlBase()
{
m_model = NULL;
- m_cols.DeleteContents( true );
m_expander_column = 0;
m_indent = 8;
}
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)
{
m_model->DecRef();
bool
wxDataViewCtrlBase::AppendColumn( wxDataViewColumn *col )
{
- m_cols.Append( (wxObject*) col );
col->SetOwner( (wxDataViewCtrl*) this );
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
// ---------------------------------------------------------
IMPLEMENT_CLASS(wxDataViewColumn, wxDataViewColumnBase)
+#include <wx/listimpl.cpp>
+WX_DEFINE_LIST(wxDataViewColumnList);
+
wxDataViewColumn::wxDataViewColumn( const wxString &title, wxDataViewRenderer *cell,
unsigned int model_column, int width,
wxAlignment align, int flags ) :
if (!wxDataViewCtrlBase::AppendColumn(col))
return false;
- GtkTreeViewColumn *column = (GtkTreeViewColumn *)col->GetGtkHandle();
+ m_cols.Append( col );
+
+ gtk_tree_view_append_column( GTK_TREE_VIEW(m_treeview),
+ GTK_TREE_VIEW_COLUMN(col->GetGtkHandle()) );
+
+ 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 );
- gtk_tree_view_append_column( GTK_TREE_VIEW(m_treeview), 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 )
{
GtkTreeIter iter;