Re: [gtkmm] Setting the background color of a specific cell in a Gtk::Treeview
- From: Liza Klerck <liza trdlnk com>
- To: Jarek Dukat <madmaxer poczta fm>
- Cc: Gtkmm <gtkmm-list gnome org>
- Subject: Re: [gtkmm] Setting the background color of a specific cell in a Gtk::Treeview
- Date: Thu, 09 Jan 2003 13:35:30 -0600
I understand that I have to change the cellrender for that cell but the problem
is that I don't know how to get to the CellRenderer - what I have is a TreeViewColumn
and a TreeModelRow and from those two I need to get at the CellRenderer.
Any ideas ?
//------------------
Here is some code to show hot to change the color for an entire column:
class ModelColumns : public Gtk::TreeModel::ColumnRecord
{
public:
ModelColumns() { add(m_col_i); add(m_col_visible);
}
Gtk::TreeModelColumn<int> m_col_i;
Gtk::TreeModelColumn<bool> m_col_visible;
};
ModelColumns m_Columns;
Gtk::TreeView m_TreeView;
Glib::RefPtr<Gtk::TreeStore> m_refTreeModel;
m_refTreeModel = Gtk::TreeStore::create(m_Columns);
m_TreeView.set_model(m_refTreeModel);
// Add a row with data
Gtk::TreeModel::Row row = *(m_refTreeModel->append());
row[m_Columns.m_col_i] = 99;
row[m_Columns.m_col_visible] = false;
// Append the column
int cols_count = m_TreeView.append_column("i", m_Columns.m_col_i);
Gtk::TreeViewColumn* pColumn = m_TreeView.get_column(cols_count-1);
if(pColumn)
{
// Set the background color for the entire column
Gtk::CellRendererText* pRenderer = static_cast<Gtk::CellRendererText*>(pColumn->get_first_cell_renderer());
Gdk::Color col("red");
renderer->property_background_gdk().set_value(col);
pColumn->add_attribute(renderer->property_visible(), m_Columns.m_col_visible);
}
Jarek Dukat wrote:
On Thu, 2003-01-09 at 17:56, Liza Klerck wrote:
I have a [Gtk::TreeViewColumn] and a [Gtk::TreeModel::Row] - how do I
get to the cellrenderer in order to set the background color of this
specific cell for this column and row in a Gtk::Treeview ? I need to set
and reset background colors for specific cells on certain events. I
understand how to set the background color of an entire column but need
to know how to set it for individual cells.
For single cell you must change background color property of the cell
renderer inside that cell.
Could you please tell us how you do it for entire column?
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]