
/* Generated by Interface Builder */

#import <stdlib.h>
#import "SpotLightApp.h"
#import "ScreenDim.h"
#import "Controller.h"
#import "EyeView.h"
#import "PrefMgr.h"

#import <appkit/Listener.h>
#import <appkit/defaults.h>

#define BORDER  3

@implementation SpotLightApp

+ new
{
    NXDefaultsVector SpotLightDefauts = {{ "DimTime","5"},
                                         { "DimType","1"}, /* SpotLight is default */
                                         { "Width", "50"},
                                         { "Quote", ">"},
                                         { "Sigfile", ".signature"},
                                         { "Rtfsigfile", ".signature.rtf"},
                                         { "EyeUpdateTime", "0.20"},
                                         { "EyesON", "1"},   /* Should the Eyes be displayed */
                                         { "PasswdLock", "0"}, /* Default is off */
                                         {NULL}};

    self = [super new];
    eyes = NULL;
    NXRegisterDefaults("SpotLight",SpotLightDefauts);

    return self;
}

- appDidInit:sender
{
    NXRect cRect, fRect;

    [[NXApp appListener] setServicesDelegate:controller];

    if (atoi(NXGetDefaultValue("SpotLight","EyesON"))){

	[[NXApp appIcon] getFrame:&fRect];
    
	[Window getContentRect:&cRect forFrameRect:&fRect style:[[NXApp appIcon] style]];
 
	cRect.origin.x = BORDER;
	cRect.origin.y = BORDER;
	cRect.size.width -= BORDER * 2;
	cRect.size.height -= BORDER * 2;

	eyes = [[EyeView alloc] initFrame:&cRect];     

	[[[NXApp appIcon] contentView] addSubview:eyes];

	[eyes initializeEyes];
	[eyes drawBalls];
    }
    [screenDim setEyes:eyes];
    [prefmgr setEyes:eyes];

    return self;
}

- free
{
    [eyes free];
    return [super free];
}

@end
