Path: utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!apple!bionet!ames!eos!shelby!csli!csli.Stanford.EDU From: cwitty@csli.Stanford.EDU (Carl Witty) Newsgroups: comp.windows.x Subject: Subclassing the Athena Widgets Summary: needs C++ "protected" Message-ID: <9975@csli.Stanford.EDU> Date: 4 Aug 89 01:18:46 GMT Sender: cwitty@csli.Stanford.EDU (Carl Witty) Reply-To: cwitty@csli.Stanford.EDU (Carl Witty) Organization: Center for the Study of Language and Information, Stanford U. Lines: 27 Vital Statistics: X Toolkit, Athena Widget set, X version 11 release 3 I'm trying to write some new widgets, and I'm having some problems. For example, I wanted a Toggle widget. This would be exactly like a Command widget, except that the user clicks once to set it, and clicks again to unset it--hence the name Toggle. The only changes should be in the action procedures. Since the X Toolkit Intrinsics attempt to be object-oriented, clearly the "right" way to do this is to subclass the Command widget. Unfortunately, this approach soon leads to difficulties. The new routines in Toggle need to call functions which are private to the Command widget (for example, Redisplay). This is impossible, because they are declared static. Therefore, I end up copying far too much of Command's implementation into Toggle.c. Alternatively, I could create Toggle by making it a subclass of Label, sibling of Command. I would end up using most of Command's implementation. This is also really ugly. Are there any clean solutions to this problem? If not, which of the above ugly solutions should I pick (should Toggle be a subclass of Label or Command?) Thanks! -- Carl Witty cwitty@csli.Stanford.EDU