//  Copyright 2009 Todd Ditchendorf
//
//  Licensed under the Apache License, Version 2.0 (the "License");
//  you may not use this file except in compliance with the License.
//  You may obtain a copy of the License at
//
//  http://www.apache.org/licenses/LICENSE-2.0
//
//  Unless required by applicable law or agreed to in writing, software
//  distributed under the License is distributed on an "AS IS" BASIS,
//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
//  See the License for the specific language governing permissions and
//  limitations under the License.

#import <Cocoa/Cocoa.h>

@class IDEUberView;
@class TDHintView;

@class IDEUberViewSplitViewDelegateInternal;

@protocol IDEUberViewDelegate <NSObject>
// TODO
@end

@interface IDEUberView : NSView <NSSplitViewDelegate> {
    id <IDEUberViewDelegate>delegate;
    IDEUberViewSplitViewDelegateInternal *internalDelegate;
    
    NSString *autosaveName;
    
    NSSplitView *verticalSplitView;
    NSSplitView *horizontalSplitView;
    NSSplitView *leftSplitView;
    NSSplitView *rightSplitView;
    TDHintView *leftSuperview;
    TDHintView *leftTopSuperview;
    TDHintView *leftBottomSuperview;
    TDHintView *rightSuperview;
    TDHintView *rightTopSuperview;
    TDHintView *rightBottomSuperview;
    TDHintView *bottomSuperview;
    TDHintView *midSuperview;
    TDHintView *topSuperview;
    NSView *leftView;
    NSView *leftTopView;
    NSView *leftBottomView;
    NSView *rightView;
    NSView *rightTopView;
    NSView *rightBottomView;
    NSView *bottomView;
    NSView *midView;
    NSView *topView;
    BOOL leftViewOpen;
    BOOL leftTopViewOpen;
    BOOL leftBottomViewOpen;
    BOOL rightViewOpen;
    BOOL rightTopViewOpen;
    BOOL rightBottomViewOpen;
    BOOL topViewOpen;
    BOOL bottomViewOpen;
    
    NSString *currentLeftIdentifier;
    NSString *currentRightIdentifier;
    NSString *currentTopIdentifier;
    NSString *currentBottomIdentifier;

    NSTimer *timer;
    NSSplitViewDividerStyle splitViewDividerStyle;
    CGFloat preferredLeftSplitWidth;
    CGFloat alternateRightSplitWidth;
    CGFloat maxLeftSplitWidth;
    CGFloat preferredRightSplitWidth;
    CGFloat alternateLeftSplitWidth;
    CGFloat maxRightSplitWidth;
    CGFloat preferredLeftBottomSplitHeight;
    CGFloat maxLeftBottomSplitHeight;
    CGFloat preferredRightBottomSplitHeight;
    CGFloat maxRightBottomSplitHeight;
    CGFloat preferredTopSplitHeight;
    CGFloat maxTopSplitHeight;
    CGFloat preferredBottomSplitHeight;
    CGFloat maxBottomSplitHeight;
    
    BOOL snapsToPreferredSplitWidths;
    CGFloat snapTolerance;

    CGFloat dragStartMidWidth;
    CGFloat dragStartRightRatio;
    CGFloat dragStartLeftRatio;
    CGFloat dragStartMidHeight;
    CGFloat dragStartTopRatio;
    CGFloat dragStartBottomRatio;
}

// designated initializer
- (id)initWithFrame:(NSRect)frame dividerStyle:(NSSplitViewDividerStyle)dividerStyle;

- (IBAction)resetToPreferredSplitPositions:(id)sender;

- (IBAction)toggleLeftView:(id)sender;
- (IBAction)openLeftView:(id)sender;
- (IBAction)closeLeftView:(id)sender;

- (IBAction)toggleLeftTopView:(id)sender;
- (IBAction)openLeftTopView:(id)sender;
- (IBAction)closeLeftTopView:(id)sender;

