Guest

Untitled

By: a guest on Jan 28th, 2012  |  syntax: None  |  size: 2.01 KB  |  hits: 11  |  expires: Never
download  |  raw  |  embed  |  report abuse
Copied
  1. //
  2. //  DRBlockItem.m
  3. //  PHP.sugar
  4. //
  5. //  Created by Derek Reynolds on 4/16/09.
  6. //  Copyright 2009 gridlee.com. All rights reserved.
  7. //
  8.  
  9. #import "DRBlockItem.h"
  10.  
  11.  
  12. @implementation DRBlockItem
  13.  
  14. - (void)initializeWithCapturedZones:(NSDictionary *)captures recipeInfo:(NSDictionary *)recipeInfo
  15. {
  16.         [super initializeWithCapturedZones:captures recipeInfo:recipeInfo];
  17.        
  18.         name = [[[captures objectForKey:@"name"] text] retain];
  19. }
  20.  
  21. - (void)dealloc
  22. {
  23.         [name release];
  24.         name = nil;
  25.        
  26.         [super dealloc];
  27. }
  28.  
  29. - (BOOL)transformIntoItem:(DRBlockItem *)otherItem
  30. {
  31.         // 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.
  32.         if (![super transformIntoItem:otherItem])
  33.                 return NO;
  34.        
  35.         // Clean up our own old values
  36.         [name release];
  37.         name = nil;
  38.        
  39.         // Take over the new values from the other item
  40.         name = [otherItem->name retain];
  41.         return YES;
  42. }
  43.  
  44. - (BOOL)isDecorator
  45. {
  46.         return YES;
  47. }
  48.  
  49. - (CEItemDecorationType)decorationType
  50. {
  51.         return CEItemDecorationDefault;
  52. }
  53.  
  54. - (NSColor *)backgroundColor
  55. {
  56.         return [NSColor yellowColor];
  57. }
  58.  
  59. - (NSImage *)image
  60. {
  61.         NSString *iconSwitch;
  62.        
  63.         if([name isEqual:@"while"])
  64.         {
  65.                 iconSwitch = @"loop";
  66.         }
  67.         else if([name isEqual:@"if"])
  68.         {
  69.                 iconSwitch = @"if";
  70.         }
  71.         else if([name isEqual:@"else"])
  72.         {
  73.                 iconSwitch = @"else";
  74.         }
  75.         else if([name isEqual:@"for"])
  76.         {
  77.                 iconSwitch = @"loop";
  78.         }
  79.         else if([name isEqual:@"foreach"])
  80.         {
  81.                 iconSwitch = @"foreach";
  82.         }
  83.         else
  84.         {
  85.                 iconSwitch = @"block";
  86.         }
  87.        
  88.         NSString *path = [[NSBundle bundleForClass:[self class]] pathForResource:iconSwitch ofType:@"png"];
  89.         NSImage *image = [[NSImage alloc] initWithContentsOfFile:path];
  90.         [image autorelease];
  91.        
  92.         return image;
  93. }
  94.  
  95. - (BOOL)isTextualizer
  96. {
  97.         return YES;
  98. }
  99.  
  100. - (NSString *)title
  101. {
  102.         return [NSString stringWithFormat:@"Example Annoying: %@", name];
  103.         return name;
  104. }
  105.  
  106. @end