home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!mcsun!fuug!demos!kiae!glas!demos!ucc.su.oz!extro.ucc.su.OZ.AU!maxtal
- From: maxtal@extro.ucc.su.OZ.AU
- Newsgroups: comp.lang.c++
- Date: 17 Jul 92 20:48 MDT
- Subject: Re: Member function pointers, (Base::*)
- Sender: Notesfile to Usenet Gateway <notes@glas.apc.org>
- Message-ID: <1992Jul17.164853.29520@ucc.su.oz>
- References: <1992Jul16.151946.1@ssrl01.slac.s>
- Nf-ID: #R:1992Jul16.151946.1@ssrl01.slac.s:507495057:1992Jul17.164853.29520@ucc.su.oz:2107714212:001:1805
- Nf-From: extro.ucc.su.OZ.AU!maxtal Jul 17 20:48:00 1992
- Lines: 58
-
-
- In article <1992Jul16.151946.1@ssrl01.slac.stanford.edu> tcox@ssrl01.slac.stanford.edu writes:
- >
- >I have formed the belief that by careful coding techniques, one can avoid
- >the use of explicit casts on C++ code, except where interface into other
- >language modules is concerned (in this case, the Motif/Xt toolkit).
-
- Good.
- >
- >However, there is one stubbon problem which I cannot for the life of me see
- >an elegant solution for, so I am posting this in the hope that someone can
- >enlighten me.
- >
- >Now, as Motif programmers will know, PushButton callbacks, and indeed
- >pretty much all callbacks within Motif, end up calling a "C" routine with
- >the following declaration:-
- >
- > actionRoutine( Widget, XtPointer clientData, XtPointer)
- >
- >The first arg is the widget wherefrom the callback originated, the second
- >is any (equiv to void*) user provided pointer, and the third is the
- >address of an Xevent structure which further defines the operation.
-
-
- Unless I misunderstand :
-
- Provide ONE only callback routine in your entire progam.
-
- actionRoutine(Widget W, void *object, XtPointer X)
- {
- WidgetObject* w=object;
- w->execute(W,X);
- }
-
-
- Where:
- class WidgetObject {
- public:
- virtual execute(Widget,XtPointer)=0;
- };
-
-
- To define the behaviour, derive a class from WidgetObject.
- You must supply the object somehow to Motiff to
- call you back with.
-
-
- [PS: I'm not a Motif or even X user, I use Windows. The above
- type of solution is what I do there. It might need tuning.
- But the key is ONE only callback (of each type in Windows).]
-
-
- --
- ;----------------------------------------------------------------------
- JOHN (MAX) SKALLER, maxtal@extro.ucc.su.oz.au
- Maxtal Pty Ltd, 6 MacKay St ASHFIELD, NSW 2131, AUSTRALIA
- ;--------------- SCIENTIFIC AND ENGINEERING SOFTWARE ------------------
-
-