BaseClassForAllSVGBasicShapes.m 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. #import "BaseClassForAllSVGBasicShapes.h"
  2. #import "BaseClassForAllSVGBasicShapes_ForSubclasses.h"
  3. #import "CGPathAdditions.h"
  4. #import "SVGDefsElement.h"
  5. #import "SVGKPattern.h"
  6. #import "CAShapeLayerWithHitTest.h"
  7. #import "SVGElement_ForParser.h" // to resolve Xcode circular dependencies; in long term, parsing SHOULD NOT HAPPEN inside any class whose name starts "SVG" (because those are reserved classes for the SVG Spec)
  8. #import "SVGHelperUtilities.h"
  9. @implementation BaseClassForAllSVGBasicShapes
  10. @synthesize pathForShapeInRelativeCoords = _pathForShapeInRelativeCoords;
  11. @synthesize transform; // each SVGElement subclass that conforms to protocol "SVGTransformable" has to re-synthesize this to work around bugs in Apple's Objective-C 2.0 design that don't allow @properties to be extended by categories / protocols
  12. - (id)init
  13. {
  14. self = [super init];
  15. if (self) {
  16. self.pathForShapeInRelativeCoords = NULL;
  17. }
  18. return self;
  19. }
  20. - (void)dealloc {
  21. CGPathRelease(_pathForShapeInRelativeCoords);
  22. }
  23. -(void)setPathForShapeInRelativeCoords:(CGPathRef)pathForShapeInRelativeCoords
  24. {
  25. if( pathForShapeInRelativeCoords == _pathForShapeInRelativeCoords )
  26. return;
  27. CGPathRelease( _pathForShapeInRelativeCoords ); // Apple says NULL is fine as argument
  28. _pathForShapeInRelativeCoords = pathForShapeInRelativeCoords;
  29. CGPathRetain( _pathForShapeInRelativeCoords );
  30. }
  31. - (CALayer *) newLayer
  32. {
  33. NSAssert(self.pathForShapeInRelativeCoords != NULL, @"Requested a CALayer for SVG shape that never initialized its own .pathForShapeInRelativeCoords property. Shape class = %@. Shape instance = %@", [self class], self );
  34. return [SVGHelperUtilities newCALayerForPathBasedSVGElement:self withPath:self.pathForShapeInRelativeCoords];
  35. }
  36. - (void)layoutLayer:(CALayer *)layer { }
  37. @end