//
//  BXContactSheetView.h
//  BXAppKit
//
//  Created by Michael Ehrmann on 06.09.04.
//  Copyright 2004 Boinx Software. All rights reserved.
//

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

#pragma mark #define
//#define showMethodNames
//#define debugDrawing
//#define debugScaling
//#define debugSelection
//#define debugMouseDown
//#define debugDataSource
//#define debugSelectionRect
//#define debugDraggingImage

// extern CGFloat kBackgroundColorThreshold;

@interface BXContactSheetView : NSControl {
	NSUInteger rowCount, columnCount;

	NSSize maxCellSize;
	NSSize minCellSize;
	
	NSSize cellSize;
	NSSize cellPadding;
	NSSize innerCellPadding;
	NSSize cellSpacing;
	BOOL horizontal;
	
	NSSize viewMargin;
	
	NSColor* backgroundColor;
	NSColor* imageNameColor;
	NSColor* selectionColor;

	CGFloat cellSizeScaleFactor;
	CGFloat cellSelectionCornerRadius;

	BOOL drawImageNames;
	BOOL drawShadow;
	BOOL drawBorder;
	
	BOOL hasFlexibleXCellSpacing;
	
	BOOL allowsMultipleSelection;
	//BOOL allowsEmptySelection;
	
	IBOutlet id zoomSlider;
	IBOutlet NSObject <BXContactSheetDataSource> *dataSource;
	IBOutlet id delegate;
	
	NSMutableArray *_cells;
	NSMutableArray *_selectedItems;
	
	NSInteger _indexOfSelectedItem;
	BOOL _postSelectionDidChangeNotification;
	
	NSRect _selectionRect;
	NSPoint _mouseDownPoint;
	NSPoint _mouseDownPointInWindow;//ds...
	NSPoint _mouseDownScrollPosition;//ds...
	NSInteger _mouseOperation;

	BOOL _spaceKey;//ds...
	BOOL _madeFirstResponder;//ds...
	
	@private
		SEL	_doubleClickAction;     
}

- (IBAction)selectAll:(id)sender;
- (IBAction)deselectAll:(id)sender;

- (void)awakeFromNib;

- (void)selectItemAtIndex:(NSInteger)index;
- (void)deselectItemAtIndex:(NSInteger)index;
- (void)toggleSelectionOfItemAtIndex:(NSInteger)index;
- (void)selectItemsFromIndex:(NSInteger)ancorIndex toIndex:(NSInteger)endIndex;
- (void)selectAll;
- (void)deselectAll;
- (NSInteger)numberOfSelectedItems;
- (NSInteger)indexOfSelectedItem;
- (NSArray*)selectedItems;
- (BOOL)isSelectedItemAtIndex:(NSInteger)index;

- (NSArray*)cells;
- (NSArray*)selectedCells;
- (NSInteger)numberOfCells;
- (NSInteger)numberOfSelectedCells;

- (void)scrollCellToVisibleAtIndex:(NSInteger)index;

- (void)recalculateSizes;

- (void)clearData;
- (void)reloadData;
- (void)reloadDataAtIndex:(NSUInteger)index;

- (void)postSelectionDidChangeNotification;
- (void)postDeleteSelectionChangeNotification;

- (IBAction)changeCellSizeScaleFactor:(id)sender;

- (SEL)doubleClickAction;
- (void)setDoubleClickAction:(SEL)aSelector;

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

- (NSObject <BXContactSheetDataSource> *)dataSource;
- (void)setDataSource:(NSObject <BXContactSheetDataSource> *)newDataSource;

- (BOOL)spaceKey;
- (void)setSpaceKey:(BOOL)value;

- (CGFloat)cellSizeScaleFactor;
- (void)setCellSizeScaleFactor:(CGFloat)factor;

- (BOOL)drawImageNames;
- (void)setDrawImageNames:(BOOL)value;

- (NSColor*)backgroundColor;
- (void)setBackgroundColor:(NSColor*)value;

- (NSColor*)selectionColor;
- (void)setSelectionColor:(NSColor*)value;

- (BOOL)drawShadow;
- (void)setDrawShadow:(BOOL)value;

- (BOOL)drawBorder;
- (void)setDrawBorder:(BOOL)value;

- (BOOL)hasFlexibleXCellSpacing;
- (void)setHasFlexibleXCellSpacing:(BOOL)value;

- (BOOL)allowsMultipleSelection;
- (void)setAllowsMultipleSelection:(BOOL)value;

//- (BOOL)allowsEmptySelection;
//- (void)setAllowsEmptySelection:(BOOL)value;

- (CGFloat)cellSelectionCornerRadius;
- (void)setCellSelectionCornerRadius:(CGFloat)value;

- (NSSize)cellSize;
- (void)setCellSize:(NSSize)size;

- (NSSize)minCellSize;
- (void)setMinCellSize:(NSSize)size;

- (NSSize)maxCellSize;
- (void)setMaxCellSize:(NSSize)size;

- (NSSize)cellSpacing;
- (void)setCellSpacing:(NSSize)size;

- (NSSize)cellPadding;
- (void)setCellPadding:(NSSize)size;

- (NSSize)innerCellPadding;
- (void)setInnerCellPadding:(NSSize)size;

- (NSSize)viewMargin;
- (void)setViewMargin:(NSSize)size;

- (BOOL)horizontal;
- (void)setHorizontal:(BOOL)inHorizontal;

@end
