//
//  LCObjectEditor.h
//  LCToolkit
//
//  Created by Logan Collins on 7/24/10.
//  Copyright 2010 Logan Collins. All rights reserved.
//

#import <Cocoa/Cocoa.h>


/* LCObjectEditor is an abstract class that displays a window to edit objects
 */
@interface LCObjectEditor : NSWindowController {
@private
	NSMutableArray *editors;
	
	id modalDelegate;
	SEL didEndSelector;
	
#if NS_BLOCKS_AVAILABLE
	void (^completionHandler)(NSInteger result);
#endif
}

// Running

// Run modally
- (NSInteger)runModal;

// Run as a sheet
// The selector should have the following signature:
// - (void)editorDidEnd:(LCObjectEditingController *)anEditingController returnCode:(NSInteger)returnCode contextInfo:(void *)contextInfo;
- (void)beginSheetModalForWindow:(NSWindow *)window modalDelegate:(id)delegate didEndSelector:(SEL)selector contextInfo:(void *)contextInfo;

// Block counterparts to the above methods, if blocks are available
#if NS_BLOCKS_AVAILABLE
- (void)beginWithCompletionHandler:(void (^)(NSInteger result))handler;
- (void)beginSheetModalForWindow:(NSWindow *)window completionHandler:(void (^)(NSInteger result))handler;
#endif

// Actions

- (IBAction)ok:(id)sender;
- (IBAction)cancel:(id)sender;

// NSEditor and NSEditorRegistration
- (BOOL)commitEditing;
- (void)commitEditingWithDelegate:(id)delegate didCommitSelector:(SEL)didCommitSelector contextInfo:(void *)contextInfo;
- (void)discardEditing;
- (void)objectDidBeginEditing:(id)editor;
- (void)objectDidEndEditing:(id)editor;

@end
