home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #16 / NN_1992_16.iso / spool / comp / lang / cplus / 11374 < prev    next >
Encoding:
Text File  |  1992-07-22  |  2.3 KB  |  71 lines

  1. Path: sparky!uunet!mcsun!fuug!demos!kiae!glas!demos!ucc.su.oz!extro.ucc.su.OZ.AU!maxtal
  2. From: maxtal@extro.ucc.su.OZ.AU
  3. Newsgroups: comp.lang.c++
  4. Date: 17 Jul 92 20:48 MDT
  5. Subject: Re: Member function pointers, (Base::*)
  6. Sender: Notesfile to Usenet Gateway <notes@glas.apc.org>
  7. Message-ID: <1992Jul17.164853.29520@ucc.su.oz>
  8. References: <1992Jul16.151946.1@ssrl01.slac.s>
  9. Nf-ID: #R:1992Jul16.151946.1@ssrl01.slac.s:507495057:1992Jul17.164853.29520@ucc.su.oz:2107714212:001:1805
  10. Nf-From: extro.ucc.su.OZ.AU!maxtal    Jul 17 20:48:00 1992
  11. Lines: 58
  12.  
  13.  
  14. In article <1992Jul16.151946.1@ssrl01.slac.stanford.edu> tcox@ssrl01.slac.stanford.edu writes:
  15. >
  16. >I have formed the belief that by careful coding techniques, one can avoid
  17. >the use of explicit casts on C++ code, except where interface into other
  18. >language modules is concerned (in this case, the Motif/Xt toolkit).
  19.  
  20.     Good.
  21. >
  22. >However, there is one stubbon problem which I cannot for the life of me see
  23. >an elegant solution for, so I am posting this in the hope that someone can
  24. >enlighten me.
  25. >
  26. >Now, as Motif programmers will know, PushButton callbacks, and indeed
  27. >pretty much all callbacks within Motif, end up calling a "C" routine with
  28. >the following declaration:-
  29. >
  30. >        actionRoutine( Widget, XtPointer clientData, XtPointer)
  31. >
  32. >The first arg is the widget wherefrom the callback originated, the second
  33. >is any (equiv to void*) user provided pointer, and the third is the
  34. >address of an Xevent structure which further defines the operation.
  35.  
  36.  
  37.     Unless I misunderstand :
  38.  
  39. Provide ONE only callback routine in your entire progam.
  40.  
  41.     actionRoutine(Widget W, void *object, XtPointer X)
  42.     {
  43.         WidgetObject* w=object;
  44.         w->execute(W,X);
  45.     }
  46.  
  47.  
  48. Where:
  49.     class WidgetObject { 
  50.     public: 
  51.         virtual execute(Widget,XtPointer)=0;
  52.     };
  53.  
  54.  
  55. To define the behaviour, derive a class from WidgetObject.
  56. You must supply the object somehow to Motiff to
  57. call you back with.
  58.  
  59.  
  60. [PS: I'm not a Motif or even X user, I use Windows. The above
  61. type of solution is what I do there. It might need tuning.
  62. But the key is ONE only callback (of each type in Windows).]
  63.  
  64.  
  65. -- 
  66. ;----------------------------------------------------------------------
  67.         JOHN (MAX) SKALLER,         maxtal@extro.ucc.su.oz.au
  68.     Maxtal Pty Ltd, 6 MacKay St ASHFIELD, NSW 2131, AUSTRALIA
  69. ;--------------- SCIENTIFIC AND ENGINEERING SOFTWARE ------------------
  70.  
  71.