- (IBAction)toggleLeftBottomView:(id)sender;
- (IBAction)openLeftBottomView:(id)sender;
- (IBAction)closeLeftBottomView:(id)sender;

- (IBAction)toggleRightView:(id)sender;
- (IBAction)openRightView:(id)sender;
- (IBAction)closeRightView:(id)sender;

- (IBAction)toggleRightTopView:(id)sender;
- (IBAction)openRightTopView:(id)sender;
- (IBAction)closeRightTopView:(id)sender;

- (IBAction)toggleRightBottomView:(id)sender;
- (IBAction)openRightBottomView:(id)sender;
- (IBAction)closeRightBottomView:(id)sender;

- (IBAction)toggleTopView:(id)sender;
- (IBAction)openTopView:(id)sender;
- (IBAction)closeTopView:(id)sender;

- (IBAction)toggleBottomView:(id)sender;
- (IBAction)openBottomView:(id)sender;
- (IBAction)closeBottomView:(id)sender;

- (void)reflectStoredOpenStates;

@property (nonatomic, assign) id <IDEUberViewDelegate>delegate; // weak ref

@property (nonatomic, copy) NSString *autosaveName;

//@property (nonatomic, retain) NSView *leftView;
@property (nonatomic, retain) NSView *leftTopView;
@property (nonatomic, retain) NSView *leftBottomView;
//@property (nonatomic, retain) NSView *rightView;
@property (nonatomic, retain) NSView *rightTopView;
@property (nonatomic, retain) NSView *rightBottomView;
@property (nonatomic, retain) NSView *topView;
@property (nonatomic, retain) NSView *midView;
@property (nonatomic, retain) NSView *bottomView;

@property (nonatomic, retain) NSSplitView *verticalSplitView; // this one has split divider lines running north south
@property (nonatomic, retain) NSSplitView *horizontalSplitView; // this one has split divider lines running east west
@property (nonatomic, retain) NSSplitView *leftSplitView;
@property (nonatomic, retain) NSSplitView *rightSplitView;

@property (nonatomic) NSSplitViewDividerStyle splitViewDividerStyle;
@property (nonatomic) CGFloat preferredLeftSplitWidth;
@property (nonatomic) CGFloat alternateRightSplitWidth;
@property (nonatomic) CGFloat maxLeftSplitWidth;
@property (nonatomic) CGFloat preferredRightSplitWidth;
@property (nonatomic) CGFloat alternateLeftSplitWidth;
@property (nonatomic) CGFloat maxRightSplitWidth;
@property (nonatomic) CGFloat preferredLeftBottomSplitHeight;
@property (nonatomic) CGFloat maxLeftBottomSplitHeight;
@property (nonatomic) CGFloat preferredRightBottomSplitHeight;
@property (nonatomic) CGFloat maxRightBottomSplitHeight;
@property (nonatomic) CGFloat preferredTopSplitHeight;
@property (nonatomic) CGFloat maxTopSplitHeight;
@property (nonatomic) CGFloat preferredBottomSplitHeight;
@property (nonatomic) CGFloat maxBottomSplitHeight;

@property (nonatomic) BOOL snapsToPreferredSplitWidths;
@property (nonatomic) CGFloat snapTolerance;

@property (nonatomic, readonly, getter=isLeftViewOpen) BOOL leftViewOpen;
@property (nonatomic, readonly, getter=isLeftTopViewOpen) BOOL leftTopViewOpen;
@property (nonatomic, readonly, getter=isLeftBottomViewOpen) BOOL leftBottomViewOpen;
@property (nonatomic, readonly, getter=isRightViewOpen) BOOL rightViewOpen;
@property (nonatomic, readonly, getter=isRightTopViewOpen) BOOL rightTopViewOpen;
@property (nonatomic, readonly, getter=isRightBottomViewOpen) BOOL rightBottomViewOpen;
@property (nonatomic, readonly, getter=isTopViewOpen) BOOL topViewOpen;
@property (nonatomic, readonly, getter=isBottomViewOpen) BOOL bottomViewOpen;
@end
