ftp.nice.ch/pub/next/developer/resources/classes/MOKit.1.0.0.s.tar.gz#/MOKit_1.0.0/Documentation/Classes/MOController.rtf

This is MOController.rtf in view mode; [Download] [Up]

Version 1.0  Copyright ©1993, 1994 by Mike Ferris.  All Rights Reserved.
Mike Ferris  -  February 16th, 1994



MOController






Inherits From:	Object

Declared In:	MOKit/MOController.h





Class Description

MOController instances manage a window which is stored in an InterfaceBuilder .nib file.  MOController handles loading the nib file and keeping track of the window.  MOController acts as the nib "File's Owner".  Automatic support for saving the window's frame (ie size and location) in the defaults database through the standard Window methods is provided.  The -showWindow: method is used to display the window (loading the nib file first if necessary).

MOController is an abstract superclass.  Most subclasses of MOController will only have one instance in your application.  For example, you might create subclasses called PreferencesController, FindController, PaletteController, etc, and then create one instance of each for your application to manage those particular panels.  Other subclasses (such as MODocController) are meant to have multiple instances, but this is less common, and if you find yourself wanting to do this, you should look closely at whether you shouldn't be subclassing MODocController instead.

Each subclass of MOController should register a nib name for that class.  This is done with the +setClassNib: method, and you should do it in your subclass's +initialize method.  MOController uses a MOClassVariable object to store these nib names so you needn't worry about reimplementing the class variable in your subclasses (like in Control).  It is possible to have a MOController without a nib, although almost all of what it provides has to do with nib support, so you'd have to have a reason for this.  (Two reasons might be if you want to keep a consistent interface between several objects, some of which have nib-file windows, or if you want to make a subclass of MODocController which supports a multiple-views-on-a-document type deal with no top-level document window.)

When you create an instance, you can assign it a frame name to use to save the windows frame information in the defaults database.  Passing NULL means the frame information is not restored from the defaults database, it is left as it is in the nib file.  Specifying a name does two things.  When the nib is loaded, the window's frame is set to the value in the defaults database corresponding to the frame name.  If there isn't a defaults entry, the frame in the nib file is used.  Also, having a frame name causes the window to save its frame info into the defaults database any time the window changes size or location.





Instance Variables

id 	window;
MOString 	*frameName;
BOOL 	nibIsLoaded;



window 	The window which the controller controls.  This should almost always be set up as an outlet connection in the nib file.

frameName	frameName always points at a valid MOString object.  The MOString contains the window's frame name.  It contains NULL if the window has no frame name.

nibIsLoaded	nibIsLoaded indicates whether the controller's nib file has been loaded (for this instance).





Method Types

Initializing the class	+ initialize
+ startUnloading

Class nib file	+ setClassNib:
+ classNib

Initializing instances	- init
- initWithFrameName:
- free

The frame name	- setFrameName:
- frameName

Loading the nib	- loadNibIfNeeded
- nibDidLoad

Dealing with the window	- window
- window:
- showWindow:

Archiving	- awake
- read:
- write:






Class Methods

initialize
+ initialize

Sets the class version number.  Loads the MOString and MOClassVariable classes.  Initializes the nib name class variable.

See also:   + startUnloading




classNib
+ (const char *)classNib

Returns the nib file name for the calling subclass.  This is done by looking up the value in the MOClassVariable object used to store the nib names.

See also:   + setClassNib:




setClassNib:
+ setClassNib:(const char *)nibName

Sets the nib file name for the calling subclass.  Nib names are stored in a MOClassVariable, so each subclass (and all their subclasses, etc...) get separate values.

See also:   + classNib




startUnloading
+ startUnloading

Frees the nib name class variable.

See also:   + initialize





Instance Methods

awake
± awake

Initializes the instance variables that are not archived after an instance has been read from a typed stream.  Basically this just makes sure the instance looks like it hasn't had its nib loaded.

See also:   ± read:, ± write:




frameName
± (const char *)frameName

Returns the frame name used to save the window's frame information in the defaults database.  Returns NULL if the frame information is not stored in the defaults database.

See also:   ± setFrameName:




free
± free

This method frees the frameName and the window.  If your subclass uses other windows (including popup menus), you should override this and free them.  Only the window pointed at by the window instance variable is freed.

See also:   ± init, ± initWithFrameName:




init:
± init

Calls initWithFrameName:NULL.

See also:   ± initWithFrameName:, ± free




initWithFrameName:
± initWithFrameName:(const char *)name

This is the designated initializer for the class.  This allocates and initializes the frameName MOString and initializes the other instance variables.  The nib file is not loaded until it is needed (that is, until -showWindow: or -window:YES are called).

See also:   ± init, ± free




loadNibIfNeeded
± loadNibIfNeeded

Loads the controller's nib file, if it has not already been loaded.  If the nib file actually was loaded, the window's frame is set if the frameName of this instance is non-NULL and the name is registered as the windows autosave frame name.  Finally, if the nib was actually loaded, the -nibDidLoad method is called.    -nibDidLoad should be overridden instead of -loadNibIfNeeded if you have further initialization to do after the nib file loads.

See also:   ± nibDidLoad




nibDidLoad
± nibDidLoad

This is called by -loadNibIfNeeded after the nib file is loaded.  MOController's implementation does nothing.  You can override if necessary.  Call super's implementation first in your override.

See also:   ± loadNibIfNeeded




read:
± read:(NXTypedStream *)stream

Reads the instance from the typed stream.  Only the frame name is archived.

See also:   ± awake, ± write:




setFrameName:
± setFrameName:(const char *)name

Sets the window's frame name.  This will only work if the nib file hasn't been loaded yet.  Normally, the frame name is set with the -initFrameName: method.

See also:   ± frameName




showWindow:
± showWindow:sender

If the nib file is not loaded, this method loads it.  Then it puts the window on-screen and makes it key.

See also:   ± window, ± window:




window
± window

This just calls -window:NO.

See also:   ± window:, ± showWindow:




window:
± window:(BOOL)loadFlag

Returns the controller's window.  If the nib file is not loaded, and loadFlag is YES, the nib file is loaded first.  If the nib file is not loaded, and loadFlag is NO, nil is returned.

See also:   ± window, ± showWindow:




write:
± write:(NXTypedStream *)stream

Writes the instance to the typed stream.  Only the frame name is archived.

See also:   ± awake, ± read:





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