Re: [gtkmm] TreeView text color



On Tue, 2 Sep 2003 17:47:20 +0200
Markus Gerwinski <markus gerwinski de> wrote:

> Hi folks,
> 
> is there a way to change the text color of a single cell of a TreeView,
> depending on its value? (E.g. display negative numbers in red, positive ones in
> black; or display "done" rows in green, rows "in progress" in blue, and
> "stopped" rows in red; or...)
> 

The ModelColumns:

  struct ModelColumns : public Gtk::TreeModelColumnRecord
  {
    ...
    Gtk::TreeModelColumn<Gdk::Color>    color_;
    ...
    
    ModelColumns() { ... add(color_); ...}
  };
  ModelColumns m_columns;

And where you create the cellrenderers:

  {
    Gtk::CellRendererText* pRenderer = Gtk::manage( new Gtk::CellRendererText() );

    int cols_count =m_TreeView.append_column(_("Color"), *pRenderer);
    Gtk::TreeViewColumn* pColumn =m_TreeView.get_column(cols_count-1);

    pColumn->add_attribute(pRenderer->property_text(), m_columns.color);
    
    pColumn->add_attribute(pRenderer->property_foreground_gdk(), m_columns.color_);
    pColumn->add_attribute(pRenderer->property_weight(), m_columns.weight_);
  }


Regards
Daniel Sundberg
http://sumpan.com

> Thanks in advance,
> 
>   Markus
> _______________________________________________
> 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]