#import  "TiffSavePanel.h"
#import  <appkit/Application.h>
#import  <appkit/Control.h>
#import  <appkit/Matrix.h>
#import  <appkit/tiff.h>

#define  Tag_None	0
#define  Tag_LZW	1
#define  Tag_JPEG	2

@implementation TiffSavePanel

- init:(float)factor jpeg: (BOOL)flag
{
	[self initFactor: factor];
	JPEGselectable = flag;
	[[compButton findCellWithTag: Tag_JPEG] setEnabled: JPEGselectable];
	[JPEGslider setEnabled: NO];
	return self;
}

- loadNib
{
	if (accessoryView == nil) {
		[NXApp loadNibSection:"TiffAccessory.nib" owner:self];
		[self setAccessoryView: [accessory contentView]];
	}
	return self;
}

- compressType:(int *)type with:(float *)factor
{
	*type = NX_TIFF_COMPRESSION_NONE;

	*factor = 0.0;
	switch ([compButton selectedTag]) {
	case Tag_None:
		*type = NX_TIFF_COMPRESSION_NONE;
		break;
	case Tag_LZW:
		*type = NX_TIFF_COMPRESSION_LZW;
		break;
	case Tag_JPEG:
		*type = NX_TIFF_COMPRESSION_JPEG;
		*factor = (float)[JPEGtext intValue];
		break;
	}
	return self;
}

- buttonChanged: sender
{
	if (JPEGselectable) {
		BOOL flag = ([compButton selectedTag] == Tag_JPEG);
		[JPEGslider setEnabled: flag];
	}
	return self;
}

@end
