//
//  SRRecorderCell.h
//  ShortcutRecorder
//
//  Copyright 2006 Contributors. All rights reserved.
//
//  License: BSD
//
//  Contributors:
//      David Dauer
//      Jesper
//      Jamie Kirkpatrick

// #import <Cocoa/Cocoa.h> //Imported in PrefixHeader
#import "SRCommon.h"

#define SRMinWidth 50
#define SRMaxHeight 20

@class SRRecorderControl, CTGradient, SRValidator;

enum SRRecorderStyle {
    SRGradientBorderStyle = 0,
    SRGreyStyle = 1
};
typedef enum SRRecorderStyle SRRecorderStyle;

@interface SRRecorderCell : NSActionCell <NSCoding>
{	
	CTGradient          *recordingGradient;
	CTGradient          *backgroundGradient;
	CTGradient          *disabledBackgroundGradient;
	NSString            *autosaveName;

	BOOL                isRecording;
	BOOL                mouseInsideTrackingArea;
	BOOL                mouseDown;
	BOOL                isFirstResponder;
	
	SRRecorderStyle		style;
	
	BOOL				isAnimating;
	double				transitionProgress;
	BOOL				isAnimatingNow;
	BOOL				isAnimatingTowardsRecording;
	BOOL				comboJustChanged;

	NSTrackingRectTag   removeTrackingRectTag;
	NSTrackingRectTag   snapbackTrackingRectTag;
	
	KeyCombo            keyCombo;
	BOOL				hasKeyChars;
	NSString		    *keyChars;
	NSString		    *keyCharsIgnoringModifiers;
	
	NSUInteger        allowedFlags;
	NSUInteger        requiredFlags;
	NSUInteger        recordingFlags;
	
	BOOL				allowsKeyOnly;
	BOOL				escapeKeysRecord;
	BOOL				_ignoresValidation;  // added by Boinx
	BOOL				_blackTextWhenEmpty;	// added by Boinx
	
	NSSet               *cancelCharacterSet;
	
    SRValidator         *validator;
    
	IBOutlet id         delegate;
	BOOL				globalHotKeys;
	void				*hotKeyModeToken;
}

- (void)resetTrackingRects;

#pragma mark *** Aesthetics ***

+ (BOOL)styleSupportsAnimation:(SRRecorderStyle)style;

- (BOOL)animates;
- (void)setAnimates:(BOOL)an;
- (SRRecorderStyle)style;
- (void)setStyle:(SRRecorderStyle)nStyle;

#pragma mark *** Delegate ***

- (id)delegate;
- (void)setDelegate:(id)aDelegate;

#pragma mark *** Responder Control ***

- (BOOL)becomeFirstResponder;
- (BOOL)resignFirstResponder;
 
#pragma mark *** Key Combination Control ***

- (BOOL)performKeyEquivalent:(NSEvent *)theEvent;
- (void)flagsChanged:(NSEvent *)theEvent;

- (NSUInteger)allowedFlags;
- (void)setAllowedFlags:(NSUInteger)flags;

- (NSUInteger)requiredFlags;
- (void)setRequiredFlags:(NSUInteger)flags;

- (BOOL)allowsKeyOnly;
- (void)setAllowsKeyOnly:(BOOL)nAllowsKeyOnly escapeKeysRecord:(BOOL)nEscapeKeysRecord;
- (BOOL)escapeKeysRecord;

- (BOOL)canCaptureGlobalHotKeys;
- (void)setCanCaptureGlobalHotKeys:(BOOL)inState;

// added by Boinx to make Shortcut Recorder record global hot keys in Mousepose
- (BOOL)ignoresValidation;
- (void)setIgnoresValidation:(BOOL)inFlag;
// until here

// added by Boinx to make Shortcut Recorder drawing black text, in Mousepose even if shortcut recorder is empty 
- (BOOL)blackTextWhenEmpty;
- (void)setBlackTextWhenEmpty:(BOOL)inFlag;
// until here


- (KeyCombo)keyCombo;
- (void)setKeyCombo:(KeyCombo)aKeyCombo;
- (void)updateWithKeyCombo:(KeyCombo)aKeyCombo;	// just updates the display, e.g. to reflect a selection change

#pragma mark *** Autosave Control ***

- (NSString *)autosaveName;
- (void)setAutosaveName:(NSString *)aName;

// Returns the displayed key combination if set
- (NSString *)keyComboString;

- (NSString *)keyChars;
- (NSString *)keyCharsIgnoringModifiers;

@end

// Delegate Methods
@interface NSObject (SRRecorderCellDelegate)

- (BOOL)shortcutRecorderCell:(SRRecorderCell *)aRecorderCell isKeyCode:(signed short)keyCode andFlagsTaken:(NSUInteger)flags reason:(NSString **)aReason;
- (void)shortcutRecorderCell:(SRRecorderCell *)aRecorderCell keyComboDidChange:(KeyCombo)newCombo;
- (void)shortcutRecorderCell:(SRRecorderCell *)aRecorderCell beginsRecordingForKeyCombo:(KeyCombo)newCombo;
- (void)shortcutRecorderCell:(SRRecorderCell *)aRecorderCell endsRecordingForKeyCombo:(KeyCombo)newCombo;

@end
