/******************************************************************************************************

	BXSheetController.h
	
 ******************************************************************************************************

	Author:			Peter Baumgartner		Tel:  (+4989) 649-43875
					Rosskopfstr. 20			Mail: peter@baumgartner.com
					82031 GrŸnwald			
					Germany					
	
					Copyright © 2006 by Peter Baumgartner - All Rights Reserved

 ******************************************************************************************************/

/******************************************************************************************************
	READ ME
 ******************************************************************************************************/

	#pragma mark READ ME

	// Generic controller that handles sheets provided by a datasource object...


	
/******************************************************************************************************
	CONSTANTS
 ******************************************************************************************************/

	#pragma mark CONSTANTS

	enum BXSheetTransitionStyle
	{
		kBXSheetTransitionStyleNone,
		kBXSheetTransitionStyleDissolve,
		kBXSheetTransitionStylePush
	};
	
	
	
/******************************************************************************************************
	BXSheetDatasource
 ******************************************************************************************************/

	#pragma mark

	// The datasource tells the controller how many panes the sheet contains. For each 
	// pane the datasource provides the view and info for its toolbar item...
	  
	@protocol BXSheetDatasource

	- (NSUInteger) numberOfPanes;
	
	- (NSString*) identifierAtIndex:(NSUInteger)inIndex;
	- (NSString*) toolbarNameAtIndex:(NSUInteger)inIndex;
	- (NSString*) toolbarTooltipAtIndex:(NSUInteger)inIndex;
	- (NSImage*) toolbarIconAtIndex:(NSUInteger)inIndex;
	- (NSView*) paneViewAtIndex:(NSUInteger)inIndex;

	@end



/******************************************************************************************************
	BXSheetController
 ******************************************************************************************************/

	#pragma mark

	@interface BXSheetController : NSWindowController <NSToolbarDelegate, NSWindowDelegate>
	{
		IBOutlet id<BXSheetDatasource> _datasource;
		IBOutlet id _delegate;
		
		// Sheet window and its toolbar...

		NSWindow* _parentWindow;
		NSWindow* _sheet;
		NSToolbar* _toolbar;
		
		NSUInteger _paneCount;
		NSUInteger _selectedPaneIndex;

		NSMutableArray* _paneIdentifiers;
		NSMutableDictionary* _toolbarItems;
		NSMutableArray* _paneViews;
		
		// Visual configuration...
		
		NSInteger _transitionStyle;
		BOOL _allowsHorizontalResizing;
		BOOL _allowsVerticalResizing;
		BOOL _windowNeedsResizing;
		BOOL _showsToolbar;
		BOOL _showsResizeIndicator;
		NSToolbarDisplayMode _toolbarDisplayMode;
		NSToolbarSizeMode _toolbarSizeMode;
		
		// Buttons...
		
		NSMutableArray* _buttonSpecs;
		NSMutableArray* _buttons;
		NSInteger _dismissButton;
		NSView* _auxilliaryView;
	}

	// Datasource & Delegate...
	
	- (void) setDatasource:(id<BXSheetDatasource>)inDatasource;
	- (id<BXSheetDatasource>) datasource;

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

	// Visual Configuration...
	
	- (void) setTransitionStyle:(NSInteger)inTransitionStyle;
	- (NSInteger) transitionStyle;

	- (void) setAllowsHorizontalResizing:(BOOL)inAllowsHorizontalResizing;
	- (BOOL) allowsHorizontalResizing;

	- (void) setAllowsVerticalResizing:(BOOL)inAllowVerticalResizing;
	- (BOOL) allowsVerticalResizing;

	- (void) setShowsResizeIndicator:(BOOL)inShowsResizeIndicator;
	- (BOOL) showsResizeIndicator;

	- (void) setShowsToolbar:(BOOL)inShowsToolbar;
	- (BOOL) showsToolbar;

	- (void) setToolbarDisplayMode:(NSToolbarDisplayMode)inDisplayMode;
	- (NSToolbarDisplayMode) toolbarDisplayMode;

	- (void) setToolbarSizeMode:(NSToolbarSizeMode)inSizeMode;
	- (NSToolbarSizeMode) toolbarSizeMode;
	
	- (void) addButtonWithTitle:(NSString*)inTitle keyEquivalent:(NSString*)inKey tag:(NSInteger)inTag offset:(CGFloat)inOffset;
	- (NSButton*) buttonAtIndex:(NSUInteger)inIndex;

	- (void) setAuxilliaryView:(NSView*)inView;
	- (NSView*) auxilliaryView;
	
	// Handle Sheet...
	
	- (void) showSheetForParentWindow:(NSWindow*)inWindow;
	- (void) showSheetForParentWindow:(NSWindow*)inWindow modal:(BOOL)inModal;

	- (void) selectPaneAtIndex:(NSUInteger)inIndex;
	- (void) selectPaneAtIndex:(NSUInteger)inIndex animate:(BOOL)inAnimate;
	- (NSUInteger) selectedPane;
	
	- (IBAction) hideSheet:(id)inSender;

	@end



/******************************************************************************************************
	BXSheetDelegate
 ******************************************************************************************************/

	#pragma mark

	// The controller notifies its delegate of certain events with the following messages...
	  
	@interface BXSheetDelegate : NSObject
	
	- (void) sheetController:(id)inController willShowSheet:(NSWindow*)inSheet;
	- (void) sheetController:(id)inController willHideSheet:(NSWindow*)inSheet withButton:(NSInteger)inButton;
	- (void) sheetController:(id)inController didHideSheet:(NSWindow*)inSheet withButton:(NSInteger)inButton;

	- (void) sheetController:(id)inController willSelectPaneAtIndex:(NSUInteger)inIndex;
	- (void) sheetController:(id)inController didSelectPaneAtIndex:(NSUInteger)inIndex;

	@end



/******************************************************************************************************/
