Re: TreeView



>
> 	Hi, there !
>
> 	I have a TreeView used in order to show some information. However, I
> would like the user to have the opportunity to show some columns and
> hide others.

If you just need to shide some known-at-compile time columns then you can
just  hide the view columns.

> The TreeModel needs therefore to be dynamic. So I was
> creating the famous column layout:
>
> class DocumentColumns : public Gtk::TreeModel::ColumnRecord {
> public:
> 	Gtk::TreeModelColumn<string> data;
>
> 	DocumentColumns()
> 		{}
>
> 	createColumns();
> };
>
> 	However, I need to specify the actual number of
> Gtk::TreeModelColumn<>'s I need, and I simply don't know they number at
> compile time. Would it be possible to create a vector of
> Gtk::TreeModelColumn<>'s, and adding that dynamically-created columns ?

Yes. For totally dynamic columns, here is some ugly code that does that:
http://cvs.gnome.org/viewcvs/glom/glom/utility_widgets/adddel/adddel.cc?view=markup
See AddDel::construct_specified_columns() there.

Unfortunately, you do need to create a new model every time you change the
model columns. But if the columns should be completely different then that
does make sense, because it would be a completely new underlying data
structure.

> Will the TreeView change when the model changes (afer calling
> createColumns() and set_model()) ? Or do I have to recreate the TreeView
> from the beginning ?

No, the treeview will detect the new model.

>
> 	Actually (this is constructive criticism), I have to confess that I am
> very disappointed with TreeView and the absence or CList (or something
> like that). I would like to add string columns and rows for simple uses
> such as this one in a simple way, and not with the overhead that
> TreeView implies, which is good for advanced uses but excessively
> complex for the easiest ones.

Yes. But we have tried to make it easy, and it's certainly easier than
using GtkTreeView in C. However, in real life people usually do need to
have typed  data instead of just strings. For instance, converting between
numbers and string representations is generally awkward, and creates
internationalization problems when you make assumptions about the locale.

> 	I wonder why CList was not re-implemented for Gtkmm2 as a wrapper for
> TreeView. Or maybe there is another component doing this which I don't
> know about.

You might try that.

Murray Cumming
murrayc murrayc com
www.murrayc.com
www.openismus.com




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