From 7306626960601665910
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f78e5,800e73b29c3c5cd1
X-Google-Attributes: gidf78e5,public
X-Google-Thread: 109fba,800e73b29c3c5cd1
X-Google-Attributes: gid109fba,public
X-Google-Thread: 10b6ac,800e73b29c3c5cd1
X-Google-Attributes: gid10b6ac,public
X-Google-ArrivalTime: 1994-12-08 17:55:00 PST
Path: bga.com!news.sprintlink.net!pipex!sunic!news.uni-c.dk!unidhp.uni-c.dk!mojemj
From: mojemj@unidhp.uni-c.dk (Mogens Jensen)
Newsgroups: comp.windows.x.motif,comp.lang.c++,comp.std.c++
Subject: Re: accessing private members in motif callback
Followup-To: comp.windows.x.motif,comp.lang.c++,comp.std.c++
Date: 9 Dec 1994 01:48:49 GMT
Organization: News Server at UNI-C, Danish Computing Centre for Research and Education.
Lines: 57
Distribution: inet
Message-ID: <3c8d21$m6v@news.uni-c.dk>
References: <D0HwBH.7Io@cee.hw.ac.uk>
NNTP-Posting-Host: unidhp.uni-c.dk
X-Newsreader: TIN [version 1.2 PL1]
Xref: bga.com comp.windows.x.motif:11767 comp.lang.c++:40234 comp.std.c++:5636

Jeffrey Morgan (jeff@cee.hw.ac.uk) wrote:

: Dear All,

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

:     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)

: 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?


What about merging the two:

class ArticleViewer : ... {
   static void articles_scrolled_list_callback( Widget, XtPointer, 
                                                XmListCallbackStruct* );
public:
   ...
   };

void
ArticleViewer::articles_scrolled_list_callback( Widget list, XtPointer data,
                                                XmListCallbackStruct *myThis )
{
   ArticleViewer &that = *(ArticleViewer*)myThis;
   ...
   float that.foo = that.fooBar();
   ...
}

I think that will do it ... ?


: Thanks.

I hope it works...


Greetings from Jens Jakob Jensen, Denmark  (using my fathers account)


