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