home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #31 / NN_1992_31.iso / spool / comp / windows / x / motif / 8177 < prev    next >
Encoding:
Text File  |  1992-12-22  |  1.8 KB  |  40 lines

  1. Newsgroups: comp.windows.x.motif
  2. Path: sparky!uunet!gatech!destroyer!cs.ubc.ca!mprgate.mpr.ca!lichen!janzen
  3. From: janzen@lichen.mpr.ca (Martin Janzen)
  4. Subject: Re: access C++ non-static member data in callback functions
  5. Message-ID: <1992Dec22.210443.2166@mprgate.mpr.ca>
  6. Sender: janzen@lichen (Martin Janzen)
  7. Reply-To: janzen@mprgate.mpr.ca
  8. Organization: MPR Teltech Ltd.
  9. References: <1992Dec21.144049.21044@asl.dl.nec.com> <gregc.724963206@eagle.fsl.noaa.gov>
  10. Date: Tue, 22 Dec 92 21:04:43 GMT
  11. Lines: 27
  12.  
  13. In article <gregc.724963206@eagle.fsl.noaa.gov>, gregc@eagle.fsl.noaa.gov (Greg Compestine) writes:
  14. >jng@aslslc71.asl.dl.nec.com (James Ng) writes:
  15. >>[re. using Motif with C++]
  16. >[...]
  17. >The problem with using a non-static member function is
  18. >that it has a hidden first parameter: the "this" ptr.  The X intrinsics
  19. >callback dispatching routines have no provision for supplying the "this"
  20. >ptr to the callback.
  21. >
  22. >   Doug Young discusses this problem and presents a workaround in his
  23. >book "Object Oriented Programming with C++ and Motif".  Basically, you
  24. >provide the "this" ptr as the client data to the static callback.  The
  25. >static callback in turn calls the object's actual callback.  The tactic
  26. >works fine until you hit the case of wanting to have such things as
  27. >action procedures associated with your objects and *no* client data
  28. >is available....
  29.  
  30. For Motif widgets, if you need the "this" pointer in an action procedure,
  31. you can store it in the XmNuserData resource of any widgets for which the
  32. action might be invoked.  All widgets that are subclasses of Primitive or
  33. Manager (just about anything but shells) have this resource. Works for me...
  34.  
  35. -- 
  36. Martin Janzen                     janzen@mprgate.mpr.ca (134.87.131.13)
  37. MPR Teltech Ltd.                  Phone: (604) 293-5309
  38. 8999 Nelson Way                   Fax: (604) 293-6100
  39. Burnaby, BC, CANADA  V5A 4B5
  40.