[comp.sys.next] Interface Builder Question

mrc@Tomobiki-Cho.CAC.Washington.EDU (Mark Crispin) (02/23/89)

     I'm building a distributed mail application for the NeXT.  It has
a bunch of windows, only one of which is visible at startup.  The
other windows (a "mailbox", "read", and "send" window) all have been
defined via IB and set as not visible at application launch through
the inspector.

     I can -- and will -- have many instances of these windows on the
screen at the same time.  Every time I read a message I'll get a new
read window, etc.  So, really the windows I defined via IB (which have
a scrolling text view and some buttons) are prototypes for the windows
I will create.

     However, I am at a total loss for how I should instantiate these
windows.  If I call the "new" factory method for the class associated
with each of these windows, then what I get is the tiny default window
made by [Window new].

     I'm almost at the point where I am going to have Interface
Builder decompile the interface, in which case I can get what I need I
need from the buildInterface() function.  However, this would mean
punting Interface Builder for any future changes in the interface.  It
also means having to write the code for all those connections.

     Any ideas?

     Oh, does anyone know if it is possible to have a menu which is
attached to (and associated with) a window instead of the main menu?
In other words, I want something that looks like a menu (including
having submenus), attaches as a separate square to one of my windows,
but otherwise is like a button.  Interface Builder makes all menus
come under the main menu, which is not what I want.

-- Mark --

ali@polya.Stanford.EDU (Ali T. Ozer) (02/23/89)

In article <944@blake.acs.washington.edu> Mark Crispin writes:
>     I can -- and will -- have many instances of these windows on the
>screen at the same time.  Every time I read a message I'll get a new
>read window, etc.  So, really the windows I defined via IB (which have
>a scrolling text view and some buttons) are prototypes for the windows
>I will create.
>
>     However, I am at a total loss for how I should instantiate these
>windows.  If I call the "new" factory method for the class associated
>with each of these windows, then what I get is the tiny default window
>made by [Window new].

To create a new window without using IB, use the 

  newContent:style:backing:buttonMask:defer:

method in Window. It creates an offscreen window which can be brought
on screen with orderFront:. You can use setContentView: and addSubview:
to add your own buttons/sliders/views/etc to such a window.

Please don't decompile interfaces in IB; the resulting code isn't 
complete or reliable.

There's actually a nice way to generate the prototype window in IB. From the
"New..." window, choose "New Object." (This lets you create a new
object class independent of any application.) Create your window
within the context of this "New Object" project, and save and decompile
it. You will get a .nib file which contains the definition of your window
and a .m file that contains the method to instantiate such a window,
including all the views inside it... All your application has to do
is call this object's "new" method to instantiate a window.

Hope this helps.

Ali Ozer, aozer@NeXT.com
NeXT Developer Support

giant@lindy.Stanford.EDU (Buc Richards) (06/07/90)

I have built a set of interface files for a project using Interface Builder.
In particular I have a window with a bunch of standard objects in it
called Inspector Window.  I have a menu button called Inspector under
the Window button that is connected to the makeKeyandOrderFront action
of this window, which works fine.  The question is, how can I gain
access to the window objects from the .m programs *outside* of
Interface Builder?  I can connect to the Key Window of course, but
there is no guarantee at any time that this will be the key window.
As a concrete example, I have a text field in the window that I would
like to display the name of a currently open file.  Open is connected
to File's Owner of course, and there is the standard code for running
an open panel there.  Ideally, I would like to also send some kind of
message at that time of the form

appropriateWindow = ?
appropriateTextField = [appropriateWindow getAppropriateTextField];
[appropriateTextField read:stream];

(note that this is a recursive problem).  The nib file has provided
me with the standard action
- setInspectorWindow:anObject
{
  inspectorWindow = anObject;
  return self;
}
but calling [self setInspectorWindow] doesn't do anything (what should
the argument be, by the way?).  This seems like it should be trivial,
but as I say I have not really been able to find this problem/solution
clearly stated in the manuals.  It's pretty clear how to do these things
if you set up all the windows by hand, outside of IB, but then IB doesn't
do much good.

Thanks for any pointers.

benand@homer.bethel.edu (Bennett) (04/04/91)

I've created a landscape view with the following bounds:

     (450,0)		    (600,450)
	 ------------------
	|	TOP	   |
	|		   |
	|L		  R|
	|                  |
	|      BOTTOM      |
	 ------------------
     (0,0)		    (600,0)
     
I would like to be able to print this landscape view in portrait mode.
I've experimented with shrinking and rotating the view, printing it and
then rotating it back, and expanding it to the original view.

- PrintView:sender
{
	
    [self scale:2.0/3.0:2.0/3.0];
    [self translate:bounds.size.width/2.0:0.0];
    [self printPSCode:[self rotate:90]];
    [self rotate:-90];
    [self translate:-bounds.size.width/2.0:0.0];
    [self scale:3.0/2.0:3.0/2.0];
    return self;
}

The reason I need to scale the view down is because when I rotate the view,
parts of the view are erased.  What I end up with is a scaled down version
of what is being displayed on the screen, but I'm unable to utilize all of the
space available for portrait mode.  My view seems to be confined to within
a portion of a normal portrait print page.


	 ---------------
	|   		|
	|    -----------|
	|   |	R      B|
	|   |	       O|
	|   |T	   ^   T|
	|   |O	<--+----|----  Area where my view is printed.
	|   |P	   v   T|	( I can't print outside this box )
	|   |	       O|
	|   |	L      M|
	|    -----------|
	|   		|
	 ---------------
 
Is there a sample program that does something like what I'm trying to do,
or is there an easier way of going about it?

Andy

-- 
Andrew James Bennett   ()   Bethel College & Seminary   ()   benand@bethel.edu