//
//  WaitingView.m
//  NoteLedge for Mac
//
//  Created by kdanmobile on 14-3-31.
//  Copyright (c) 2014年 kdanmobile. All rights reserved.
//

#import "WaitingView.h"
@implementation NSView (Centering)

- (void) center {
    
    if (![self superview]) return;
    
    [self setFrame:NSMakeRect(
                              
                              0.5 * ([self superview].frame.size.width - self.frame.size.width),
                              0.5 * ([self superview].frame.size.height - self.frame.size.height),
                              
                              self.frame.size.width, 
                              self.frame.size.height
                              
                              )];
    
}

@end
@implementation WaitingView

- (id)initWithFrame:(NSRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        _indicator = [[NSProgressIndicator alloc] init];
        [_indicator setBezeled:NO];
        [_indicator setAutoresizingMask:63];
        [_indicator setStyle:NSProgressIndicatorSpinningStyle];
        [_indicator setControlSize:NSRegularControlSize];
        [_indicator setUsesThreadedAnimation:YES];
        [_indicator sizeToFit];
       
        [self addSubview:_indicator];
         [_indicator center];
    }
    return self;
}

- (void)startAnimation
{
    [_indicator startAnimation:nil];
}
- (void)drawRect:(NSRect)dirtyRect
{
	[[NSColor colorWithCalibratedRed:1.0 green:1.0 blue:1.0 alpha:0.5] set];
    [NSBezierPath fillRect:self.bounds];
}

- (void)mouseDown:(NSEvent *)theEvent
{
    
}
- (void)mouseUp:(NSEvent *)theEvent
{
    
}

@end