Setting foreground color for rows in a TreeView



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


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