Re: [gtkmm] treeview --- custom celrenderer..



B.Hakvoort wrote:

Hi,

I try to show colored squares in my treeview. For anyone who wonders
what i'm talking about, look here :) (the colored squares in front of
the filesystems) http://members.cox.net/tribblehunter/tech/partition.jpg

I've tried to make use of the CellRendererToggle, but i wasn't able to
access the widget (which i need to change the background color)
I'd suggest the following implementation for column "Type" that you've reffered:

1. Write custom CellRenderer, where you'd just paint colored square:
   - reimplement get_size_vfunc - to set size of your color cell;
- reimplement render_vfunc - to draw the square (Gdk::Drawable has lot of functions you may wish to use for that - draw_rectangle(), for instance).
2. Create TreeView::Column and pack there 2 CellRenderers:  Custom + Text.
3. Link Custom CellRenderer attribute (property) that will handle color selection with Text Cellrenderer value or hidded column.

Of course i could use images, but i would prefer to handle this in the
sourcecode...

Hopefully someone can give me the complete solution, but i will settle
for a pointer or even a vague hint :)





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