Re: Coloring specific rows in a Gtk::TreeView



If it's helpful, here's a program I've been working on that includes rendering a specific cell from a specific row and column. The source file you'll need to look at is CGtkPkgList.h

http://users.axxium.us/user-accounts/sparky/packages/zendo/0.5/zendo-0.5.tar.gz

On Wed, 30 Jul 2008, Sai wrote:

Hi,

Thanks a lot for the reply.

I tried this out. But it colors all the cells in a column. But the need is
coloring specific cells among all the cells in the column (depending upon the
value stored in the rows). ( A column can have many rows, among all these
rows very few need to be colored ). Can you please give me some ideas on
this?


On Wed, Jul 30, 2008 at 7:26 PM, Andris Pavenis <andris pavenis iki fi>
wrote:
      Sai wrote:
            Hi,

            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;

 treeView.get_column(colNum)->
  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]