/*
copyright 2004 Alexander Malmberg <alexander@malmberg.org>

Test cursor changing when mouse pointer is held above a text field when the
window is closed/hidden in whatever way.

Test field editor behavior when -setStringValue: is called.
*/

#include <Foundation/NSAutoreleasePool.h>
#include <AppKit/NSApplication.h>
#include <AppKit/NSMenu.h>
#include <AppKit/NSTextField.h>
#include <AppKit/NSWindow.h>

NSTextField *tf,*tf2,*tf3,*tf4;
NSWindow *win;

int main(int argc, char **argv)
{
	CREATE_AUTORELEASE_POOL(arp);

	[NSApplication sharedApplication];

	win=[[NSWindow alloc] initWithContentRect: NSMakeRect(100,100,200,100)
		styleMask: NSTitledWindowMask|NSResizableWindowMask|NSClosableWindowMask
		backing: NSBackingStoreRetained
		defer: YES];

	tf=[[NSTextField alloc] initWithFrame: NSMakeRect(0,0,200,25)];
	[tf setEditable: YES];
	[tf setStringValue: @"center"];
	[tf setAlignment: NSCenterTextAlignment];

	tf2=[[NSTextField alloc] initWithFrame: NSMakeRect(0,25,200,25)];
	[tf2 setStringValue: @"left"];
	[tf2 setEditable: YES];
	[tf2 setAlignment: NSLeftTextAlignment];

	tf3=[[NSTextField alloc] initWithFrame: NSMakeRect(0,50,200,25)];
	[tf3 setStringValue: @"right"];
	[tf3 setEditable: YES];
	[tf3 setAlignment: NSRightTextAlignment];

	tf4=[[NSTextField alloc] initWithFrame: NSMakeRect(0,75,200,25)];
	[tf4 setStringValue: @"justified"];
	[tf4 setEditable: YES];
	[tf4 setAlignment: NSJustifiedTextAlignment];

	[[win contentView] addSubview: tf];
	[[win contentView] addSubview: tf2];
	[[win contentView] addSubview: tf3];
	[[win contentView] addSubview: tf4];

	[win makeKeyAndOrderFront: nil];

	NSMenu *m=[NSMenu new];
	[m addItemWithTitle: @"Close window"
		action: @selector(performClose:)
		keyEquivalent: @"w"];
	[NSApp setMainMenu: m];

	[NSApp run];

	DESTROY(arp);
	return 0;
}

