//
//  State.m
//  StuntPuppy
//
//  Created by Victor Johnson on 7/28/10.
//  Copyright 2010 __MyCompanyName__. All rights reserved.
//

#import "State.h"
#import <UIKit/UIKit.h>

@implementation State

@synthesize title, blue, img, hotspot;

- (id)initWithFrame:(CGRect)frame
{
	if (self = [super initWithFrame:frame])
	{
		self.frame = CGRectMake(0.0, 0.0, 298, 45);	// we know the frame size
		//self.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
		self.backgroundColor = [UIColor clearColor];	// make the background transparent
	}
	return self;
}

- (void) initText:(NSString *)txt {
//	NSLog(@"initText: %@",txt);
	CGRect frame = CGRectMake(0,0, 298,45); 
	
	img = [[UIImageView alloc] initWithFrame:frame];
	img.image = [UIImage imageNamed:@"bg_states_picker_row.jpg"];
	img.center = CGPointMake(149,22.5);
	img.hidden = NO;
	img.userInteractionEnabled = NO;
	[self addSubview:img];
	
	blue = [[UIImageView alloc] initWithFrame:frame];
	blue.hidden = NO;
	blue.alpha = 0;
	blue.image = [UIImage imageNamed:@"bg_states_highlight.png"];
	blue.backgroundColor = [UIColor clearColor];
	blue.userInteractionEnabled = NO;
	[self addSubview:blue];
	
	title = [[UILabel alloc] initWithFrame:CGRectMake(0,0,200,44)];
	title.text = txt;
	title.textColor = [UIColor blackColor];
	title.font = [UIFont fontWithName:@"Helvetica" size:15];	
	title.backgroundColor = [UIColor clearColor];
	title.center = CGPointMake(110, 22);
	title.textAlignment = UITextAlignmentLeft;
    title.userInteractionEnabled = NO;
	[self addSubview:title];

	hotspot = [[UIButton alloc] initWithFrame:CGRectMake(0.0f, 0.0f, 298, 44)];
	[hotspot setCenter:CGPointMake(149, 22)];
	hotspot.backgroundColor = [UIColor clearColor];
	hotspot.userInteractionEnabled = YES;
	hotspot.hidden = NO;
	hotspot.alpha = 1;
	
	//[hotspot addTarget:self action:@selector(downState) forControlEvents:UIControlEventTouchDown];
	//[hotspot addTarget:self action:@selector(upState) forControlEvents:UIControlEventTouchUpInside];
}
-(void) downState {
	NSLog(@"downstate");
	title.textColor = [UIColor whiteColor];
	blue.alpha = .8;
}
-(void) upState {
	NSLog(@"upstate");
	title.textColor = [UIColor blackColor];
	blue.alpha = 0;
}
-(NSString *)getTxt {
	return title.text;
}
- (void)dealloc
{
	[title release];
	[blue release];
	[img release];
	[hotspot release];
	[super dealloc];
}


@end
