Topic: c++ and motif


Author: jeff@cee.hw.ac.uk (Jeffrey Morgan)
Date: Thu, 8 Dec 1994 16:50:54 GMT
Raw View
Dear All,

Does anyone know how to use a private member function (C++) as a callback
for a Motif (C) Widget?

I have the class ArticleViewer with a scrolled list widget. At the momment
I have the following :-

    XtAddCallback(
        the_articles_scrolled_list,
        XmNdefaultActionCallback,
        (XtCallbackProc) articles_scrolled_list_callback,
        (XtPointer) this);

with the corresponding function definition :-

    static
    void
    articles_scrolled_list_callback(Widget scrolled_list,
                                    XtPointer client_data,
                                    XmListCallbackStruct *cbs)


The (XtPointer) this in the callback allows me to access the object of which
the scrolled list is part. However, I cannot get access to the private
data/members in that object (if you know how - let me know) so I have to
have access members returning the values of the private data members e.g.

    Article     get_article();

just so I can access the internals of the object in a callback that is
conceptually part of the object.

What I would prefer to do would be to use a private memeber function as the
callback function e.g.

    void
    ArticleViewer::articles_scrolled_list_callback(Widget scrolled_list,
                                                   XtPointer client_data,
                                                   XmListCallbackStruct *cbs)

to give me access to the private members. Any ideas?

Please answer in the group or preferably via email:-

                jeff@cee.hw.ac.uk

Thanks.