#import <appkit/appkit.h>
#import "WindowDelegate.h"

#define	SAVE	NX_ALERTDEFAULT
#define	CLOSE	NX_ALERTALTERNATE
#define	CANCEL	NX_ALERTOTHER

@implementation WindowDelegate

- windowWillClose:sender
{
	int result;
	result = NXRunAlertPanel
		([NXApp appName],
		"Unsaved changes. Close Anyway?\n",
		"Save",
		"Close anyway",
		"Cancel");

	switch(result)
		{
		case SAVE:
			printf("Save button selected\n");
			printf("Saving...\n");
			printf("Closing window\n\n");
			break;
		case CLOSE:
			printf("Close button selected\n");
			printf("Closing window\n\n");
			break;
		case CANCEL:
			printf("Cancel button selected\n");
			printf("Window won't close\n\n");
			return nil;
		}
	return self;
}

@end
