//
//  LCObjectsContainer.h
//  LogoistCore
//
//  Created by Mendel Kucharzeck on 14.12.11.
//  Copyright 2011 AvisNocturna Software. All rights reserved.
//

#import "LCObjectsChangeManager.h"
#import "LCChangeManagerAwareObject.h"

@class LCBaseObject;
@class LCObjectsTimelineManager;
@protocol LCObjectsContainerDelegate;

@interface LCObjectsContainer : LCChangeManagerAwareObject <NSCopying>
{
    NSMutableArray *objects;
    
    CGSize size;
    id backgroundColor;
    
    BOOL showGrid;
    NSInteger gridDistance;
    id gridColor;
    
    BOOL showRulers;
    float rulerOpacity;
    
    BOOL showRulerGuides;
    id rulerGuideColor;
    
    BOOL clipsToBounds;
    
    NSUndoManager *undoManager;
    LCObjectsChangeManager *changeManager;
    
    LCObjectsTimelineManager *timelineManager;
    
    NSMutableArray *objectsToNotify;
    NSMutableArray *delegates;
    
    NSMutableSet *changedObjectsForDelegates;
    NSMutableSet *changedObjectsForDelegatesAnimated;
    NSTimer *delayedNotifyDelegatesTimer;
    
    NSMutableArray *rulerGuides;
}

- (void) addObject:(LCBaseObject*)object;
- (void) addNewlyCreatedObject:(LCBaseObject*)object;               //Same as addObject, but calls setStandardSize...
- (void) addObjects:(NSArray*)objects;
- (void) removeObject:(LCBaseObject*)object;
- (void) removeObjects:(NSArray*)objects;
- (void) reorderObject:(LCBaseObject*)object toIndex:(NSUInteger)index;
- (void) bringToFront:(LCBaseObject*)object;
- (void) sendToBack:(LCBaseObject*)object;
@property (readonly) NSArray *objects;
@property (readonly) NSArray *allRootLevelObjects;                   //Does filter out combined objects
@property (readonly) NSArray *allUnlockedObjects;                    //Does filter out locked objects
@property (readonly) NSArray *allUnlockedRootLevelObjects;           //Does filter out locked and combined objects

@property (assign) CGSize size;
@property (readonly) CGRect rectOfAllObjects;
- (void) setSizeWithoutMovingObjects:(CGSize)s;
- (void) sizeToFit;

@property (retain) id backgroundColor;

@property (assign) BOOL showGrid;
@property (assign) NSInteger gridDistance;
@property (retain) id gridColor;

@property (assign) BOOL showRulers;
@property (assign) float rulerOpacity;

@property (assign) BOOL showRulerGuides;
@property (retain) id rulerGuideColor;

@property (assign) BOOL clipsToBounds;

@property (retain) NSUndoManager *undoManager;
@property (readonly) LCObjectsChangeManager *changeManager;

@property (retain) LCObjectsTimelineManager *timelineManager;

- (void) addDelegate:(id <LCObjectsContainerDelegate>)delegate;
- (void) removeDelegate:(id <LCObjectsContainerDelegate>)delegate;
- (void) removeAllDelegates;
- (void) notifyDelegatesAboutChangedObject:(LCBaseObject*)changedObject animated:(BOOL)animated;
- (void) notifyDelegatesAboutChangedObjects:(NSSet*)changedObjects animated:(BOOL)animated;

@end
