Re: [gtkmm] get a reference from a Gtk::TreeValueProxy



Well, I did not try it, but it does compile. The only trouble I get is that
I cannot access my custom data without calling the "=" operator which is
potentially heavy...

but this works for example:

definition of the custom data:
    class RowObject: public foo
    {
    public:
        RowObject(){}
        int a;
        std::string b;
    };

definition of the column model:
    class ColumnModel : public Gtk::TreeModel::ColumnRecord
    {
    public:
        ColumnModel() {add(name); add(rowObject);}
        Gtk::TreeModelColumn<Glib::ustring> name;
        Gtk::TreeModelColumn<RowObject> rowObject;
    };

    ColumnModel columnModel;

then, if it is a well initialized Gtk::TreeModel::iterator:
    RowObject ro = (*it)[columnModel.rowObject];
    ro.a = 15;
    ro.b = "foo";
    (*it)[columnModel.rowObject] = ro;

this does compile (didn't try if it really works). But I have to copy the
whole object twice, and I cannot afford that for performance issue.
I would like to be able to do something like:
    RowObject& ro = (*it)[columnModel.rowObject].getReference();    // This
is the reference I would like to obtain...
    ro.a = 15;
    ro.b = "foo";

----- Original Message -----
From: "Murray Cumming" <murrayc t-online de>
To: "erwan ancel" <erwan ancel free fr>
Cc: "gtkmm-list" <gtkmm-list gnome org>
Sent: Friday, January 31, 2003 9:38 AM
Subject: Re: [gtkmm] get a reference from a Gtk::TreeValueProxy


> On Fri, 2003-01-31 at 10:13, erwan ancel wrote:
> > Yes, I mean instance :)
> >
> > I started from this tutorial, and as it is said in the tutorial, I am
> > putting custom datas that won't be displayed in a hidden column.
> > This custom data is a complex class, and I cannot use it only with the
'='
> > operator. I have to obtain a reference (or pointer) to my instance.
>
> I'm not sure whether it's possible to store non-Glib::Object-derived
> classes by value in tree model columns. If that's what you are doing
> then it would be interesting to see your actual compiler errors.
>
> It should certainly be possible to store a pointer to the instances
> though.
>
> >
> >         Erwan
> >
> > ----- Original Message -----
> > From: "Murray Cumming" <murrayc t-online de>
> > To: "erwan ancel" <erwan ancel free fr>
> > Cc: "gtkmm-list" <gtkmm-list gnome org>
> > Sent: Friday, January 31, 2003 9:24 AM
> > Subject: Re: [gtkmm] get a reference from a Gtk::TreeValueProxy
> >
> >
> > > On Fri, 2003-01-31 at 08:49, erwan ancel wrote:
> > > > Hi,
> > > >
> > > > I don't manage to find a way to get a reference to the corresponding
> > > > occurence
> > >
> > > Do you mean "instance"?
> > >
> > > >  of my class A from
> > > > Gtk::TreeValueProxy<A>
> > > >
> > > > How can I do that ?
> > >
> > > I had to grep to find out what TreeValueProxy is. I don't think you
> > > should be worrying about it - it's purely an intermediate type. You
> > > should be able to do something like this:
> > >
> > > http://www.gtkmm.org/gtkmm2/docs/tutorial/html/ch08.html#id2843676
> > > (See "Getting Values")
> > >
> > > If this isn't enough, what are you trying to do?
> > >
> > > --
> > > Murray Cumming
> > > murray usa net
> > > www.murrayc.com
> > >
> > >
> >
> > _______________________________________________
> > gtkmm-list mailing list
> > gtkmm-list gnome org
> > http://mail.gnome.org/mailman/listinfo/gtkmm-list
> --
> Murray Cumming
> murray usa net
> www.murrayc.com
>
>




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