Re: Setting foreground color for rows in a TreeView



Frankly, I do not know.  When I first began using gtkmm, this issue was one with which I struggled a great deal.

Bob Caryl

Joost Ellerbroek wrote:
That might work, but then why does property_background() work, and not
property_foreground() ?

On 8/9/06, Robert Caryl <bob fis-cal com> wrote:
You might want to take a look at getting a Pango::Layout on the text
that is rendered.  Once you have the layout, you can then get a list of
the attributes applied to the text and then you can modify the
foreground color attribute.  Once this is accomplished, you can re-apply
the attributes to the layout.  See the docs for detail on how to use Pango.

Bob Caryl


Joost Ellerbroek wrote:
> I've had a look at the mailinglist archive, but only found an example
> of setting individual cell background.
> This I did get to work, but when I try to adapt it to change
> foreground color nothing happens: all text stays black.
> Could this have something to do with gtk styles?
>
> This is what I do now:
> -----------------------------------------------
>     Gtk::CellRendererText*            cell_renderer;
>     expModelPtr                        pModel        =
> expModelPtr::cast_dynamic(pView->get_model());
>     vector<Gtk::TreeViewColumn*>    columns        = pView->get_columns();
>
>     for(vector<Gtk::TreeViewColumn*>::iterator iter = columns.begin();
> iter != columns.end(); iter++)
>     {
>         cell_renderer        =
> dynamic_cast<Gtk::CellRendererText*>((*iter)->get_first_cell_renderer());
>         (*iter)->add_attribute(cell_renderer->property_foreground(),
> pModel->colrecord.m_col_color);
>     };
> -----------------------------------------------
>
>
> This method works with a Gtk::CellRenderer* and
> property_cell_background().
> The TreeView only contains text columns, so according to the api
> reference, dynamic_cast<Gtk::CellRendererText*>() should work.
>
> Any ideas?
>
> Joost
> ------------------------------------------------------------------------
>
> _______________________________________________
> gtkmm-list mailing list
> gtkmm-list gnome org
> http://mail.gnome.org/mailman/listinfo/gtkmm-list
>





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