
#import  "ColorChangeCtr.h"
#import  <appkit/NXColorWell.h>
#import  <appkit/color.h>
#import  "../ImageOpCtr.h"
#import  "../ImageOpr.h"
#import  "../common.h"

@implementation ColorChangeCtr

- changeAlpha:sender
{
	NXColorWell *well;

	well = (NXColorWell *)(([sender selectedTag] == 0)
					? origWell : newWell);
	[well setEnabled: ![sender state]];
	return self;
}

/* Local Method */
- getfrom:well : alphastat colors:(int *)color
{
	int i;
	float cl[3];

	if ([alphastat state]) {
		for (i = 0; i < 3; i++)
			color[i] = 255;
		color[ALPHA] = AlphaTransp;
	}else {
		NXConvertColorToRGB([well color], &cl[0], &cl[1], &cl[2]);
		for (i = 0; i < 3; i++)
			color[i] = cl[i] * 255;
		color[ALPHA] = AlphaOpaque;
	}
	return self;
}

- doit:sender
{
	int origclr[MAXPLANE], newclr[MAXPLANE];

	[self getfrom:origWell : origAlpha colors:origclr];
	[self getfrom:newWell : newAlpha colors:newclr];
	[imageOpCtr colorChange:origclr to:newclr
		with:[comparison floatValue]
		uniformly:[uniform state] area:[whichside selectedTag]];
			/* This message will be delegated to imageOpr */
	return self;
}


@end
