Re: [gtkmm] Understanding Gtk::TreeView



On 20 Sep 2002 21:19:47 +0100
Matthew Walton <mxw00u Cs Nott AC UK> wrote:

> On Fri, 2002-09-20 at 20:38, James T. Richardson, Jr. wrote:
> > Hello, I was wondering if someone could verify my understanding of the Gtk::TreeView (and related) classes. I come from Windows programming background and implementing the Gtk::TreeView seems to be overly-complex.
> 
> Yes, it's complicated, but it is extremely flexible.
> 
> > class MyTreeViewColumns : public Gtk::TreeModel::ColumnRecord
> > {

<snip>

> > };
> 
> I always think of this as like a structure for the data model, telling
> it what columns it should have, what to call them and what data types
> they will contain.

The more I look at stuff, the more I am starting to look at it this way too.

> ListStore sorting is very simple, as items in a ListStore can't have
> children. That's for TreeStores, and as far as I'm aware, TreeStore
> sorting doesn't actually work at the moment. Didn't last time I looked
> anyway, I hope someone can tell me different. Don't know if this is a
> GTK+ or gtkmm thing though.

I finally understand that there is ListStore *and* a TreeStore, one for a "Listview" another for a "TreeView", respectivly. However, it seems odd (in a sense) to have the TreeView handle showing simple "ListViews". The part that makes sense to me, is that the listview can be interpreted as an extremely basic tree view (i.e. no children), but the name TreeView for representing a simple 'listbox' (to use windows terms) is slightly confusing. 

As for sorting, I'm not worried about that right now, I'm trying to figure out how to add children to a row in a TreeStore. I see how TreeModel::Children is an STL-like container, but looks like it only has 'read' properties.

> Yup. It knows squat about the underlying data and can't affect it either
> (except through specific editing operations in editable cells). This is
> a Good Thing.

Yes, I am in full agreement here.

> > 		const Glib::ScopedPtr<char> text_buf(g_strdup_printf("message #%d", i)); // const Glib::ScopedPtr<char> looks like a fancy c-style string, is it?
> 
> I have no idea what that bit of code is for. Seems like a long way
> around... and who sneaked Glib::ScopedPtr<> into the API without me
> noticing?

The code was adapted from the paned example distributed with gtkmm-1.3.22. 


> Hope that was vaguely coherent. Might not be 100% accurate, but that's
> my understanding of it.

I'm understanding it bit by bit. I'm having trouble finding complete documentation/examples using the TreeView. Slowly, however, I am starting to gain an understanding for what it's doing (and not doing).

James



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