
/*
	Copyright 1993  Jeremy Slade.

	You are free to use all or any parts of the Locus project
	however you wish, just give credit where credit is due.
	The author (Jeremy Slade) shall not be held responsible
	for any damages that result out of use or misuse of any
	part of this project.

*/

/*
	Project: Locus
	
	Class: WidePopupController
	
	Description: See WidePopupController.h

	Original author: Jeremy Slade
	
	Revision History:
		Created
			V.101	JGS FMon Feb  8 23:00:40 GMT-0700 1993

*/

#import "WidePopupController.h"

#import <appkit/appkit.h>


@implementation WidePopupController


+ initialize
/*
	set the class version number
*/
{
	[self setVersion:WidePopupController_VERSION];
	return ( self );
}



- initForButton:aButton andPopup:aPopUpList
/*
	Connects self as the intermediary between aButton and aPopUpList.  aButton sends self the popUp: message, which is forwarded to aPopUpList
*/
{
	[super init];
	
	cover = aButton;
	popUp = aPopUpList;
	
	[popUp sizeToFit];
	[[cover setTarget:self] setAction:@selector(popUp:)];
	
	return ( self );
}



- getBounds:(NXRect *)rect
/*
	Determine the bound rect of the PopUpList.  Uses the frame of the button or the popUpList, whichever is wider ( make sure it is wide enough to display the whole thing, but not any shorter than the button is )
*/
{
	NXRect popupFrame;
	
	[popUp getFrame:&popupFrame];
	[cover getBounds:rect];

	if ( NX_WIDTH(rect) < NX_WIDTH(&popupFrame)-1 )
		rect->size.width = NX_WIDTH(&popupFrame)-1;
	
	return ( self );
}



- setTitle:(const char *)aString
/*
	Receives messages from the popUp list directed for the cover.  The object that sends the popUp: mesasge to the popUp must respond to this message in return.
*/
{
	[cover setTitle:aString];
	
	return ( self );
}



- convertPoint:(NXPoint *)aPoint toView:aView
/*
	Forward to the cover -- this would normally be sent directly to the cover button from the popUp.
*/
{
	[cover convertPoint:aPoint toView:aView];
	
	return ( self );
}



- popUp:sender
/*
	Send the popUp: message to the popUp
*/
{
	[popUp sizeToFit];
	return ( [popUp popUp:self] );
}



- window
{
	return ( [cover window] );
}



- display
{
	return ( [cover display] );
}



- (BOOL)needsDisplay
{
	return ( [cover needsDisplay] );
}



- (const char *)title
{
	return ( [cover title] );
}



@end
