ftp.nice.ch/peanuts/GeneralData/Usenet/news/1989/CSN-89.tar.gz#/comp-sys-next/1989/Oct/Multiple-instantiation-of-windows-laid-out-with-IB

This is Multiple-instantiation-of-windows-laid-out-with-IB in view mode; [Up]


Date: Sun 21-Oct-1989 21:36:33 From: Unknown Subject: Multiple instantiation of windows laid out with IB Is there a way to use the Interface Builder to set up a window, and then create an arbitrary number of copies of this window from the program, at run-time? For example, suppose I use IB to lay out a DocumentWindow, and my application requires opening a separate DocumentWindow for each document it edits. Jacob
Date: Sun 22-Oct-1989 07:29:07 From: Unknown Subject: Re: Multiple instantiation of windows laid out with IB One way of doing this is to have a separate nib file for the document window. A fairly detailed example of this is given in the Interface Builder chapter of the NeXT Technical Documentation set. An on-line copy of this chapter appears in /NextLibrary/Documentation/NeXT/SysRefMan/08_IntfBuilder.wn Basically, what you do is have an owner object for each document window in your application. Whenever a new document is desired, a new manager object is created; its factory method looks like this: @implementation MyManager + new { self = [super new]; [NXApp loadNibSection:"DocWindow.nib" owner:self]; return self; } // more stuff here @end I hope this does what you want, and is helpful to you. If you have any questions, feel free to ask. bob == Bob Heiney, labc-1aa@WEB.Berkeley.edu == == NeXT Student Advocate for U. C. Berkeley == == "And in the end, the love you take is equal to the love you make" == == -- The Beatles == >From: ed@uunet!dtgcube (Edward Jung)
Date: Sun 22-Oct-1989 10:31:11 From: Unknown Subject: Re: Multiple instantiation of windows laid out with IB >Is there a way to use the Interface Builder to set up a window, and then >create an arbitrary number of copies of this window from the program, at >run-time? Yes, you can do that with Interface Builder. Instructions on how to do it are in the Interface Builder chapter dealing with a multi-window editor (Project 4, Chapter 8, pp.47 in the on-line manual /NextLibrary/Documentation/NeXT/SysRefMan/08_IntfBuilder.wn). The instructions are relatively straight-forward. There are also other ways: You might be tempted to use the message 'copy' to make a copy of the objects, but avoid this. 'copy' makes an exact copy, including all *references* to other objects (rather than copying those objects), which is ALMOST CERTAINLY NOT what you want. Instead, use typed streams to copy objects: #import <objc/typedstream.h> id copyObject(id baseObject) { id returnValue; int length; char * buffer = NXWriteRootObjectToBuffer(baseObject, &length); returnValue = NXReadObjectFromBuffer(buffer, length); /* error checking here */ NXFreeObjectBuffer(buffer, length); return returnValue; } This writes out a graph of the object and then reads it back in, all in memory. Hope this helps.
Date: Sun 23-Oct-1989 20:53:12 From: Unknown Subject: Re: Multiple instantiation of windows laid out with IB / comp.sys.next / ed@uunet!dtgcube (Edward Jung) / Oct 22, 1989 / #import <objc/typedstream.h> id copyObject(id baseObject) { id returnValue; int length; char * buffer = NXWriteRootObjectToBuffer(baseObject, &length); returnValue = NXReadObjectFromBuffer(buffer, length); /* error checking here */ NXFreeObjectBuffer(buffer, length); return returnValue; } This writes out a graph of the object and then reads it back in, all in memory. ---------- Thanks, this is a nice way to copy an object. (Looks like NeXT punted on the -deepCopy method in class Object?) However, it seems that it does not preserve the outlet connections that have been set up in the interface builder. Jacob P.S. Thanks to everybody who pointed me to Example 4 in the Interface Builder chapter of the 1.0 manual.
Date: Sun 24-Oct-1989 02:49:15 From: Unknown Subject: Re: Multiple instantiation of windows laid out with IB In article <130030@gore.com> jacob@gore.com (Jacob Gore) writes: >Is there a way to use the Interface Builder to set up a window, and then >create an arbitrary number of copies of this window from the program, at >run-time? >For example, suppose I use IB to lay out a DocumentWindow, and my >application requires opening a separate DocumentWindow for each document it >edits. Yes; the easist way to do this is to create a separate .nib file for your window and load it in whenever you need to create a new document. Take a look at the Yap source; at the YapDocument.m file. In its "new" factory method it loads the YapDocument.nib file, right after creating a new instance of the class. This new object is specified as the "owner" to the loadNibSection:owner: method; thus the outlet initialization methods in this object will be called. YapDocument.nib has one outlet, "document," thus the "setDocument:" method of this new object is invoked, giving it a handle to the text object in this window. Ali Ozer, NeXT Developer Support Ali_Ozer@NeXT.com >From: chavez@sumex-aim.stanford.edu (R. Martin Chavez)
Date: Sun 25-Oct-1989 11:38:29 From: Unknown Subject: Re: Multiple instantiation of windows laid out with IB Hmm. It ought to archive all outlet connections (actually connect them to the common instances), assuming that the read and write methods are correctly written... If I didn't mention it in the previous posting, you must have working read and write methods for the typed stream archiving functions to work. BTW, if the architecture of your application fits to the multiple controller/.nib file setup, you should use it. It is very convenient.

These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Marcel Waldvogel and Netfuture.ch.