Browse files

Add more git ignore options.

Add support for IB.

Fix frame issue when creating instance with nib.
  • Loading branch information...
1 parent f854b99 commit 04188060166818493dec52b5283e337a0a141bb9 @slavikshen slavikshen committed Feb 21, 2013
Showing with 57 additions and 13 deletions.
  1. +25 −2 .gitignore
  2. +1 −1 BFPageControl.h
  3. +31 −10 BFPageControl.m
View
27 .gitignore
@@ -1,2 +1,25 @@
-Example/.DS_Store
-.DS_Store
+# Mac OS X
+*.DS_Store
+
+# Xcode
+*.pbxuser
+*.mode1v3
+*.mode2v3
+*.perspectivev3
+*.xcuserstate
+project.xcworkspace/
+xcuserdata/
+
+# Generated files
+*.o
+*.pyc
+
+
+#Python modules
+MANIFEST
+dist/
+build/
+
+# Backup files
+*~.nib
+*.swp
View
2 BFPageControl.h
@@ -97,6 +97,6 @@
/// @name Misc Properties
///---------------------------------------------------------------------------------------
-@property (nonatomic, assign)id <BFPageControlDelegate>delegate;
+@property (nonatomic, assign) IBOutlet id <BFPageControlDelegate>delegate;
@end
View
41 BFPageControl.m
@@ -80,7 +80,22 @@ @implementation BFPageControl
-(id)initWithFrame: (NSRect)frameRect
{
- if(self = [super initWithFrame: NSMakeRect(frameRect.origin.x, frameRect.origin.y, 0, 0)])
+ if(self = [super initWithFrame:frameRect])
+ {
+ _numberOfPages = 0;
+ _indicatorDiameterSize = 10.0;
+ _indicatorMargin = 5.0;
+ _matrix = nil;
+ _useHandCursor = NO;
+ _drawingBlock = nil;
+ _hidesForSinglePage = NO;
+ }
+
+ return self;
+}
+
+-(id)initWithCoder:(NSCoder *)aDecoder {
+ if(self = [super initWithCoder:aDecoder])
{
_numberOfPages = 0;
_indicatorDiameterSize = 10.0;
@@ -104,11 +119,21 @@ -(void)updateCurrentPageDisplay
if(_matrix)
[_matrix removeFromSuperview], _matrix = nil;
- if(_hidesForSinglePage && self.numberOfPages < 2)
+ NSUInteger numberOfPages = self.numberOfPages;
+ if(_hidesForSinglePage && numberOfPages < 2)
return;
NSSize size = [self sizeForNumberOfPages: _numberOfPages];
- NSRect frame = NSMakeRect(0, 0, size.width, size.height);
+
+ CGRect bounds = self.bounds;
+ CGFloat W = bounds.size.width;
+ CGFloat H = bounds.size.height;
+
+ CGFloat x = floorf((W-size.width)/2);
+ CGFloat y = floorf((H-size.height)/2);
+
+ NSRect frame = NSMakeRect(x, y, size.width, size.height);
+
_matrix = [[NSMatrix alloc] initWithFrame: frame mode: NSRadioModeMatrix cellClass: [BFPageControlCell class] numberOfRows: 1 numberOfColumns: _numberOfPages];
_matrix.drawsBackground = YES;
_matrix.backgroundColor = [NSColor clearColor];
@@ -119,9 +144,9 @@ -(void)updateCurrentPageDisplay
[_matrix setAction: @selector(_clickedItem:)];
[self addSubview: _matrix];
- frame.origin.y = self.frame.origin.y;
- frame.origin.x = self.frame.origin.x;
- super.frame = frame;
+// frame.origin.y = self.frame.origin.y;
+// frame.origin.x = self.frame.origin.x;
+// super.frame = frame;
__weak id wSelf = self;
void(^block)(NSRect, NSView *, BOOL, BOOL) = ^(NSRect frame, NSView *theView, BOOL isSelected, BOOL isHighlighted){
@@ -185,19 +210,15 @@ -(void)setCurrentPage:(NSInteger)currentPage
-(void)setFrame: (NSRect)frameRect
{
- frameRect.size = [self sizeForNumberOfPages: _numberOfPages];
[super setFrame: frameRect];
-
[self updateCurrentPageDisplay];
}
///////////////////////////////////////////////////////////////////////////////////////////////////
-(void)setBounds: (NSRect)aRect
{
- aRect.size = [self sizeForNumberOfPages: _numberOfPages];
[super setBounds: aRect];
-
[self updateCurrentPageDisplay];
}

0 comments on commit 0418806

Please sign in to comment.