Permalink
Browse files

Enable programmatic creation of BCCollectionViews

  • Loading branch information...
1 parent 0c003d7 commit a02ce7b340413bb801e27d7978e3f7d1b3680d64 @aaronbrethorst aaronbrethorst committed May 3, 2011
Showing with 36 additions and 17 deletions.
  1. +36 −17 BCCollectionView.m
View
@@ -7,35 +7,54 @@
#import "BCCollectionViewLayoutItem.h"
#import "BCCollectionViewGroup.h"
+@interface BCCollectionView ()
+- (void)configureView;
+@end
+
+
@implementation BCCollectionView
@synthesize delegate, contentArray, groups, backgroundColor, originalSelectionIndexes, zoomValueObserverKey, accumulatedKeyStrokes, numberOfPreRenderedRows, layoutManager;
@dynamic visibleViewControllerArray;
+- (id)initWithFrame:(NSRect)frameRect
+{
+ self = [super initWithFrame:frameRect];
+ if (self) {
+ [self configureView];
+ }
+ return self;
+}
+
- (id)initWithCoder:(NSCoder *)aDecoder
{
self = [super initWithCoder:aDecoder];
if (self) {
- reusableViewControllers = [[NSMutableArray alloc] init];
- visibleViewControllers = [[NSMutableDictionary alloc] init];
- contentArray = [[NSArray alloc] init];
- selectionIndexes = [[NSMutableIndexSet alloc] init];
- dragHoverIndex = NSNotFound;
- accumulatedKeyStrokes = [[NSString alloc] init];
- numberOfPreRenderedRows = 3;
- layoutManager = [[BCCollectionViewLayoutManager alloc] initWithCollectionView:self];
- visibleGroupViewControllers = [[NSMutableDictionary alloc] init];
-
- [self addObserver:self forKeyPath:@"backgroundColor" options:0 context:NULL];
-
- NSClipView *enclosingClipView = [[self enclosingScrollView] contentView];
- [enclosingClipView setPostsBoundsChangedNotifications:YES];
- NSNotificationCenter *center = [NSNotificationCenter defaultCenter];
- [center addObserver:self selector:@selector(scrollViewDidScroll:) name:NSViewBoundsDidChangeNotification object:enclosingClipView];
- [center addObserver:self selector:@selector(viewDidResize) name:NSViewFrameDidChangeNotification object:self];
+ [self configureView];
}
return self;
}
+- (void)configureView
+{
+ reusableViewControllers = [[NSMutableArray alloc] init];
+ visibleViewControllers = [[NSMutableDictionary alloc] init];
+ contentArray = [[NSArray alloc] init];
+ selectionIndexes = [[NSMutableIndexSet alloc] init];
+ dragHoverIndex = NSNotFound;
+ accumulatedKeyStrokes = [[NSString alloc] init];
+ numberOfPreRenderedRows = 3;
+ layoutManager = [[BCCollectionViewLayoutManager alloc] initWithCollectionView:self];
+ visibleGroupViewControllers = [[NSMutableDictionary alloc] init];
+
+ [self addObserver:self forKeyPath:@"backgroundColor" options:0 context:NULL];
+
+ NSClipView *enclosingClipView = [[self enclosingScrollView] contentView];
+ [enclosingClipView setPostsBoundsChangedNotifications:YES];
+ NSNotificationCenter *center = [NSNotificationCenter defaultCenter];
+ [center addObserver:self selector:@selector(scrollViewDidScroll:) name:NSViewBoundsDidChangeNotification object:enclosingClipView];
+ [center addObserver:self selector:@selector(viewDidResize) name:NSViewFrameDidChangeNotification object:self];
+}
+
- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context
{
if ([keyPath isEqualToString:@"backgroundColor"])

0 comments on commit a02ce7b

Please sign in to comment.