Re: inserting ColorButton in CellRenderer ....

В Срд, 12/03/2008 в 20:24 -0400, Roberto Alejandro Espí Muñoz пишет:
> Hi!! I'm trying to use the TreeView widget to show a series of fields
> I have predefined.  One of those is a color atributte.  I was thinking
> maybe using a ColorButton per row.  When I tried to insert it though I
> noticed that the CellRenderer class that determines special kinds of
> widgets on rows only allows a group of them.  My question is, how can
> I insert the ColorButton widget in the TreeView or can anyone let me
> know of a workaround of displaying a color attribute field?? 

Just create your own renderer:

class UserCellRendererColorButton : public CellRenderer

override get_size_vfunc, render_vfunc and add (or reuse from
CellRenderer) properties you will read to draw the button widget (you
will need color value at least).

Inside get_size_vfunc you should set dimensions for ColorButton widget.

Inside render_vfunc you should use method from Gtk::Style that draws
Button (ColorButton) widget.

When creating TreeViewColumn, you should set attribute:

treeColumn->add_attribute( yourRenderer->your_color_property(), yourColumnModel.colorButtonColumn );

Simple, and always works :)


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