[wx-dev] wxDataViewCtrl cell attributes

Robert Roebling robert at roebling.de
Fri Jun 1 10:30:21 PDT 2007


Vadim Zeitlin wrote:

> Robert Roebling wrote:
> 
> RR> I'm experimenting with cell attributes (such
> RR> as background colour) in wxDataViewCtrl and
> RR> planned to add an overridable method like
> RR> virtual void GetAttr( wxListItemAttr &attr, col, row );
> 
>  Is wxListItemAttr here intentional? 

Yes, I didn't just cut and paste the code yet :-)

> RR> to display a model very often, but cell attributes
> RR> "feel" like belonging to a view rather than the
> RR> model.
> 
>  Exactly.
> 
> RR> Any opinion?
> 
> The only other MVC control using attributes in wx is
> wxGrid AFAIK. And it actually combines the attributes
> of the table

Not sure what you mean here (what attributes of the
table?) but I'll look at that.

> RR> I'm acutally not sure how I'd
> RR> implement the API in wxDataViewCtrl. The easiest
> RR> would be something like OnGetItemAttr() as in the
> RR> virtual wxListCtrl.
> 
> Why not. Another possibility is to, again, copy wxGrid
> and have wxDataItemAttrProvider which would have (virtual)
> GetAttr().

Good idea, this way there is no need to derive from
wxDataViewCtrl.

> In fact, more importantly than just this particular issue,
> I strongly suggest reusing wxGrid-related classes. wxDataViewCtrl
> is rather similar to wxGrid from conceptual point of view and
> it would be a pity to have different API for working with them.
> And it could also facilitate migrating the code using wxGrid now
> to use wxDataViewCtrl.

No need to suggest there, the problem with the idea of having
the same renderer classes for both wxGrid and wxDataViewCtrl
is that under GTK+, some of the renderes are just native GTK+
renderers for the GtkTreeView whereas for wxGrid, all renderers
are generic. One could probably still define a common renderer
class and add an intermediate glue class between a generic renderer
and the GTK+ native renderer, but my energy ended there.

  Robert









More information about the wx-dev mailing list