grunwald@flute.cs.uiuc.edu (Dirk Grunwald) (07/08/89)
No, this isn't another request for C++ compatible X libraries; it's a suggestion for a way to use Xt in C++ with ``little pain'' The advantage of Interviews is, basically that it uses an object oriented language to design an object oriented library; it's easy to grok. The disadvantage is that it's ``non-standard'' -- people will make tools to build Xt interfaces, but not too many for Interviews. So, howabout an object that encapsulates the Xt view of a widget and translates it to the world of C++ at (some slight) overhead; translation between Xt & C++ structure offsets would be done each way ( Xt <-> C++ ) E.g., the class builds a WidgetClassRec that provides thunks for widget hooks (set_values, get_values_hook, etc). The thunks call virtual functions to actually invoke the action on the subclass. You'd have to play around with the widget pointers that get passed to offset past the C++ vtbl pointers & other things that C++ might stick in the class. (i.e. you want C++ to think you're a C++ widget, not an Xt Widget) You could use member functions to invoke Xt routines; these would be inlines that simply displace the widget ``this'' to match the Xt structure definitions. (i.e. you want Xt to think you're an Xt Widget, not a C++ Widget) This sounds possible, but it's unclear how much overhead you add. Also, Xt uses some special values in ClassRec (e.g., InheritTranslations) that you couldn't mimic since you specify thunks for each ClassRec slot. -- Dirk Grunwald -- Univ. of Illinois (grunwald@flute.cs.uiuc.edu)