
/* 
    MiscController_Protected.m
*/

// RCS identification information
static char *rcsID = "$Id:$";
static void __AvoidCompilerWarning(void) {if(!rcsID)__AvoidCompilerWarning();}

// NeXTSTEP Headers
#import <AppKit/AppKit.h>

// Other Headers
#import "MiscControllerManager.h"
#import "MiscController.h"


@implementation MiscController (Protected)

/*"
    MiscController is a protected category which 
    means that only this class or subclasses should make use of 
    these methods. They are subject to change without notice.
"*/


//-------------------------------------------------------------------
// 	awakeFromNib hooks
//-------------------------------------------------------------------

- (void) _initializeUI
/*"
    Our current implementation does nothing. It is a hook for subclasses 
    to extend to do their own UI initialization (instead of extending or
	overridding #awakeFromNib).
"*/
{
}


//-------------------------------------------------------------------
//	Notification posting
//-------------------------------------------------------------------

- (void) _postControllerDidEditNotificationWithUserInfo:(NSDictionary*)userInfo
/*"
   Called from our #didEditWithUserInfo: method. We just post a
   MiscControllerDidEditNotification to NSNotification's defaultCenter.
"*/
{
    [[NSNotificationCenter defaultCenter]
        postNotificationName:MiscControllerDidEditNotification
                      object:self userInfo:userInfo];
}


//-------------------------------------------------------------------
//	Notification registering
//-------------------------------------------------------------------

- (void)_registerForControllerDidEditNotification:(MiscController*)aController
/*"
   A shorthand way of registering for edit notification from aController.
   The method that gets called when a controller edits (when using this
   method to register) is #controllerDidEdit:.
"*/
{
	if (aController != nil && 
		[aController isKindOfClass:[MiscController class]]) {
		[[NSNotificationCenter defaultCenter] addObserver:self 
			selector:@selector(controllerDidEdit:)
                        name:MiscControllerDidEditNotification object:aController];
	}
    else {
        NSLog(@"MiscController: _registerForControllerDidEditNotification "
              @"called with bad controller argument.");
    }
}

- (void) _unregisterForControllerDidEditNotification:(MiscController*)aController
/*"
   A shorthand way to remove yourself from receiving edit notification
   from aController.
"*/
{
    if (aController != nil) {
        [[NSNotificationCenter defaultCenter] removeObserver:self
            name:MiscControllerDidEditNotification object:aController];
    }
}

@end


@implementation MiscController (NibInitialization)

- (void) awakeFromNib
/*"
    Currently just calls _initializeUI (a hook for subclasses to use
    for UI setup). Please use this instead of subclassing awakeFromNib
    (unless you are subclassing to put more initialization hooks).
"*/
{
    [self _initializeUI];
}

@end

