
#import <UIKit/UIKit.h>
#import <OpenGLES/ES1/gl.h>



CGPathRef CGPathCreateWithRoundedRect(CGRect rect, CGFloat r);


@interface GLQuartzTexture : NSObject
{
	GLuint		texName;
	CGSize		textureSize;
	
	BOOL		antialias, subpixelAA;
	BOOL		filterTexture, mipmapTexture;

	double		texturePadding;
	
	BOOL		requiresUpdate;
}


- (void) drawWithBounds:(CGRect)bounds;
- (void) drawCenteredAtPoint:(CGPoint)point scaled: (double) scale;
- (void) drawAtPoint:(CGPoint)point scaled: (double) scale;
- (void) drawAtPoint:(CGPoint)point;
- (void) drawCenteredAtPoint:(CGPoint)point;

- (GLuint) texName; // 0 if no texture allocated

- (void) bindTexture;
- (void) genTexture; // generates the texture without drawing texture to current context
- (void) updateTextureIfRequired;

- (void) freeGLResources;

@property(nonatomic) BOOL antialias;
@property(nonatomic) BOOL subpixelAA;
@property(nonatomic) BOOL filterTexture;
@property(nonatomic) BOOL mipmapTexture;
@property(nonatomic) double texturePadding;
@property(readonly) CGSize textureSize;
@property(readonly) GLuint texName;

@end


@interface GLQuartzArc : GLQuartzTexture
{
	UIColor*	fillColor;
	UIColor*	borderColor;
	double		innerRadius, outerRadius;
	double		borderWidth;
	double		startAngle, endAngle;
	double		cornerRadius;
}

@property(retain, nonatomic) UIColor* fillColor;
@property(retain, nonatomic) UIColor* borderColor;

@property(nonatomic) double innerRadius;
@property(nonatomic) double outerRadius;
@property(nonatomic) double startAngle;
@property(nonatomic) double endAngle;
@property(nonatomic) double borderWidth;
@property(nonatomic) double cornerRadius;

@end

@interface GLQuartzBox : GLQuartzTexture
{
	UIColor*	boxColor;
	UIColor*	borderColor;
	CGSize		frameSize;
	double		cornerRadius;
	double		borderWidth;
}

@property(retain, nonatomic) UIColor* boxColor;
@property(retain, nonatomic) UIColor* borderColor;

@property(nonatomic) CGSize frameSize;
@property(nonatomic) double cornerRadius;
@property(nonatomic) double borderWidth;

@end


@interface GLString : GLQuartzBox
{
	UIFont*		font;
	NSString*	string;
	UIColor*	textColor;
	BOOL		staticFrame;

	CGSize		marginSize;
}

+ (UIFont*) defaultFont;

// this API requires a current rendering context and all operations will be performed in regards to thar context
// the same context should be current for all method calls for a particular object instance

// designated initializer
- (id) initWithString:(NSString *)aString withFont:(UIFont*)theFont withTextColor:(UIColor *)color withBoxColor:(UIColor *)color withBorderColor:(UIColor *)color;

- (id) initWithString:(NSString *)astring;

// basic methods that pick up defaults
- (id) initWithString:(NSString *)aString withFont:(UIFont *)aFont;

- (BOOL) staticFrame; // returns whether or not a static frame will be used

- (CGSize) marginSize; // current margins for text offset and pads for dynamic frame

// these will force the texture to be regenerated at the next draw
- (void) setMargins:(CGSize)size; // set offset size and size to fit with offset
- (void) useStaticFrame:(CGSize)size; // set static frame size and size to frame
- (void) useDynamicFrame; // set static frame size and size to frame

- (void) setString:(NSString *)theString;
- (void) setFont: (UIFont*) aFont;

@property(retain, nonatomic) UIColor* textColor;

@end


