Source

PixelCity Mac / PixelCity_SaverView.m

Full commit
//
//  PixelCity_SaverView.m
//  PixelCity-Saver
//
//  Created by Blake Winton on 10-11-18.
//

#import "PixelCity_SaverView.h"

@implementation PixelCity_SaverView

- (id)initWithFrame:(NSRect)frame isPreview:(BOOL)isPreview
{
    self = [super initWithFrame:frame isPreview:isPreview];
    if (self) {
        glView = [[PixelCityView alloc] initWithFrame:NSZeroRect pixelFormat:[PixelCityView basicPixelFormat]];
        if (!glView)
        {
            [self autorelease];
            return nil;
        }

        [self addSubview:glView];
        [[glView openGLContext] makeCurrentContext];

        [self setAnimationTimeInterval:1/30.0];
    }
    return self;
}

- (void)setFrameSize:(NSSize)newSize
{
    [super setFrameSize:newSize];
    [glView setFrameSize:newSize];
}


- (void)dealloc
{
    [glView removeFromSuperview];
    [glView release];
    [super dealloc];
}

- (void)startAnimation
{
    [super startAnimation];
}

- (void)stopAnimation
{
    [super stopAnimation];
}

- (void)drawRect:(NSRect)rect
{
    //[super drawRect:rect];
    [glView drawRect:rect];
}

- (void)animateOneFrame
{
    // Redraw
    [self setNeedsDisplay:YES];
    return;
}

- (BOOL)hasConfigureSheet
{
    return NO;
}

- (NSWindow*)configureSheet
{
    return nil;
}

@end