[wx-dev] wxDataViewCtrl cell attributes

Vadim Zeitlin vadim at wxwindows.org
Fri Jun 1 06:49:17 PDT 2007


On Wed, 30 May 2007 23:13:50 +0200 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? I'd expect it to be wxDataItemAttr or
maybe just wxItemAttr (of course, wxListItemAttr could become just a
typedef for the new class name).

RR> This is easy and works, but I realized that
RR> this will obviously propagate into every
RR> wxDataViewCtrl that displays that model (see
RR> sample, just start it under GTK+).
RR> 
RR> I wonder if that is what we want or if we want
RR> to set things like background colour and maybe
RR> fonts differently for different wxDataViewCtrls.

 This is what I'd expect.

RR> In reality people won't use two or more controls
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 (it could make sense to
define things like items alignment there) with those of the control IIRC.
So the ideal solution would probably be to do the same in wxDataViewCtrl.
But failing that I'd rather have the attributes in the control than in the
model.

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().

 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.

 Regards,
VZ





More information about the wx-dev mailing list