
Untitled
By: a guest on Jan 28th, 2012 | syntax:
None | size: 2.01 KB | hits: 11 | expires: Never
//
// DRBlockItem.m
// PHP.sugar
//
// Created by Derek Reynolds on 4/16/09.
// Copyright 2009 gridlee.com. All rights reserved.
//
#import "DRBlockItem.h"
@implementation DRBlockItem
- (void)initializeWithCapturedZones:(NSDictionary *)captures recipeInfo:(NSDictionary *)recipeInfo
{
[super initializeWithCapturedZones:captures recipeInfo:recipeInfo];
name = [[[captures objectForKey:@"name"] text] retain];
}
- (void)dealloc
{
[name release];
name = nil;
[super dealloc];
}
- (BOOL)transformIntoItem:(DRBlockItem *)otherItem
{
// Note: the passed argument can actually be any item class, but casting it to this specific class makes it easy to write the transformation code. The default (super) implementation takes care of checking the class, so this is perfectly valid.
if (![super transformIntoItem:otherItem])
return NO;
// Clean up our own old values
[name release];
name = nil;
// Take over the new values from the other item
name = [otherItem->name retain];
return YES;
}
- (BOOL)isDecorator
{
return YES;
}
- (CEItemDecorationType)decorationType
{
return CEItemDecorationDefault;
}
- (NSColor *)backgroundColor
{
return [NSColor yellowColor];
}
- (NSImage *)image
{
NSString *iconSwitch;
if([name isEqual:@"while"])
{
iconSwitch = @"loop";
}
else if([name isEqual:@"if"])
{
iconSwitch = @"if";
}
else if([name isEqual:@"else"])
{
iconSwitch = @"else";
}
else if([name isEqual:@"for"])
{
iconSwitch = @"loop";
}
else if([name isEqual:@"foreach"])
{
iconSwitch = @"foreach";
}
else
{
iconSwitch = @"block";
}
NSString *path = [[NSBundle bundleForClass:[self class]] pathForResource:iconSwitch ofType:@"png"];
NSImage *image = [[NSImage alloc] initWithContentsOfFile:path];
[image autorelease];
return image;
}
- (BOOL)isTextualizer
{
return YES;
}
- (NSString *)title
{
return [NSString stringWithFormat:@"Example Annoying: %@", name];
return name;
}
@end