const wxChar wxDataViewCtrlNameStr[] = wxT("dataviewCtrl");
-// ---------------------------------------------------------
-// wxDataViewModel
-// ---------------------------------------------------------
-
-IMPLEMENT_ABSTRACT_CLASS(wxDataViewModel, wxObject)
// ---------------------------------------------------------
// wxDataViewListModel
// ---------------------------------------------------------
-IMPLEMENT_ABSTRACT_CLASS(wxDataViewListModel, wxDataViewModel)
-
wxDataViewListModel::wxDataViewListModel()
{
m_viewingColumns.DeleteContents( true );
wxDataViewListModel::~wxDataViewListModel()
{
+ wxList::compatibility_iterator node = m_notifiers.GetFirst();
+ while (node)
+ {
+ wxDataViewListModelNotifier* notifier = (wxDataViewListModelNotifier*) node->GetData();
+ notifier->Freed();
+ node = node->GetNext();
+ }
}
bool wxDataViewListModel::RowAppended()
virtual bool Cleared()
{ return m_model->ChildCleared(); }
+ virtual bool Freed()
+ { m_model->m_child = NULL; return wxDataViewListModelNotifier::Freed(); }
+
wxDataViewSortedListModel *m_model;
};
// wxDataViewSortedListModel
// ---------------------------------------------------------
-IMPLEMENT_ABSTRACT_CLASS(wxDataViewSortedListModel, wxDataViewListModel)
-
wxDataViewSortedListModel::wxDataViewSortedListModel( wxDataViewListModel *child ) :
m_array( wxDataViewIntermediateCmp )
{
wxDataViewSortedListModel::~wxDataViewSortedListModel()
{
+ if (m_child)
m_child->RemoveNotifier( m_notifierOnChild );
}
InitStatics();
m_array.Clear();
- unsigned int n = m_child->GetNumberOfRows();
+ unsigned int n = m_child->GetRowCount();
unsigned int i;
for (i = 0; i < n; i++)
m_array.Add( i );
#if 0
static void Dump( wxDataViewListModel *model, unsigned int col )
{
- unsigned int n = model->GetNumberOfRows();
+ unsigned int n = model->GetRowCount();
unsigned int i;
for (i = 0; i < n; i++)
{
return wxDataViewListModel::Cleared();
}
-unsigned int wxDataViewSortedListModel::GetNumberOfRows()
+unsigned int wxDataViewSortedListModel::GetRowCount() const
{
return m_array.GetCount();
}
-unsigned int wxDataViewSortedListModel::GetNumberOfCols()
+unsigned int wxDataViewSortedListModel::GetColumnCount() const
{
- return m_child->GetNumberOfCols();
+ return m_child->GetColumnCount();
}
-wxString wxDataViewSortedListModel::GetColType( unsigned int col )
+wxString wxDataViewSortedListModel::GetColumnType( unsigned int col ) const
{
- return m_child->GetColType( col );
+ return m_child->GetColumnType( col );
}
-void wxDataViewSortedListModel::GetValue( wxVariant &variant, unsigned int col, unsigned int row )
+void wxDataViewSortedListModel::GetValue( wxVariant &variant, unsigned int col, unsigned int row ) const
{
unsigned int child_row = m_array[row];
m_child->GetValue( variant, col, child_row );
IMPLEMENT_ABSTRACT_CLASS(wxDataViewRendererBase, wxObject)
-wxDataViewRendererBase::wxDataViewRendererBase( const wxString &varianttype, wxDataViewCellMode mode )
+wxDataViewRendererBase::wxDataViewRendererBase( const wxString &varianttype,
+ wxDataViewCellMode WXUNUSED(mode),
+ int WXUNUSED(align) )
{
m_variantType = varianttype;
- m_mode = mode;
+}
+
+const wxDataViewCtrl* wxDataViewRendererBase::GetView() const
+{
+ return wx_const_cast(wxDataViewRendererBase*, this)->GetOwner()->GetOwner();
}
// ---------------------------------------------------------
IMPLEMENT_ABSTRACT_CLASS(wxDataViewColumnBase, wxObject)
-wxDataViewColumnBase::wxDataViewColumnBase(const wxString& title,
+wxDataViewColumnBase::wxDataViewColumnBase(const wxString& WXUNUSED(title),
wxDataViewRenderer *renderer,
unsigned int model_column,
int WXUNUSED(width),
- int flags )
+ wxAlignment WXUNUSED(align),
+ int WXUNUSED(flags))
{
m_renderer = renderer;
m_model_column = model_column;
- m_flags = flags;
- m_title = title;
m_owner = NULL;
m_renderer->SetOwner( (wxDataViewColumn*) this );
+
+ // NOTE: the wxDataViewColumn's ctor must store the width, align, flags
+ // parameters inside the native control!
}
wxDataViewColumnBase::wxDataViewColumnBase(const wxBitmap& bitmap,
wxDataViewRenderer *renderer,
unsigned int model_column,
int WXUNUSED(width),
- int flags )
+ wxAlignment WXUNUSED(align),
+ int WXUNUSED(flags) )
{
m_renderer = renderer;
m_model_column = model_column;
- m_flags = flags;
m_bitmap = bitmap;
m_owner = NULL;
m_renderer->SetOwner( (wxDataViewColumn*) this );
}
}
-void wxDataViewColumnBase::SetTitle( const wxString &title )
+int wxDataViewColumnBase::GetFlags() const
{
- m_title = title;
-}
+ int ret = 0;
-wxString wxDataViewColumnBase::GetTitle()
-{
- return m_title;
-}
+ if (IsSortable())
+ ret |= wxDATAVIEW_COL_SORTABLE;
+ if (IsResizeable())
+ ret |= wxDATAVIEW_COL_RESIZABLE;
+ if (IsHidden())
+ ret |= wxDATAVIEW_COL_HIDDEN;
-void wxDataViewColumnBase::SetBitmap( const wxBitmap &bitmap )
-{
- m_bitmap = bitmap;
+ return ret;
}
-const wxBitmap &wxDataViewColumnBase::GetBitmap()
+void wxDataViewColumnBase::SetFlags(int flags)
{
- return m_bitmap;
+ SetSortable((flags & wxDATAVIEW_COL_SORTABLE) != 0);
+ SetResizeable((flags & wxDATAVIEW_COL_RESIZABLE) != 0);
+ SetHidden((flags & wxDATAVIEW_COL_HIDDEN) != 0);
}
+
// ---------------------------------------------------------
// 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)
+ {
+ m_model->DecRef();
+ m_model = NULL;
+ }
}
bool wxDataViewCtrlBase::AssociateModel( wxDataViewListModel *model )
{
+ if ( m_model )
+ m_model->DecRef(); // discard old model, if any
+
+ // add our own reference to the new model:
m_model = model;
+ if ( m_model )
+ m_model->IncRef();
return true;
}
}
bool wxDataViewCtrlBase::AppendTextColumn( const wxString &label, unsigned int model_column,
- wxDataViewCellMode mode, int width )
+ wxDataViewCellMode mode, int width, wxAlignment align, int flags )
{
return AppendColumn( new wxDataViewColumn( label,
- new wxDataViewTextRenderer( wxT("string"), mode ), model_column, width ) );
+ new wxDataViewTextRenderer( wxT("string"), mode, (int)align ),
+ model_column, width, align, flags ) );
}
bool wxDataViewCtrlBase::AppendToggleColumn( const wxString &label, unsigned int model_column,
- wxDataViewCellMode mode, int width )
+ wxDataViewCellMode mode, int width, wxAlignment align, int flags )
{
return AppendColumn( new wxDataViewColumn( label,
- new wxDataViewToggleRenderer( wxT("bool"), mode ), model_column, width ) );
+ new wxDataViewToggleRenderer( wxT("bool"), mode, (int)align ),
+ model_column, width, align, flags ) );
}
bool wxDataViewCtrlBase::AppendProgressColumn( const wxString &label, unsigned int model_column,
- wxDataViewCellMode mode, int width )
+ wxDataViewCellMode mode, int width, wxAlignment align, int flags )
{
return AppendColumn( new wxDataViewColumn( label,
- new wxDataViewProgressRenderer( wxEmptyString, wxT("long"), mode ), model_column, width ) );
+ new wxDataViewProgressRenderer( wxEmptyString, wxT("long"), mode, (int)align ),
+ model_column, width, align, flags ) );
}
bool wxDataViewCtrlBase::AppendDateColumn( const wxString &label, unsigned int model_column,
- wxDataViewCellMode mode, int width )
+ wxDataViewCellMode mode, int width, wxAlignment align, int flags )
{
return AppendColumn( new wxDataViewColumn( label,
- new wxDataViewDateRenderer( wxT("datetime"), mode), model_column, width ) );
+ new wxDataViewDateRenderer( wxT("datetime"), mode, (int)align ),
+ model_column, width, align, flags ) );
}
bool wxDataViewCtrlBase::AppendBitmapColumn( const wxString &label, unsigned int model_column,
- wxDataViewCellMode mode, int width )
+ wxDataViewCellMode mode, int width, wxAlignment align, int flags )
{
return AppendColumn( new wxDataViewColumn( label,
- new wxDataViewBitmapRenderer( wxT("wxBitmap"), mode ), model_column, width ) );
+ new wxDataViewBitmapRenderer( wxT("wxBitmap"), mode, (int)align ),
+ model_column, width, align, flags ) );
}
bool wxDataViewCtrlBase::AppendTextColumn( const wxBitmap &label, unsigned int model_column,
- wxDataViewCellMode mode, int width )
+ wxDataViewCellMode mode, int width, wxAlignment align, int flags )
{
return AppendColumn( new wxDataViewColumn( label,
- new wxDataViewTextRenderer( wxT("string"), mode ), model_column, width ) );
+ new wxDataViewTextRenderer( wxT("string"), mode, (int)align ),
+ model_column, width, align, flags ) );
}
bool wxDataViewCtrlBase::AppendToggleColumn( const wxBitmap &label, unsigned int model_column,
- wxDataViewCellMode mode, int width )
+ wxDataViewCellMode mode, int width, wxAlignment align, int flags )
{
return AppendColumn( new wxDataViewColumn( label,
- new wxDataViewToggleRenderer( wxT("bool"), mode ), model_column, width ) );
+ new wxDataViewToggleRenderer( wxT("bool"), mode, (int)align ),
+ model_column, width, align, flags ) );
}
bool wxDataViewCtrlBase::AppendProgressColumn( const wxBitmap &label, unsigned int model_column,
- wxDataViewCellMode mode, int width )
+ wxDataViewCellMode mode, int width, wxAlignment align, int flags )
{
return AppendColumn( new wxDataViewColumn( label,
- new wxDataViewProgressRenderer( wxEmptyString, wxT("long"), mode ), model_column, width ) );
+ new wxDataViewProgressRenderer( wxEmptyString, wxT("long"), mode, (int)align ),
+ model_column, width, align, flags ) );
}
bool wxDataViewCtrlBase::AppendDateColumn( const wxBitmap &label, unsigned int model_column,
- wxDataViewCellMode mode, int width )
+ wxDataViewCellMode mode, int width, wxAlignment align, int flags )
{
return AppendColumn( new wxDataViewColumn( label,
- new wxDataViewDateRenderer( wxT("datetime"), mode ), model_column, width ) );
+ new wxDataViewDateRenderer( wxT("datetime"), mode, (int)align ),
+ model_column, width, align, flags ) );
}
bool wxDataViewCtrlBase::AppendBitmapColumn( const wxBitmap &label, unsigned int model_column,
- wxDataViewCellMode mode, int width )
+ wxDataViewCellMode mode, int width, wxAlignment align, int flags )
{
return AppendColumn( new wxDataViewColumn( label,
- new wxDataViewBitmapRenderer( wxT("wxBitmap"), mode ), model_column, width ) );
+ new wxDataViewBitmapRenderer( wxT("wxBitmap"), mode, (int)align ),
+ model_column, width, align, flags ) );
}
bool wxDataViewCtrlBase::AppendColumn( wxDataViewColumn *col )
return true;
}
-unsigned int wxDataViewCtrlBase::GetNumberOfColumns()
+unsigned int wxDataViewCtrlBase::GetColumnCount() const
{
return m_cols.GetCount();
}