Re: EuGTK - setRow
- Posted by irv Sep 21, 2010
- 1471 views
No, CreateLV returns an iterator, and a sequence of n text renderers, one for each column in your list. So, 4 columns should use CreateLV(4)
Now, the reason you are getting the error is because setRow doesn't do what you think it does - nope, that would be too easy.
Think about it for a minute: if you were to set the 4th row from the top to be colored red, for example, what would happen when you sort or drag the data in that row somewhere else? The red wouldn't move with the data, and that would normally be what you would want it to do, I think. At least, that's what the people who wrote GTK thought.
So... setRow needs the following parameters:
- a COLUMN # or a range of COL #'s: {start, fini} that you want to have this color or font
- the tv
- the lv
- a string specifying "background", "foreground", or "font"...
- a COLUMN # in your store which contains a color description - "red". for example, to be associated with this item
A column must be declared in your store to hold this string, so it is declared as a gSTR (in List:Store()) You probably don't want to display the strings, so you do not declare a column to show this (in List:View()) Clear as mud yet?
That way, in your list of foods, all the green veggies would have a shade of green "lightgreen", "darkgreen", etc. in the COLOR column, all the red meats could have a shade of red.... etc.
So when you move Broccoli around in the list, Broccoli's nice green color moves with it.
If you just want an entire column to be one color, you can use setCol with the color spelled out as a string. If you just want more than one column to be one color, you can - strangely enough - use setRow({2,4}..."red"). No, it doesn't make any sense.
Looks like setRow needs a more descriptive name. SetTheColorOfTheItemInColumn:n,UsingTheColorNameStoredWithThatRow()
object names = { {"Jerry S. Smith",21,"Rover","red","lightgray","Courier 12"}, {"Jonnie B. Goode",44,"Fluffy"}, {"Susan Black",45}, {"Fred Flintstone",55, "Dino", "cyan", "blue", "Beat My Guest 16"}, {"George Burns",112,"cigar","white","red", ""} } -- note: you do not need to fill in more that required - if, like Susan, you don't HAVE a pet, leave it out. -- if Susan had no pet, but we still needed to set a background color for her, we could write: -- {"Susan Black",45,0,"cyan"... the zero gets skipped over, leaving the 'pet' blank -- -- note2: we can't skip over a number like we can with a string - if we leave off Susan's age, -- it will display as zero.