Path: utzoo!attcan!uunet!tank!ncar!mailrus!cornell!batcomputer!gdykes From: gdykes@batcomputer.tn.cornell.edu (Gene Dykes) Newsgroups: comp.windows.x Subject: Handles for Public Functions Message-ID: <7098@batcomputer.tn.cornell.edu> Date: 3 Jan 89 18:10:38 GMT Distribution: comp Organization: Theory Center, Cornell U., Ithaca NY Lines: 34 I would appreciate comments on the following problem and my solution to it: I have a widget layout manager that parses a grammar that describes a widget tree. It is no trouble to specify resources in this grammar, because widgets use string "handles" for the resources. Thus, an entry in the grammar might look like this: foreground "blue" But I would also like to specify "actions" in this grammar, one type of which is to call a widget's public function. The problem is that widgets don't have any handles defined for public functions; the client has to call the public function directly by its true name. Consider the following grammar line: XtFormDoLayout (Form "form1", Boolean "True") This describes a call to a public function of the Xaw "Form" widget. The layout manager can construct the arguments from the text, but it has no handle on the address of the function to call. There are two solutions to this problem. The first is to hardwire a table of tags and functions into the manager. This is, of course, not very desirable. My solution is to require widgets with public functions that desire to be "nice" widgets to return a list of tags and function addresses as the value of a resource (I chose "XtNpublicFunctions"). It's fairly trivial to add this to widgets contributed from other sources, but it seems that perhaps it should have some kind of official blessing :-) or condemnation :-(. -- Gene Dykes, gdykes@tcgould.tn.cornell.edu