Re: [gtkmm] Understanding TreeView



On Sun, 2002-07-07 at 00:32, Morten Brix Pedersen wrote:
> Hi,
> 
> I'm trying to understand Gtk::TreeView and its friends.
> 
> So, with a TreeView, I can append columns using the append_column member
> function.  There is two of these:
> 
> int Gtk::TreeView::append_column (  const Glib::ustring& title,     const TreeModelColumn<ColumnType>& model_column )
> 
> int Gtk::TreeView::append_column (  TreeViewColumn& column )

I think a TreeViewColumn allows you to associate a CellRenderer with a
Model Column, but that always follows the same logic, so you can use the
first override to just tell it to use the appropriate renderer for that
type of model data.

> Using the former, is it right to assume that the TreeViewColumn is actually a CellRendererText?
> 
> Because these two code examples yields the same results:
> 
> 1:
>     _treeview.append_column("Description", _cols.description);
> 
> 2:
>     Gtk::CellRendererText *celltext = new Gtk::CellRendererText();
>     Gtk::TreeViewColumn *column = new Gtk::TreeViewColumn("Description", *Gtk::manage(celltext));
>   
>     column->add_attribute(celltext->property_text(), _cols.description);
>   
>     _treeview.append_column(*Gtk::manage(column));

Yes, so you see why 1. is useful. 2. is unnecessarily tedious for most
situations.
 
> By the way, gtkmm needs a good and simple TreeView example,

There are less-than-perfect examples in demo/gtk-demo and
examples/paned. 

> the
> cellrenderercustom example is powerful but very poor to learn from.

CellRendereCustom is a completely different problem. That's very
advanced stuff that isn't needed for most uses of TreeView.

> Should I open a bug for this?

I have promised several times to write a book chapter on TreeView, with
associated examples, but there are other priorities at the moment
because we need to API freeze as soon as possible. I _will_ write that
chapter.

-- 
Murray Cumming
murrayc usa net
www.murrayc.com




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