// RulerPanel.m
// Project: Rulers
//
// Stephan Wacker
// 93-02-16

#if 0	// Purpose

A RulerPanel is a Panel object with the following modifications:
-- It can become the main window.
-- It isn't activated when the user clicks in its contents area.
-- It is a plain window without a title bar.

#endif	// Purpose



#import "RulerPanel.h"


@implementation RulerPanel


- (BOOL) canBecomeMainWindow
{
    return YES;
}

- frameView
// access window's private resource
{
    return _borderView;
}

- initContent: (const NXRect *) contentRect
        style: (int) aStyle
      backing: (int) backingType
   buttonMask: (int) mask
        defer: (BOOL) flag
// Override style parameter with NX_PLAINSTYLE.
{
    NXRect	frameRect = *contentRect;
    
    [super initContent: &frameRect
#ifndef REGULAR_WINDOW
		 style: NX_PLAINSTYLE
#else
		 style: aStyle
#endif
	       backing: backingType
	    buttonMask: mask
		 defer: flag
    ];
    
    [self setAvoidsActivation: YES];
    
    return self;
}


// Forward keystrokes to the RulerControl delegate.
//
- keyDown: (NXEvent *) theEvent
{
    id result = nil;

    if( (theEvent->flags & (NX_COMMANDMASK|NX_HELPMASK)) == 0 ) {
	result = [delegate keyDown: theEvent];
    }
    if( !result ) {
	result = [super keyDown: theEvent];
    }
    return result;
}


// Window can be closed even though it doesn't have a close button.
//
- performClose: sender
{
    if( [delegate respondsTo: @selector( windowWillClose: )] )
	[delegate windowWillClose: self];
    
    return [self close];
}


@end
