Re: Coloring specific rows in a Gtk::TreeView

Sai wrote:

Is coloring specific rows in a Gtk::TreeView possible ?. If yes please tell me how. I have no clue on how to color specific rows.

Yes. Here is editted example for coloring cells of single column depending on content (like 'OK' green and 'ERROR' red).

 int colNum = treeView.append_column("Foo", m_columns.m_foo) - 1;

   set_cell_data_func(*treeView .get_column_cell_renderer(colNum),
                       sigc::mem_fun(*this, &Foo::set_verdict_color));

void Foo::set_verdict_color(Gtk::CellRenderer* cell,
const Gtk::TreeModel::iterator& iter)
 // implement getBackgroundColor!!!
 const char *bkCol = getBackgroundColor(*iter);
 cell->property_cell_background() = bkCol;

One can change foreground color in the same way.
(Copied example from own program and editted)

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