Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Branch: master
Fetching contributors…

Cannot retrieve contributors at this time

105 lines (82 sloc) 3.364 kB
//
// MyDocument.m
// BezierBuilder
//
// Created by Dave DeLong on 7/7/09.
// Copyright 2009 __MyCompanyName__. All rights reserved.
//
#import "MyDocument.h"
#import "BezierPoint.h"
#import "CodeBuilder.h"
#import "NSBezierPathCodeBuilder.h"
#import "CGPathRefCodeBuilder.h"
@implementation MyDocument
@synthesize bezierView, bezierCodeView;
@synthesize codeOption;
@synthesize originControl;
@synthesize codeStyleControl;
- (void) rebuildSteps {
Class builderClass = Nil;
if ([codeStyleControl selectedSegment] == 0) {
builderClass = [NSBezierPathCodeBuilder class];
}
else {
builderClass = [CGPathRefCodeBuilder class];
}
CodeBuilder *builder = [[builderClass alloc] init];
[builder setBezierPoints:[bezierView bezierPoints]];
if ([originControl selectedSegment] == 1) {
[builder setYOrigin:[bezierView bounds].size.height];
}
else {
[builder setYOrigin:0.0];
}
[bezierCodeView setString:[builder codeForBezierPoints]];
[builder release];
}
- (void) codeOptionChanged:(id)sender {
[self rebuildSteps];
}
- (void) elementsDidChangeInBezierView:(BezierView *)view {
[self rebuildSteps];
[bezierView setNeedsDisplay:YES];
}
- (id)init
{
self = [super init];
if (self) {
}
return self;
}
- (NSString *)windowNibName
{
// Override returning the nib file name of the document
// If you need to use a subclass of NSWindowController or if your document supports multiple NSWindowControllers, you should remove this method and override -makeWindowControllers instead.
return @"MyDocument";
}
- (void)windowControllerDidLoadNib:(NSWindowController *) aController
{
[super windowControllerDidLoadNib:aController];
// Add any code here that needs to be executed once the windowController has loaded the document's window.
}
- (NSData *)dataOfType:(NSString *)typeName error:(NSError **)outError
{
// Insert code here to write your document to data of the specified type. If the given outError != NULL, ensure that you set *outError when returning nil.
// You can also choose to override -fileWrapperOfType:error:, -writeToURL:ofType:error:, or -writeToURL:ofType:forSaveOperation:originalContentsURL:error: instead.
// For applications targeted for Panther or earlier systems, you should use the deprecated API -dataRepresentationOfType:. In this case you can also choose to override -fileWrapperRepresentationOfType: or -writeToFile:ofType: instead.
if ( outError != NULL ) {
*outError = [NSError errorWithDomain:NSOSStatusErrorDomain code:unimpErr userInfo:NULL];
}
return nil;
}
- (BOOL)readFromData:(NSData *)data ofType:(NSString *)typeName error:(NSError **)outError
{
// Insert code here to read your document from the given data of the specified type. If the given outError != NULL, ensure that you set *outError when returning NO.
// You can also choose to override -readFromFileWrapper:ofType:error: or -readFromURL:ofType:error: instead.
// For applications targeted for Panther or earlier systems, you should use the deprecated API -loadDataRepresentation:ofType. In this case you can also choose to override -readFromFile:ofType: or -loadFileWrapperRepresentation:ofType: instead.
if ( outError != NULL ) {
*outError = [NSError errorWithDomain:NSOSStatusErrorDomain code:unimpErr userInfo:NULL];
}
return YES;
}
@end
Jump to Line
Something went wrong with that request. Please try again.