Re: Colorizing rows in SimpleList revisited



On Friday, January 2, 2004, at 07:52 PM, John McDermott wrote:

The only problem is that this gives runtime warnings for cells not having a given attribute -- e.g. cells using the boolean renderer don't have a foreground color. My question is, how do I determine whether or not a given renderer supports a particular attribute?

it is possible to list the properties supported by an object, with $object->list_properties (or $class->list_properties).

however, this will be a real runtime hit, so you probably don't want to do it every time. two approaches would be:

1) use ref() to find the type of a cell renderer, and use that type to look up a function that knows how to colorize that cell renderer type.

2) after creating the model, create a cache of cell renderer types for each column, and query at this time whether they support the foreground property. then use that cached information later.

either way, you figure out ahead of time how to colorize a row, and you can either hand-code that knowledge or figure it out at runtime. since different renderers may use different names for the same attribute, i'd actually advocate method 1 here, which doesn't require listing properties at all.

--
"it's hard to be eventful when you have this much style."
   - me, rationalizing yet another night of sitting at home.




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]