Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!usc!sdd.hp.com!spool.mu.edu!uunet!durer!durer.cme.nist.gov!warsaw From: warsaw@nlm.nih.gov (Barry A. Warsaw) Newsgroups: comp.windows.open-look Subject: Re: XView Programming Style Message-ID: Date: 27 Mar 91 16:30:12 GMT References: <0x6u9ws@openlook.Unify.Com> Sender: news@cme.nist.gov Reply-To: warsaw@nlm.nih.gov Organization: Century Computing, Inc. Lines: 43 In-reply-to: rick@pbi.com's message of 26 Mar 91 12:59:38 GMT Of course, life can be so much easier if you use C++ :-). Anyway, what I do is subclass all the GUIDE generated classes. One reason is to shorten all those __object class names which I hate to type. But another is to use OO style to keep track of all my windows. I can bypass using tons of XV_KEY_DATA's since the only one I really need is INSTANCE, which contains a pointer to an object of my derived class and each derived class has data members which point to 1. the base window, 2. their subwindows, and 3. a list of all multiple instance subwindows. So I have basically two types of windows. The first will only have a single instance within my application. This might be the introductory window, or an "About..." type window. The second type of window may have many instances floating about at any one time. For example, a "file" window for an editor (editing multiple files at once). On my base window object, I have public members which are pointers to all single instance windows and if they pop up at start up time, I call objects_initialize() (inherited from the GUIDE-generated base class) in their constructor. For windows with multiple instances, or for single instance windows which pop up later at a user's instruction, I usually have both a constructor and a "pop" method. The constructor will not call objects_initialize(), but pop() will check to see if the XView structures have been initialized and if not, it will first call objects_initialize(), then pop up the window. Seems to work very well for me since its easy to create multiple instances of windows and I don't create all those window resources until they're absolutely necessary. Also, using C++ really cleans up the event handlers for windows since the INSTANCE key for items will be a pointer to my derived class. The event handler has just enough code to extract and cast the INSTANCE key value to the object pointer and then call the appropriate member function which implements the guts of the event's functionality. Hope this makes some sense. Anyway, yes this is a plug for C++ :-). -Barry NAME: Barry A. Warsaw INET: warsaw@nlm.nih.gov TELE: (301) 496-1936 UUCP: uunet!nlm.nih.gov!warsaw